/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple:    #6c47ff;
  --purple-d:  #5535e0;
  --purple-l:  #ede9ff;
  --green:     #22c55e;
  --green-d:   #16a34a;
  --red:       #ef4444;
  --red-d:     #dc2626;
  --orange:    #f97316;
  --yellow:    #eab308;
  --gray-50:   #f8fafc;
  --gray-100:  #f1f5f9;
  --gray-200:  #e2e8f0;
  --gray-300:  #cbd5e1;
  --gray-400:  #94a3b8;
  --gray-500:  #64748b;
  --gray-700:  #334155;
  --gray-900:  #0f172a;
  --white:     #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
  --radius:    14px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.app-header__logo {
  font-weight: 700;
  font-size: 17px;
  color: var(--purple);
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header__user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--gray-500);
}

.app-header__logout {
  color: var(--red);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.app-header__logout:hover { background: #fee2e2; }

.page-content {
  padding: 16px;
  max-width: 560px;
  margin: 0 auto;
}

/* ===== LOGIN PAGE ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #ede9ff 0%, #f8fafc 100%);
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-card__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 4px;
  text-align: center;
}

.login-card__subtitle {
  color: var(--gray-400);
  text-align: center;
  font-size: 13px;
  margin-bottom: 28px;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  color: var(--gray-900);
}
.form-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(108,71,255,.12);
}
.form-input::placeholder { color: var(--gray-400); }

.form-input--code {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 5px;
  text-align: center;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
  width: 100%;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--purple);
  color: var(--white);
}
.btn--primary:hover { background: var(--purple-d); }

.btn--success {
  background: var(--green);
  color: var(--white);
}
.btn--success:hover { background: var(--green-d); }

.btn--danger {
  background: var(--red);
  color: var(--white);
}
.btn--danger:hover { background: var(--red-d); }

.btn--ghost {
  background: var(--gray-100);
  color: var(--gray-700);
}
.btn--ghost:hover { background: var(--gray-200); }

.btn--orange {
  background: var(--orange);
  color: var(--white);
}

.btn--sm {
  padding: 7px 14px;
  font-size: 13px;
  width: auto;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  margin-bottom: 12px;
}

.card--active {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px rgba(108,71,255,.15);
}

.card--success { border-color: var(--green); background: #f0fdf4; }
.card--warning { border-color: var(--orange); background: #fff7ed; }
.card--danger  { border-color: var(--red);    background: #fef2f2; }

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card__title {
  font-weight: 700;
  font-size: 15px;
  color: var(--gray-900);
}

.card__meta {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 4px;
}

/* ===== PVZ GRID ===== */
.pvz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.pvz-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
  text-align: center;
  position: relative;
}
.pvz-card:hover {
  border-color: var(--purple);
  box-shadow: var(--shadow);
}
.pvz-card.selected {
  border-color: var(--purple);
  background: var(--purple-l);
}

.pvz-card__name {
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.3;
  margin-bottom: 8px;
}

.pvz-card__badge {
  display: inline-block;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}
.pvz-card__badge--free   { background: #dcfce7; color: #15803d; }
.pvz-card__badge--locked { background: #fef9c3; color: #a16207; }
.pvz-card__badge--zero   { background: var(--gray-100); color: var(--gray-400); }

.pvz-card__collectors {
  margin-top: 6px;
  font-size: 11px;
  color: var(--purple);
  font-weight: 500;
}

/* ===== BADGES / TAGS ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge--purple { background: var(--purple-l); color: var(--purple); }
.badge--green  { background: #dcfce7; color: #15803d; }
.badge--red    { background: #fee2e2; color: #dc2626; }
.badge--gray   { background: var(--gray-100); color: var(--gray-500); }
.badge--yellow { background: #fef9c3; color: #a16207; }

/* ===== ORDER CARD ===== */
.order-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.order-card--locked {
  opacity: .65;
  border-color: var(--yellow);
  background: #fffbeb;
}

.order-card__header {
  padding: 12px 14px 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.order-card__num {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 600;
  flex-shrink: 0;
}

.order-card__code {
  font-size: 17px;
  font-weight: 700;
  color: var(--purple);
  letter-spacing: 1px;
  font-family: 'SF Mono', Consolas, monospace;
}

.order-card__info {
  padding: 0 14px 12px;
  font-size: 13px;
  color: var(--gray-700);
}

.order-card__row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.order-card__row .icon {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  color: var(--gray-400);
}

.order-card__comment {
  margin-top: 6px;
  padding: 6px 10px;
  background: #fff7ed;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--orange);
  font-weight: 500;
}

.order-card__locked-label {
  padding: 6px 14px;
  background: #fef9c3;
  font-size: 12px;
  color: #a16207;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.order-card__image {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  display: block;
}

/* ===== PROCESS FORM ===== */
.process-form {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 2px solid var(--purple);
  margin-bottom: 16px;
}

.process-form__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.btn-row--3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ===== PHOTO UPLOAD ===== */
.photo-upload {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
  overflow: hidden;
}
.photo-upload:hover { border-color: var(--purple); background: var(--purple-l); }
.photo-upload input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.photo-upload__icon { font-size: 28px; margin-bottom: 6px; }
.photo-upload__text { font-size: 13px; color: var(--gray-500); }
.photo-upload__preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: none;
  margin-top: 8px;
}

/* ===== RANGE PICKER ===== */
.range-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.range-picker label {
  font-size: 13px;
  color: var(--gray-500);
  white-space: nowrap;
}

.range-picker input[type=number] {
  width: 70px;
  padding: 8px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  outline: none;
}
.range-picker input[type=number]:focus {
  border-color: var(--purple);
}

.range-sep { color: var(--gray-400); font-weight: 700; font-size: 17px; }

/* ===== GIVEOUT RESULT CARD ===== */
.result-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.result-card__img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: block;
}

.result-card__body { padding: 16px; }

.result-card__title {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
  margin-bottom: 2px;
}

.result-card__value {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 10px;
}

.result-card__value--code {
  font-size: 20px;
  color: var(--purple);
  font-family: 'SF Mono', Consolas, monospace;
  letter-spacing: 2px;
}

.result-card__alert {
  background: #fffbeb;
  border: 1px solid var(--yellow);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: #a16207;
  font-weight: 500;
  margin-bottom: 12px;
  display: flex;
  gap: 7px;
  align-items: flex-start;
}

/* ===== SECTION TITLE ===== */
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .count {
  background: var(--purple-l);
  color: var(--purple);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 13px;
}

/* ===== SESSION BANNER ===== */
.session-banner {
  background: linear-gradient(135deg, var(--purple) 0%, #8b5cf6 100%);
  color: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.session-banner__info { flex: 1; }

.session-banner__title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 2px;
}

.session-banner__sub {
  font-size: 12px;
  opacity: .8;
}

/* ===== ALERTS ===== */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.alert--error   { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.alert--success { background: #dcfce7; color: #16a34a; border: 1px solid #86efac; }
.alert--info    { background: var(--purple-l); color: var(--purple); border: 1px solid #c4b5fd; }
.alert--warning { background: #fffbeb; color: #a16207; border: 1px solid #fde68a; }

/* ===== LOADER ===== */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--gray-400);
  flex-direction: column;
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 16px 0;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state__icon { font-size: 48px; margin-bottom: 12px; }
.empty-state__text { font-size: 15px; }

/* ===== TABS ===== */
.tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
  gap: 2px;
}

.tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tab.active {
  background: var(--white);
  color: var(--purple);
  box-shadow: var(--shadow-sm);
}

/* ===== TOAST ===== */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  max-width: calc(100vw - 32px);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.toast--success { background: var(--green-d); }
#toast.toast--error   { background: var(--red-d); }

/* ===== STEP INDICATOR ===== */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-200);
  transition: background .2s, transform .2s;
}
.step-dot.active  { background: var(--purple); transform: scale(1.3); }
.step-dot.done    { background: var(--green); }

/* ===== PROGRESS ===== */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), #8b5cf6);
  border-radius: 10px;
  transition: width .4s ease;
}

/* ===== UTILS ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--gray-400); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.fw-bold { font-weight: 700; }
.gap-2 { gap: 8px; }

/* ===== MOBILE OPTIMIZATION ===== */
@media (max-width: 400px) {
  .pvz-grid { grid-template-columns: 1fr; }
  .btn-row { grid-template-columns: 1fr; }
  .btn-row--3 { grid-template-columns: 1fr; }
  .range-picker { flex-wrap: wrap; }
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .page-content { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
