/* =====================================================================
   Stock Verification — design system
   ---------------------------------------------------------------------
   Built for one job: three storekeepers counting parts on a foundry
   floor, on phones, in Arabic and English.

   Decisions that follow from that:
   · Bottom navigation on phones, top navigation from 900px up.
   · Every tappable thing is at least 44x44 with room around it.
   · Part numbers and quantities are monospace with tabular figures —
     a part number is read digit by digit, not as a word.
   · Variance never relies on colour alone: a sign, a word and a colour.
     Surplus is violet, not green — finding more than the book says is
     a discrepancy, not a success.
   · Dark mode is automatic; a warehouse is not a bright office.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ---------- tokens -------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* anodised-aluminium palette — the finish on the wheels they cast */
  --brand:      #0A5C9E;
  --brand-700:  #084A80;
  --brand-100:  #E4EFF8;

  --danger:     #B3261E;   /* shortage */
  --danger-bg:  #FCEBE9;
  --violet:     #59459C;   /* surplus, and Odoo-only items */
  --violet-bg:  #EDEAF7;
  --ok:         #0F7A4A;   /* verified */
  --ok-bg:      #E3F3EB;
  --warn:       #9A5B08;   /* awaiting verification */
  --warn-bg:    #FDF1DC;

  --page:    #F4F7FA;
  --panel:   #FFFFFF;
  --raised:  #FAFBFD;
  --line:    #DDE4EC;
  --line-2:  #EBEFF4;
  --ink:     #101828;
  --ink-2:   #3B4A5A;
  --muted:   #64748B;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  --shadow-1: 0 1px 2px rgb(16 24 40 / .06);
  --shadow-2: 0 1px 3px rgb(16 24 40 / .08), 0 8px 24px rgb(16 24 40 / .06);

  --nav-h: 62px;
  --tap: 44px;

  --sans: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', 'Segoe UI', system-ui,
          -apple-system, 'Helvetica Neue', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', 'Cascadia Mono',
          'Courier New', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand:     #4D9BD6;
    --brand-700: #6FB2E3;
    --brand-100: #16283A;

    --danger:    #F2857B;  --danger-bg: #35191A;
    --violet:    #A99AE0;  --violet-bg: #221E36;
    --ok:        #57C295;  --ok-bg:     #102A21;
    --warn:      #E0AA5A;  --warn-bg:   #2E2211;

    --page:   #0B1015;
    --panel:  #141A21;
    --raised: #1A222B;
    --line:   #26313C;
    --line-2: #1E2831;
    --ink:    #E7EDF4;
    --ink-2:  #C3CEDA;
    --muted:  #8CA0B3;

    --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-2: 0 1px 3px rgb(0 0 0 / .5), 0 8px 24px rgb(0 0 0 / .35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
@media (min-width: 900px) { body { padding-bottom: 0; } }

.mono, .code, td.code, .num, input.qty {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}

/* ---------- header -------------------------------------------------- */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
  padding-top: env(safe-area-inset-top);
}
.topbar-in {
  max-width: 1600px; margin: 0 auto;
  padding: var(--sp-2) var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-3); min-height: 56px;
}
.brand {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 700; font-size: 15px; white-space: nowrap; color: var(--ink);
  text-decoration: none;
}
.brand img { width: 28px; height: 28px; border-radius: 7px; display: block; }
.brand .sub { font-weight: 400; font-size: 12px; color: var(--muted); }

nav.main { display: none; gap: 2px; flex: 1; }
@media (min-width: 900px) { nav.main { display: flex; flex-wrap: wrap; } }
nav.main a {
  color: var(--ink-2); text-decoration: none;
  padding: 9px var(--sp-3); border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  display: inline-flex; align-items: center; min-height: 40px;
}
nav.main a:hover { background: var(--line-2); color: var(--ink); }
nav.main a[aria-current="page"] { background: var(--brand-100); color: var(--brand); font-weight: 600; }

.topbar .spacer { flex: 1; }
.who { font-size: 13px; color: var(--muted); display: none; }
@media (min-width: 700px) { .who { display: block; } }
.who b { color: var(--ink); font-weight: 600; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap);
  border-radius: var(--r-sm); color: var(--ink-2);
  text-decoration: none; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; background: none; cursor: pointer;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- bottom navigation (phones) ------------------------------ */
.botnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
  display: flex; background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 3px rgb(16 24 40 / .06);
}
@media (min-width: 900px) { .botnav { display: none; } }
.botnav a {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--nav-h); padding: var(--sp-2) 2px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.botnav a svg { width: 22px; height: 22px; }
.botnav a[aria-current="page"] { color: var(--brand); }
.botnav a[aria-current="page"]::before {
  content: ""; position: absolute; top: 5px;
  width: 22px; height: 3px; border-radius: 999px; background: var(--brand);
}
.botnav a span { line-height: 1.15; text-align: center; }
.botnav a:active { background: var(--line-2); }

