/* ==========================================================================
   Shipment Verify — mobile-first design system  (v2, "Operations Dashboard")
   Palette: logistics navy + tracking blue + amber accent.
   Fonts: Poppins (headings/brand) + Inter (UI/body, tabular figures).
   Designed per UI/UX Pro Max audit. Every class maps to the SPEC contract.
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */
:root {
  /* Brand / surfaces */
  --bg:            #eef2f8;   /* soft blue-slate app canvas */
  --card:          #ffffff;
  --ink:           #0f172a;   /* slate-900 */
  --ink-soft:      #334155;   /* slate-700 */
  --muted:         #64748b;   /* slate-500 */
  --line:          #e2e8f0;   /* slate-200 */
  --line-strong:   #cbd5e1;   /* slate-300 */

  /* Primary = tracking blue; Accent = delivery amber */
  --primary:       #2563eb;   /* blue-600 */
  --primary-dark:  #1d4ed8;   /* blue-700 */
  --primary-tint:  #eff4ff;   /* light blue wash */
  --accent:        #ea580c;   /* orange-600 (urgent / highlight) */
  --navy:          #0f172a;
  --navy-2:        #1e293b;

  /* Status hues */
  --st-pending:  #64748b;
  --st-awaiting: #d97706;
  --st-verified: #16a34a;
  --st-rejected: #dc2626;
  --st-shipped:  #2563eb;

  /* Status soft tints */
  --st-pending-bg:  #eef1f5;
  --st-awaiting-bg: #fef3c7;
  --st-verified-bg: #dcfce7;
  --st-rejected-bg: #fee2e2;
  --st-shipped-bg:  #dbeafe;

  /* Spacing scale (4/8 rhythm) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;

  /* Radius / elevation */
  --r-sm: 10px; --r: 14px; --r-lg: 18px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.05);
  --sh-2: 0 2px 6px rgba(15,23,42,.10), 0 12px 28px rgba(15,23,42,.10);
  --sh-nav: 0 -2px 14px rgba(15,23,42,.07);

  --tap: 44px;

  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Poppins", var(--font-body);
}

