* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #F3F4F6;
  color: #111827;
  -webkit-tap-highlight-color: transparent;
}
body {
  display: flex; flex-direction: column;
  font-size: 15px;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ====== Pages ====== */
.page {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.page.active { display: flex; }

/* ====== Topbar ====== */
.topbar {
  display: flex; align-items: center;
  padding: 12px 16px;
  background: #1F2937; color: #fff;
  flex-shrink: 0;
}
.topbar .title { flex: 1; font-weight: 600; font-size: 1.05rem; }
.topbar .user-name { font-weight: 600; }
.topbar .user-role { font-size: 0.78rem; opacity: 0.7; }
.topbar > div:first-child { flex: 1; }
.icon-btn {
  background: transparent; border: none; color: #fff;
  width: 40px; height: 40px; font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,0.15); }

/* ====== Login ====== */
#page-login { background: linear-gradient(160deg, #1F2937, #374151); }
.login-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
  color: #fff;
}
.brand { text-align: center; margin-bottom: 32px; }
.brand i { font-size: 3rem; color: #60A5FA; }
.brand h1 { font-size: 2rem; margin: 8px 0 4px; }
.brand .muted { color: #9CA3AF; font-size: 0.9rem; }
.brand-logo {
  width: 75%; max-width: 280px; height: auto;
  display: block; margin: 0 auto 6px; border-radius: 12px;
}

.login-form {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 8px;
}
.login-form label {
  font-size: 0.78rem; color: #9CA3AF; margin-top: 8px;
}
.login-form input {
  background: #374151; color: #fff; border: 1px solid #4B5563;
  padding: 12px 14px; border-radius: 8px;
  font-size: 1rem; outline: none;
}
.login-form input:focus { border-color: #60A5FA; }
.login-form button {
  margin-top: 16px;
  background: #2563EB; color: #fff;
  border: none; padding: 14px;
  font-size: 1.05rem; font-weight: 600;
  border-radius: 8px; cursor: pointer;
}
.login-form button:active { background: #1D4ED8; }
.login-form .error {
  color: #F87171; text-align: center; margin-top: 8px; font-size: 0.85rem;
  min-height: 1.2rem;
}
.login-hint {
  text-align: center; margin-top: 12px; color: #6B7280;
}

/* ====== Main menu ====== */
#page-menu { background: #F3F4F6; }
.menu-grid {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.mode-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #fff;
  border: none;
  border-radius: 16px;
  padding: 24px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.1s;
  border-left: 6px solid transparent;
  text-align: center;
}
.mode-btn:active { transform: scale(0.98); }
.mode-btn i { font-size: 2.5rem; margin-bottom: 8px; }
.mode-btn span { font-size: 1.3rem; font-weight: 700; }
.mode-btn small { color: #6B7280; margin-top: 4px; }
.mode-inbound { border-left-color: #7C3AED; color: #5B21B6; }
.mode-inbound i { color: #7C3AED; }
.mode-pick { border-left-color: #2563EB; color: #1D4ED8; }
.mode-pick i { color: #2563EB; }
.mode-dispatch { border-left-color: #059669; color: #047857; }
.mode-dispatch i { color: #059669; }
.mode-place { border-left-color: #F59E0B; color: #B45309; }
.mode-place i { color: #F59E0B; }
.mode-info { border-left-color: #0EA5E9; color: #0369A1; }
.mode-info i { color: #0EA5E9; }
.mode-return { border-left-color: #DC2626; color: #991B1B; }
.mode-return i { color: #DC2626; }

.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-btn { padding: 16px; }
.mode-btn i { font-size: 2rem; margin-bottom: 4px; }
.mode-btn span { font-size: 1rem; }

/* RMA reason grid */
.reason-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 8px;
}
.reason-btn {
  background: #fff;
  border: 2px solid #E5E7EB;
  border-radius: 8px;
  padding: 12px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  text-align: center;
}
.reason-btn:active, .reason-btn.selected {
  background: #FEE2E2;
  border-color: #DC2626;
  color: #991B1B;
}
.mode-place { border-left-color: #F59E0B; color: #B45309; }
.mode-place i { color: #F59E0B; }
.mode-info { border-left-color: #0EA5E9; color: #0369A1; }
.mode-info i { color: #0EA5E9; }
.menu-grid .mode-btn { padding: 14px; }
.menu-grid .mode-btn i { font-size: 1.8rem; margin-bottom: 4px; }
.menu-grid .mode-btn span { font-size: 1.05rem; }

.menu-foot {
  padding: 12px 16px;
  font-size: 0.78rem; color: #6B7280;
  text-align: center;
  background: #fff;
  border-top: 1px solid #E5E7EB;
}
.menu-foot .dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: #9CA3AF; margin-right: 4px;
}
.menu-foot .dot.online { background: #10B981; }
.menu-foot .dot.offline { background: #EF4444; }

/* ====== Scan pages ====== */
.scan-page .content {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.row {
  display: flex; flex-direction: column; gap: 4px;
}
.row label {
  font-size: 0.78rem; color: #6B7280;
}
.select {
  padding: 10px; font-size: 1rem;
  border-radius: 8px; border: 1px solid #D1D5DB;
  background: #fff;
}
.ship-info {
  background: #E5E7EB;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #374151;
}
.stage-banner {
  background: #2563EB; color: #fff;
  padding: 14px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.5px;
}
.hint {
  color: #6B7280;
  font-size: 0.85rem;
}
.scan-box { }
.scan-input {
  width: 100%;
  padding: 18px 14px;
  font-size: 1.4rem;
  font-weight: 600;
  border: 2px solid #2563EB;
  border-radius: 10px;
  outline: none;
  background: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.scan-input:focus { border-color: #1D4ED8; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

.result-box {
  padding: 20px;
  border-radius: 10px;
  color: #fff;
  font-size: 1rem;
  text-align: center;
  font-weight: 500;
  min-height: 80px;
  display: flex; align-items: center; justify-content: center;
  white-space: pre-line;
}
.result-box.neutral { background: #6B7280; }
.result-box.success { background: #059669; }
.result-box.error { background: #DC2626; }
.result-box.warning { background: #F59E0B; }
.result-box.info { background: #2563EB; }

.info-card {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.95rem;
  color: #111827;
  border: 1px solid #E5E7EB;
}
.info-card.success {
  background: #D1FAE5; border-color: #6EE7B7;
  color: #065F46;
}

.next-card {
  background: linear-gradient(135deg, #1E40AF, #2563EB);
  color: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.next-card .next-label {
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  opacity: 0.8;
  margin-bottom: 4px;
}
.next-card .next-rack {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 1px;
}
.next-card .next-cell {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2px 0;
  letter-spacing: 1px;
}
.next-card .next-track {
  font-size: 0.85rem;
  opacity: 0.85;
  font-family: monospace;
}

/* Direktiv yig'ish paneli — yirik, ko'rinarli */
.pick-target {
  background: linear-gradient(135deg, #1E3A8A, #2563EB);
  color: #fff;
  border-radius: 14px;
  padding: 18px 16px;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pick-target-label {
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  opacity: 0.85;
  font-weight: 600;
  text-transform: uppercase;
}
.pick-target-rack {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #FCD34D;
}
.pick-target-cell {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  font-family: 'Courier New', monospace;
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 6px 10px;
  text-align: center;
}
.pick-target-hr {
  border-top: 1px dashed rgba(255, 255, 255, 0.3);
  margin: 6px 0;
}
.pick-target-track {
  font-size: 1.3rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  background: #FCD34D;
  color: #1F2937;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: center;
  letter-spacing: 1px;
  word-break: break-all;
}
.pick-target-meta {
  font-size: 0.85rem;
  opacity: 0.9;
  text-align: center;
  margin-top: 2px;
}
.pick-target-progress {
  font-size: 0.78rem;
  text-align: center;
  margin-top: 4px;
  opacity: 0.8;
}

.no-target {
  background: #D1FAE5;
  color: #065F46;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.no-target i {
  font-size: 2.5rem;
  color: #059669;
}

/* Trek info detail card */
.info-detail {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #E5E7EB;
}
.info-detail h2 {
  font-size: 1.1rem;
  margin: 0;
  word-break: break-all;
  color: #111827;
}
.info-detail .row-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  border-bottom: 1px solid #F3F4F6;
  padding-bottom: 6px;
}
.info-detail .row-info:last-child { border-bottom: none; }
.info-detail .row-info span:first-child { color: #6B7280; }
.info-detail .row-info span:last-child {
  color: #111827;
  font-weight: 600;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}
.info-detail .badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
.info-detail .badge-paid { background: #D1FAE5; color: #065F46; }
.info-detail .badge-unpaid { background: #FEF3C7; color: #92400E; }
.info-detail .badge-cod { background: #FFE5D0; color: #7C2D12; }
.info-detail .badge-violated { background: #FEE2E2; color: #991B1B; }
.info-detail .section-title {
  font-size: 0.78rem;
  letter-spacing: 1px;
  color: #6B7280;
  text-transform: uppercase;
  margin-top: 6px;
}

.session {
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  display: flex; flex-direction: column; gap: 4px;
}
.session strong { font-size: 1rem; color: #111827; }
.session small { color: #6B7280; }

.big-btn {
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
.big-btn.purple { background: #7C3AED; }
.big-btn.red { background: #DC2626; }
.big-btn:active { opacity: 0.85; }

.scan-list {
  display: flex; flex-direction: column; gap: 6px;
  background: #fff;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  max-height: 40vh;
  overflow-y: auto;
  font-size: 0.85rem;
}
.scan-list .item {
  padding: 6px 8px;
  border-bottom: 1px solid #F3F4F6;
}
.scan-list .item:last-child { border-bottom: none; }
.scan-list .item.error { color: #B91C1C; }

/* Skaner tarixi qatori (inbound) */
.scan-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; border-bottom: 1px solid #F3F4F6; gap: 8px;
}
.scan-row:last-child { border-bottom: none; }
.scan-row code { font-size: 0.85rem; }
.scan-row .muted { color: #9CA3AF; }
.tag {
  display: inline-block; font-size: 0.7rem; font-weight: 700;
  padding: 1px 6px; border-radius: 6px; margin-right: 4px; color: #fff;
}
.tag.paid { background: #059669; }
.tag.unpaid { background: #D97706; }
.tag.dub { background: #6B7280; }

/* ====== Toast ====== */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1F2937; color: #fff;
  padding: 12px 18px; border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 90%;
  z-index: 1000;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: #DC2626; }
#toast.success { background: #059669; }

/* ====== Animation ====== */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  100% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}
.pulse { animation: pulse 1s; }

/* ====== Wide screen (kompyuter) ====== */
@media (min-width: 720px) {
  body { background: #1F2937; align-items: center; justify-content: center; }
  .page {
    max-width: 420px;
    height: 90vh;
    max-height: 880px;
    margin: 0 auto;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    background: #F3F4F6;
  }
  .page.active { display: flex; }
}