/* ---------- layout -------------------------------------------------- */
.wrap { max-width: 1600px; margin: 0 auto; padding: var(--sp-5) var(--sp-4) var(--sp-8); }
@media (max-width: 600px) { .wrap { padding: var(--sp-4) var(--sp-3) var(--sp-6); } }

h1 { font-size: 22px; font-weight: 700; margin: 0 0 2px; letter-spacing: -.015em; }
h2 { font-size: 15px; font-weight: 600; margin: 0; color: var(--ink); }
h3 { font-size: 12px; font-weight: 600; margin: 0 0 var(--sp-2); color: var(--muted);
     text-transform: uppercase; letter-spacing: .06em; }
.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 var(--sp-5); }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-1);
  margin-bottom: var(--sp-4); overflow: hidden;
}
.panel > .hd {
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  background: var(--raised);
}
.panel > .hd h2 { flex: 1; }
.panel > .bd { padding: var(--sp-4); }
.panel > .bd.flush { padding: 0; }

.grid { display: grid; gap: var(--sp-3); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr)); }

/* ---------- stat tiles ---------------------------------------------- */
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: var(--sp-3) var(--sp-4);
  border-inline-start: 3px solid var(--muted);
  display: block; text-decoration: none; color: inherit;
}
a.stat:hover { border-color: var(--brand); box-shadow: var(--shadow-2); }
.stat .v { font-family: var(--mono); font-size: 25px; font-weight: 600;
           line-height: 1.15; letter-spacing: -.02em; }
.stat .k { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat .x { font-size: 11.5px; color: var(--muted); margin-top: var(--sp-1); }
.stat.blue   { border-inline-start-color: var(--brand); }
.stat.warn   { border-inline-start-color: var(--warn); }
.stat.ok     { border-inline-start-color: var(--ok); }
.stat.danger { border-inline-start-color: var(--danger); }
.stat.violet { border-inline-start-color: var(--violet); }

/* ---------- tables --------------------------------------------------- */
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: start; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line);
  background: var(--raised); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.tbl td { padding: var(--sp-3); border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.tbl tbody tr:hover { background: var(--raised); }
table.tbl td.num, table.tbl th.num { text-align: end; white-space: nowrap; }
table.tbl td.code { font-size: 12.5px; font-weight: 500; white-space: nowrap; color: var(--brand); }
table.tbl tfoot td { background: var(--raised); font-weight: 600; border-top: 1px solid var(--line); }
.name { max-width: 380px; }
@media (max-width: 700px) { .name { max-width: 170px; } }

.empty { padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- chips ---------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.chip.pending  { background: var(--warn-bg);   color: var(--warn);   border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.chip.verified { background: var(--ok-bg);     color: var(--ok);     border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.chip.rejected { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.chip.odoo     { background: var(--violet-bg); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 30%, transparent); }
.chip.excel    { background: var(--brand-100); color: var(--brand);  border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.chip.both     { background: var(--line-2);    color: var(--ink-2);  border-color: var(--line); }

/* variance — colour is never the only signal; the sign and word carry it too */
.short { color: var(--danger); font-weight: 600; }
.over  { color: var(--violet); font-weight: 600; }
.same  { color: var(--muted); }

/* ---------- forms ---------------------------------------------------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: var(--sp-1); }
label .hint { font-weight: 400; color: var(--muted); }

input[type=text], input[type=password], input[type=number], input[type=search],
select, textarea {
  width: 100%; padding: 11px var(--sp-3); font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel); color: var(--ink); min-height: var(--tap);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 16px center, right 11px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 32px;
}
[dir=rtl] select { background-position: left 11px center, left 16px center; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}
textarea { min-height: 72px; resize: vertical; }
.field { margin-bottom: var(--sp-4); }
.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1; min-width: 150px; margin-bottom: 0; }

.check {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 14px; font-weight: 500; margin-bottom: 2px;
  min-height: var(--tap); cursor: pointer;
}
.check input { width: 20px; height: 20px; accent-color: var(--brand); flex: 0 0 auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 10px var(--sp-4); font: inherit; font-size: 14.5px; font-weight: 600;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  border-radius: var(--r-sm); cursor: pointer; text-decoration: none;
  min-height: var(--tap); transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn.ghost { background: var(--panel); color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--line-2); color: var(--ink); }
.btn.go   { background: var(--ok); border-color: var(--ok); }
.btn.stop { background: var(--panel); color: var(--danger);
            border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.stop:hover { background: var(--danger-bg); }
.btn.sm { padding: 6px var(--sp-3); font-size: 13px; min-height: 36px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }

.alert {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm); font-size: 14px;
  margin-bottom: var(--sp-4); border: 1px solid; display: flex; gap: var(--sp-2);
}
.alert.ok   { background: var(--ok-bg);     border-color: color-mix(in srgb, var(--ok) 30%, transparent);     color: var(--ok); }
.alert.err  { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.alert.warn { background: var(--warn-bg);   border-color: color-mix(in srgb, var(--warn) 30%, transparent);   color: var(--warn); }

/* ---------- the count tag: signature component ----------------------- */
.tag {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); margin-bottom: var(--sp-3); overflow: hidden;
  box-shadow: var(--shadow-1);
}
.tag .plate {
  background: var(--raised); border-bottom: 1px solid var(--line-2);
  padding: var(--sp-3) var(--sp-4);
  display: flex; gap: var(--sp-2); align-items: baseline; flex-wrap: wrap;
}
.tag .plate .c { font-family: var(--mono); font-weight: 600; font-size: 15px; color: var(--brand); }
.tag .plate .n { color: var(--ink-2); font-size: 13.5px; flex: 1; min-width: 180px; }
.tag .body { padding: var(--sp-4); }

/* quantities side by side so the eye compares without moving */
.strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; margin-bottom: var(--sp-4);
}
.strip .cell { padding: var(--sp-3); border-inline-end: 1px solid var(--line-2); }
.strip .cell:last-child { border-inline-end: none; }
.strip .cell .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.strip .cell .v { font-family: var(--mono); font-size: 19px; font-weight: 600; margin-top: 2px; }
.strip .cell.focus { background: var(--brand-100); }

/* ---------- progress + inline bar charts ----------------------------- */
.bar { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px;
           transition: width .3s ease; }

.hbars { display: flex; flex-direction: column; gap: var(--sp-2); }
.hbar { display: grid; grid-template-columns: minmax(78px, 120px) 1fr auto; gap: var(--sp-3);
        align-items: center; font-size: 13px; }
.hbar .lab { color: var(--ink-2); font-weight: 500; overflow: hidden;
             text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 20px; background: var(--line-2); border-radius: var(--r-sm); overflow: hidden; }
.hbar .track > i { display: block; height: 100%; background: var(--brand); border-radius: var(--r-sm); }
.hbar .track > i.v2 { background: var(--violet); }
.hbar .track > i.v3 { background: var(--ok); }
.hbar .track > i.v4 { background: var(--danger); }
.hbar .val { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }

/* two-tone rail: Excel against Odoo on one line */
.cmp { height: 22px; display: flex; border-radius: var(--r-sm); overflow: hidden;
       background: var(--line-2); }
.cmp > i { display: block; height: 100%; }
.cmp > i.a { background: var(--brand); }
.cmp > i.b { background: var(--violet); }
.legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: 12.5px;
          color: var(--muted); margin-top: var(--sp-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---------- search results ------------------------------------------ */
.results { border: 1px solid var(--line); border-radius: var(--r-sm);
           max-height: 340px; overflow-y: auto; background: var(--panel); }
.results button {
  display: block; width: 100%; text-align: start; background: none; border: 0;
  border-bottom: 1px solid var(--line-2); padding: var(--sp-3);
  cursor: pointer; font: inherit; font-size: 14px; color: var(--ink);
  min-height: var(--tap);
}
.results button:hover, .results button:focus { background: var(--brand-100); outline: none; }
.results button .c { font-family: var(--mono); font-weight: 600; color: var(--brand); }
.results button .n { color: var(--ink-2); display: block; font-size: 12.5px; }
.results button .q { color: var(--muted); font-size: 11.5px; }

/* ---------- login ---------------------------------------------------- */
.login-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6); background: var(--page);
}
.login-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); width: 100%; max-width: 380px;
  padding: var(--sp-8) var(--sp-6); box-shadow: var(--shadow-2);
}
.login-card .logo { width: 52px; height: 52px; border-radius: 13px; margin-bottom: var(--sp-4); }
.login-card h1 { font-size: 20px; }