/* --- Reset / base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; letter-spacing: -.01em; }

/* tabular figures wherever we show counts/quantities */
.stat-num, .badge-qty, .expected strong, .rc-sub, .meta { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* --- Top bar -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 12px var(--s4);
  padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 4px 16px rgba(15,23,42,.28);
}

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-head);
  font-weight: 700; font-size: 1.0625rem; letter-spacing: -.01em; white-space: nowrap;
}
.brand svg { color: #fbbf24; flex: 0 0 auto; }   /* amber mark pops on navy */

.who {
  font-size: .8125rem; color: #cbd5e1;
  display: flex; align-items: center; gap: 7px; min-width: 0;
}
.who a { color: #e2e8f0; font-weight: 500; }
.who a:hover { color: #fff; }

/* Role pill (top bar) */
.role {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; line-height: 1.5;
  background: rgba(255,255,255,.14); color: #e2e8f0;
}
.role-admin    { background: rgba(37,99,235,.95);  color: #fff; }
.role-verifier { background: rgba(22,163,74,.95);  color: #fff; }
.role-packer   { background: rgba(217,119,6,.95);  color: #fff; }

/* --- Layout container ----------------------------------------------------- */
.container { max-width: 720px; margin: 0 auto; padding: var(--s4); padding-bottom: 100px; }

/* --- Bottom navigation ---------------------------------------------------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: var(--sh-nav);
}
.navitem {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: 62px; padding: 8px 4px;
  color: var(--muted); text-decoration: none; font-weight: 600;
  transition: color .15s ease, background .15s ease;
}
.navitem:hover { text-decoration: none; color: var(--ink); background: #f8fafc; }
.navitem.active { color: var(--primary); }
.navitem.active .ico { transform: translateY(-1px); }
.ico { display: inline-flex; align-items: center; justify-content: center; line-height: 1; transition: transform .15s ease; }
.ico svg { display: block; }
.lbl { font-size: 11px; line-height: 1.2; letter-spacing: .01em; }

/* --- Flash messages ------------------------------------------------------- */
.flash {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 11px 14px; border-radius: var(--r-sm); margin-bottom: var(--s3);
  font-size: .9375rem; border: 1px solid transparent;
}
.flash::before { content: ""; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: currentColor; }
.flash-info    { background: var(--primary-tint); color: #1e40af; border-color: #bfdbfe; }
.flash-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* --- Cards & text --------------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--sh-1); padding: var(--s4); margin-bottom: var(--s3);
}
.block { margin-bottom: var(--s5); }
.block > h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.0625rem; font-weight: 700; margin: 0 0 var(--s3);
}
.block > h2 svg { color: var(--muted); }
.page-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 6px; }
.section-title { font-size: 1.125rem; font-weight: 700; margin: 18px 0 10px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; font-size: .9375rem; }
.spacer { height: var(--s4); }
.right { margin-left: auto; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.meta { font-size: .8125rem; color: var(--muted); }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 11px 18px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-family: var(--font-body); font-size: 1rem; font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, border-color .15s ease, transform .06s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.985); }
.btn svg { flex: 0 0 auto; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(37,99,235,.35); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: #15803d; color: #fff; }            /* AA-contrast (4.5:1) green */
.btn-success:hover { background: #166534; }
.btn-danger  { background: var(--st-rejected); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost   { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #f8fafc; border-color: var(--line-strong); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 38px; padding: 7px 14px; font-size: .875rem; border-radius: 9px; }

/* --- Forms ---------------------------------------------------------------- */
label, input, select, textarea { font-family: inherit; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 11px 13px; font-size: 16px;
  color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm);
  appearance: none; -webkit-appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.16);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px;
}
input[type="file"] { padding: 9px 12px; font-size: .9375rem; line-height: 1.6; }
.field { display: block; margin-bottom: var(--s3); font-size: .8125rem; font-weight: 600; color: var(--ink-soft); }
.field > input, .field > select, .field > textarea { margin-top: 6px; font-weight: 400; color: var(--ink); }
.form-grid { display: flex; flex-direction: column; gap: 2px; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 2px 12px; }
@media (min-width: 520px) { .form-row { grid-template-columns: 1fr 1fr; } }
.help { font-size: .8125rem; color: var(--muted); margin-top: 4px; }

/* --- Badges & pills ------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-pending               { background: var(--st-pending-bg);  color: #475569; }
.badge-awaiting_verification { background: var(--st-awaiting-bg); color: #b45309; }
.badge-verified              { background: var(--st-verified-bg); color: #15803d; }
.badge-rejected              { background: var(--st-rejected-bg); color: #b91c1c; }
.badge-shipped               { background: var(--st-shipped-bg);  color: #1d4ed8; }
.pill {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; line-height: 1.5; background: #eef1f5; color: #475569; white-space: nowrap;
}
.badge-qty {
  display: inline-flex; align-items: center; padding: 4px 11px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 700; line-height: 1.5; background: var(--primary-tint); color: var(--primary-dark); white-space: nowrap;
}

/* --- Stat tiles ----------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(116px, 1fr)); gap: var(--s2); margin-bottom: var(--s5); }
.stat {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-align: center; text-decoration: none; color: var(--ink);
  padding: 16px 12px; margin-bottom: 0; overflow: hidden;
  transition: transform .1s ease, box-shadow .15s ease;
}
.stat::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--line); }
.stat:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--sh-2); }
.stat:active { transform: translateY(0); }
.stat-num { font-size: 1.9rem; font-weight: 700; line-height: 1.05; letter-spacing: -.02em; }
.stat-lbl { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.s-pending::before  { background: var(--st-pending); }
.s-awaiting::before { background: var(--st-awaiting); }
.s-verified::before { background: var(--st-verified); }
.s-rejected::before { background: var(--st-rejected); }
.s-shipped::before  { background: var(--st-shipped); }
.s-pending  .stat-num { color: var(--st-pending); }
.s-awaiting .stat-num { color: var(--st-awaiting); }
.s-verified .stat-num { color: var(--st-verified); }
.s-rejected .stat-num { color: var(--st-rejected); }
.s-shipped  .stat-num { color: var(--st-shipped); }

/* --- Row cards ------------------------------------------------------------ */
.row-card {
  display: flex; align-items: center; gap: var(--s3); color: var(--ink); text-decoration: none;
  transition: transform .1s ease, box-shadow .15s ease, border-color .15s ease;
}
.row-card:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--sh-2); }
.row-card:active { transform: scale(.99); }
.rc-main { min-width: 0; flex: 1 1 auto; }
.rc-title { font-weight: 600; font-size: 1rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.rc-sub { font-size: .8125rem; color: var(--muted); margin-top: 3px; }
.row-card .badge, .row-card .badge-qty, .row-card .pill { flex: 0 0 auto; }

/* --- Photo grids ---------------------------------------------------------- */
.photo-grid, .preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: var(--s2); }
.photo-thumb, .preview-thumb {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: #f1f5f9; display: block;
}
.preview-grid { margin-top: 10px; }

/* --- Verify card ---------------------------------------------------------- */
.verify-card { scroll-margin-top: 76px; }
.expected {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px;
  background: var(--primary-tint); border: 1px solid #dbe6ff; border-left: 4px solid var(--primary);
  border-radius: var(--r-sm); padding: 12px 14px; margin: 12px 0; font-size: .9375rem; color: #1e3a8a;
}
.expected strong { font-size: 1.3rem; font-weight: 700; color: var(--primary-dark); }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: var(--s3); }
.reject-box {
  display: flex; flex-direction: column; gap: var(--s2); padding: 12px;
  border: 1px dashed #fecaca; background: #fef2f2; border-radius: var(--r-sm);
}

/* --- Filter chips --------------------------------------------------------- */
.filters {
  display: flex; gap: var(--s2); overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding-bottom: 4px; margin-bottom: var(--s3);
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; flex: 0 0 auto; padding: 8px 15px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  font-size: .875rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.chip:hover { text-decoration: none; border-color: var(--line-strong); background: #f8fafc; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.active:hover { background: var(--primary-dark); }

/* --- Generic lists -------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: var(--s3); padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }

/* --- Login ---------------------------------------------------------------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 82vh; padding: 16px 0; }
.login-card { width: 100%; max-width: 380px; padding: 30px 26px; margin-bottom: 0; }
.login-logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-head); font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px;
}
.login-logo svg { color: var(--primary); }
.login-card .muted { margin-top: 0; margin-bottom: 18px; }
.login-card form { margin-top: 4px; }
.login-card .btn-block { margin-top: 6px; }

/* --- Import preview -------------------------------------------------------- */
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .875rem; color: var(--ink-soft); margin: 4px 0 8px; }
.checkline input { width: auto; min-height: 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 4px 0 12px; }
.import-table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.import-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.import-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.import-table tr:last-child td { border-bottom: 0; }
.import-table .imp-skip { opacity: .5; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* --- Photo lightbox (full-resolution viewer) ------------------------------ */
.photo-thumb { cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(2,6,23,.93);
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  animation: lb-in .15s ease;
}
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lightbox-stage {
  max-width: 100%; max-height: 100%; overflow: auto;
  -webkit-overflow-scrolling: touch; touch-action: pinch-zoom;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-img { max-width: 100vw; max-height: 100vh; object-fit: contain; cursor: zoom-in; user-select: none; -webkit-user-select: none; }
.lightbox-stage.zoomed { align-items: flex-start; justify-content: flex-start; }
.lightbox-stage.zoomed .lightbox-img { max-width: none; max-height: none; width: auto; cursor: zoom-out; }
.lightbox-close {
  position: fixed; top: calc(8px + env(safe-area-inset-top)); right: 12px; z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.14); color: #fff; font-size: 28px; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,.26); }
.lightbox-hint {
  position: fixed; bottom: calc(10px + env(safe-area-inset-bottom)); left: 0; right: 0;
  text-align: center; color: #cbd5e1; font-size: 12px; pointer-events: none;
}

/* --- Motion preferences --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