/* ---------- misc ----------------------------------------------------- */
.toolbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line);
        overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs a {
  padding: var(--sp-3) var(--sp-4); text-decoration: none; color: var(--muted);
  font-size: 13.5px; font-weight: 600; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; min-height: var(--tap);
  display: inline-flex; align-items: center; gap: 6px;
}
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a:hover { color: var(--ink); }
.tabs .n { font-weight: 400; color: var(--muted); font-size: 12px;
           background: var(--line-2); border-radius: 999px; padding: 1px 7px; }

.pager { display: flex; gap: var(--sp-2); align-items: center;
         padding: var(--sp-3) var(--sp-4); font-size: 13px; color: var(--muted);
         border-top: 1px solid var(--line-2); }
.pager .spacer { flex: 1; }

.note-item { border-inline-start: 2px solid var(--line); padding: var(--sp-1) var(--sp-3);
             margin-top: var(--sp-2); font-size: 13px; background: var(--raised);
             border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.note-item .meta { color: var(--muted); font-size: 11.5px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2) var(--sp-4); font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); }

.offline-bar {
  background: var(--warn-bg); color: var(--warn); text-align: center;
  font-size: 13px; font-weight: 600; padding: var(--sp-2);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}

/* ---------- motion & print ------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .topbar, .botnav, .toolbar, .btn, .pager { display: none !important; }
  body { background: #fff; padding-bottom: 0; }
  .panel { box-shadow: none; border-color: #999; break-inside: avoid; }
}
