/* ══════════════════════════════════════════════════════════════════
   MAGADH WELLNESS GAYA — ORDER DESK
   ------------------------------------------------------------------
   Palette is drawn from histology stains, the actual materials of a
   diagnostics business: methylene blue, malachite green, crystal
   violet, eosin, safranin.

   The organising idea: this business runs in two directions, and the
   word "purchase order" points both ways. So direction is colour-coded
   throughout — BUYING from suppliers reads methyl blue, SELLING to
   clients reads crystal violet. Colour is wayfinding here, not decor.
   ══════════════════════════════════════════════════════════════════ */

/* ---------- Typefaces (self-hosted, works offline) ---------- */
@font-face {
  font-family: 'Plex Sans'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Plex Sans'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Plex Sans'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Plex Cond'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/ibm-plex-sans-condensed-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}

:root {
  /* Stains */
  --ink:        #171A2E;   /* methylene blue, concentrated */
  --ink-2:      #232742;
  --ink-soft:   #5A6478;
  --ink-faint:  #8B95A6;

  --paper:      #F3F5F4;
  --panel:      #FFFFFF;
  --line:       #E1E7E6;
  --line-soft:  #EDF1F0;

  --malachite:  #0B7A63;   /* primary action, "good" */
  --malachite-2:#0E9478;
  --malachite-soft:#E3F2ED;

  --methyl:     #24567F;   /* BUYING direction */
  --methyl-soft:#E6EDF4;

  --crystal:    #5D4A94;   /* SELLING direction */
  --crystal-soft:#EEEAF6;

  --eosin:      #B23A4E;   /* danger */
  --eosin-soft: #FAE7EA;

  --safranin:   #B8701C;   /* warning / pending */
  --safranin-soft:#FBEEDC;

  /* Legacy aliases — older markup still references these */
  --steel: var(--methyl);
  --steel-deep: var(--ink);
  --teal: var(--malachite);
  --amber: var(--safranin);
  --amber-soft: var(--safranin-soft);
  --danger: var(--eosin);
  --danger-soft: var(--eosin-soft);
  --ok: var(--malachite);
  --ok-soft: var(--malachite-soft);

  --radius:    7px;
  --radius-lg: 11px;
  --mono: 'Plex Mono', 'SFMono-Regular', Consolas, monospace;
  --cond: 'Plex Cond', 'Plex Sans', system-ui, sans-serif;

  --sh-1: 0 1px 2px rgba(23,26,46,.05);
  --sh-2: 0 2px 10px rgba(23,26,46,.07), 0 1px 3px rgba(23,26,46,.04);
  --sh-3: 0 16px 44px rgba(23,26,46,.17);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.no-scroll { overflow: hidden; }

/* ---------- Type scale ---------- */
h1 {
  font-size: 24px; font-weight: 600; letter-spacing: -.022em;
  margin: 0 0 4px; color: var(--ink); line-height: 1.15;
}
h2 {
  font-family: var(--cond);
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .11em; color: var(--ink-soft); margin: 0 0 14px;
}
h3 { font-size: 13px; font-weight: 600; margin: 0 0 4px; color: var(--ink); }

.eyebrow {
  font-family: var(--cond);
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .13em; color: var(--malachite); margin: 0 0 3px;
}
.page-sub { color: var(--ink-soft); font-size: 13px; margin: 0; max-width: 70ch; }
.muted { color: var(--ink-soft); }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.01em; }

a { color: var(--methyl); text-decoration: none; }
a:hover { color: var(--malachite); text-decoration: underline; }

/* ---------- Shell ---------- */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.loading-shell {
  display: flex; align-items: center; justify-content: center;
  min-height: 160px; color: var(--ink-faint);
  font-family: var(--cond); text-transform: uppercase;
  letter-spacing: .14em; font-size: 11px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; height: 58px; flex-shrink: 0;
  background: var(--ink); color: #E8ECF2;
  position: relative;
}
/* Stain strip: the palette itself, stated once at the top of the app */
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg,
    var(--methyl) 0 28%, var(--crystal) 28% 52%,
    var(--malachite) 52% 76%, var(--safranin) 76% 90%, var(--eosin) 90% 100%);
}

.topbar .brand {
  display: flex; align-items: center; gap: 11px;
  font-size: 14px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap;
}
.brand-name { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name b { font-weight: 600; font-size: 13.5px; color: #fff; letter-spacing: -.01em; }
.brand-name span {
  font-family: var(--cond); font-size: 9.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .15em; color: #93A0B5;
}
.brand .mark {
  width: 27px; height: 27px; border-radius: 7px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--malachite-2), var(--methyl) 60%, var(--crystal));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28);
  position: relative;
}
/* a small assay dot, like a reagent cap */
.brand .mark::after {
  content: ''; position: absolute; inset: 9px; border-radius: 50%;
  background: rgba(255,255,255,.9);
}

.topbar nav { display: flex; gap: 2px; align-items: center; }
.topbar nav > a {
  color: #B9C4D4; font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: var(--radius);
  transition: background .12s, color .12s;
}
.topbar nav > a:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.topbar nav > a.active { background: rgba(255,255,255,.14); color: #fff; }

.user-box { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #A9B5C6; }
.user-box button {
  background: transparent; border: 1px solid rgba(255,255,255,.22);
  color: #E8ECF2; padding: 5px 11px; border-radius: var(--radius);
  font-size: 12px; cursor: pointer; box-shadow: none;
}
.user-box button:hover { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.34); color: #fff; }

.div-chip {
  margin-left: 4px; padding: 3px 10px; border-radius: 20px;
  font-family: var(--cond); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  background: rgba(255,255,255,.13); color: #CBD5E3;
}
.div-chip:hover { background: rgba(255,255,255,.22); color: #fff; text-decoration: none; }

/* Company / item line breadcrumb. Two independent targets in one pill: the
   left half goes back to the company picker, the right half to the line
   picker, so neither choice needs unwinding through the other. */
.ctx-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 4px; padding: 3px 10px; border-radius: 20px;
  font-family: var(--cond); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  background: rgba(255,255,255,.13);
}
.ctx-chip a { color: #CBD5E3; }
.ctx-chip a:hover { color: #fff; text-decoration: none; }
.ctx-sep { color: rgba(255,255,255,.32); }

.header-actions { display: flex; gap: 8px; align-items: center; }

/* Operations-history filter bar: collapses from six columns down to two on
   a narrow screen rather than squeezing the date inputs to nothing. */
.audit-filters {
  display: grid; gap: 10px;
  grid-template-columns: minmax(200px, 2fr) minmax(160px, 1.4fr) minmax(140px, 1fr) 150px 150px 90px;
  align-items: end;
}
.audit-filters .field { margin-bottom: 0; }
@media (max-width: 1100px) {
  .audit-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

main { flex: 1; padding: 26px 24px 64px; max-width: 1480px; width: 100%; margin: 0 auto; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 20px; flex-wrap: wrap;
  margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}

/* ---------- Direction-coded nav groups (the signature) ---------- */
.nav-group { position: relative; }
.nav-btn {
  background: transparent; border: none; box-shadow: none;
  color: #B9C4D4; font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: var(--radius);
  display: inline-flex; align-items: center; gap: 6px;
}
.nav-btn:hover { background: rgba(255,255,255,.09); color: #fff; border-color: transparent; }
.nav-group.active > .nav-btn { background: rgba(255,255,255,.14); color: #fff; }
.nav-group .caret { font-size: 8px; opacity: .6; }

.nav-menu {
  display: none; position: absolute; left: 0; top: calc(100% + 6px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); min-width: 268px; z-index: 300;
  box-shadow: var(--sh-3); overflow: hidden; padding: 5px;
}
.nav-group.open .nav-menu { display: block; }
.nav-hint {
  font-family: var(--cond); font-size: 10px; text-transform: uppercase;
  letter-spacing: .13em; color: var(--ink-faint); font-weight: 600;
  padding: 9px 11px 5px;
}
.nav-menu a {
  display: block; padding: 8px 11px; border-radius: 6px;
  color: var(--ink); border-left: 2px solid transparent;
}
.nav-menu a b, .nav-menu a strong { display: block; font-size: 13px; font-weight: 500; }
.nav-menu a span { display: block; font-size: 11.5px; color: var(--ink-soft); margin-top: 1px; }
.nav-menu a:hover { background: var(--paper); text-decoration: none; }
.nav-menu a.sel { background: var(--methyl-soft); border-left-color: var(--methyl); }

.cart-badge {
  background: var(--safranin); color: #fff; border-radius: 20px;
  padding: 1px 7px; font-size: 11px; font-weight: 600; margin-left: 5px;
  font-family: var(--mono);
}

/* ---------- Panels ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--sh-1);
}
.panel-tight { padding: 13px 16px; }
.panel-alert { border-left: 3px solid var(--safranin); }

.grid { display: grid; gap: 15px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1080px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ---------- Stat tiles & KPIs ---------- */
.stat-tile, .kpi {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 16px 18px;
  box-shadow: var(--sh-1); position: relative; overflow: hidden;
}
.stat-tile::before, .kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--line);
}
.stat-tile .num, .kpi-value {
  font-family: var(--mono); font-size: 25px; font-weight: 500;
  color: var(--ink); letter-spacing: -.028em; line-height: 1.12;
}
.stat-tile .label, .kpi-sub {
  font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; line-height: 1.35;
}
.kpi-label {
  font-family: var(--cond); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-soft); font-weight: 600; margin-bottom: 7px;
}

.accent-teal::before,  .kpi-teal::before      { background: var(--malachite); }
.accent-ok::before,    .kpi-ok::before        { background: var(--malachite); }
.accent-amber::before, .kpi-amber::before     { background: var(--safranin); }
.accent-danger::before,.kpi-danger::before    { background: var(--eosin); }
.kpi-steel::before                            { background: var(--methyl); }
.kpi-muted::before                            { background: #D3DAD9; }

a.linkcard { display: block; color: inherit; transition: transform .12s, box-shadow .12s; }
a.linkcard:hover { transform: translateY(-2px); box-shadow: var(--sh-2); text-decoration: none; }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  font-family: var(--cond); text-align: left;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-soft); font-weight: 600; padding: 9px 11px;
  background: #FAFBFB; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
td { padding: 9px 11px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tr:hover td { background: #F7FAF9; }
.num-cell { font-family: var(--mono); text-align: right; font-size: 12.5px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--methyl-soft); }

/* ---------- Buttons ---------- */
button, .btn {
  font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); padding: 8px 14px;
  transition: all .13s ease; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: var(--sh-1);
}
button:hover, .btn:hover {
  border-color: var(--ink-faint); color: var(--ink); text-decoration: none;
  box-shadow: var(--sh-2);
}
button:active, .btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--malachite); border-color: var(--malachite); color: #fff;
  box-shadow: 0 1px 3px rgba(11,122,99,.32);
}
.btn-primary:hover { background: #096B57; border-color: #096B57; color: #fff; }
.btn-amber { background: var(--safranin); border-color: var(--safranin); color: #fff; }
.btn-amber:hover { background: #9E5F14; border-color: #9E5F14; color: #fff; }
.btn-danger { background: var(--eosin); border-color: var(--eosin); color: #fff; }
.btn-danger:hover { background: #963042; border-color: #963042; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper); box-shadow: none; color: var(--ink); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- Forms ---------- */
label {
  display: block; font-family: var(--cond);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-soft); margin-bottom: 5px;
}
input, select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line);
  border-radius: var(--radius); font-family: inherit; font-size: 13px;
  background: #fff; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--malachite);
  box-shadow: 0 0 0 3px rgba(11,122,99,.14);
}
input::placeholder { color: #A9B3B2; }
input[type=number] { font-family: var(--mono); }
.field { margin-bottom: 13px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.tier-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 700px) { .tier-grid { grid-template-columns: repeat(2, 1fr); } }
.hr-label {
  font-family: var(--cond); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--malachite); font-weight: 600;
  margin: 18px 0 11px; padding-top: 13px; border-top: 1px solid var(--line);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-family: var(--cond);
  font-size: 10.5px; font-weight: 600; padding: 3px 9px;
  border-radius: 4px; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-pending   { background: var(--safranin-soft);  color: #8A5312; border-color: #F0DCBB; }
.badge-added,
.badge-received  { background: var(--malachite-soft); color: #076251; border-color: #BFE3D8; }
.badge-placed    { background: var(--methyl-soft);    color: var(--methyl); border-color: #C7D8E7; }
.badge-cancelled { background: var(--eosin-soft);     color: var(--eosin); border-color: #EFC9D0; }

/* ---------- Pills & segmented controls ---------- */
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  padding: 5px 13px; border-radius: 20px; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--line); cursor: pointer; background: #fff; color: var(--ink-soft);
  transition: all .12s;
}
.pill:hover { border-color: var(--ink-faint); color: var(--ink); }
.pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.seg {
  display: inline-flex; background: #E6EBEA; border-radius: 9px;
  padding: 3px; gap: 2px; margin-bottom: 16px;
}
.seg-sm { margin: 6px 0 12px; }
.seg-btn {
  border: none; background: transparent; box-shadow: none;
  padding: 6px 14px; border-radius: 6px; font-size: 12.5px;
  font-weight: 500; color: var(--ink-soft);
}
.seg-btn:hover { background: rgba(255,255,255,.65); color: var(--ink); box-shadow: none; }
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: var(--sh-1); font-weight: 600; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  border: none; background: transparent; box-shadow: none; border-radius: 0;
  padding: 10px 16px; font-size: 13px; font-weight: 500; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); border-color: transparent; box-shadow: none; background: var(--paper); }
.tab.active { color: var(--ink); border-bottom-color: var(--malachite); font-weight: 600; background: transparent; }

/* ---------- Notices ---------- */
.notice {
  background: var(--safranin-soft); border: 1px solid #F0DCBB;
  border-left: 3px solid var(--safranin);
  border-radius: var(--radius); padding: 12px 15px;
  font-size: 12.5px; color: #7A4C10; margin-bottom: 16px;
}
.all-clear {
  padding: 22px; text-align: center; color: #076251; font-size: 13px;
  background: var(--malachite-soft); border-radius: var(--radius); margin: 12px 0 0;
}
.empty-state { text-align: center; padding: 44px 20px; color: var(--ink-faint); font-size: 13px; }
.login-err { color: var(--eosin); font-size: 12.5px; margin: 10px 0 0; min-height: 16px; }

/* ---------- Charts (Insights) ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 1080px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-row { grid-template-columns: 1fr; } }

.chart-wrap { width: 100%; overflow-x: auto; margin-top: 14px; }
.chart { width: 100%; min-width: 560px; height: auto; display: block; }
.chart .gl { stroke: var(--line-soft); stroke-width: 1; }
.chart .ax { font-family: var(--mono); font-size: 10px; fill: var(--ink-faint); }
.chart .b-buy  { fill: var(--methyl); }     /* buying  = methyl blue    */
.chart .b-sell { fill: var(--crystal); }    /* selling = crystal violet */
.chart rect { transition: opacity .12s; }
.chart rect:hover { opacity: .78; }

.legend { display: flex; gap: 15px; font-size: 11.5px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw-buy { background: var(--methyl); }
.sw-sell { background: var(--crystal); }

.hbars { display: flex; flex-direction: column; gap: 14px; margin-top: 13px; }
.hbar-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; gap: 10px; }
.hbar-meta { color: var(--ink-soft); font-size: 11px; font-family: var(--mono); white-space: nowrap; }
.hbar-track {
  position: relative; height: 23px; background: #EEF2F1;
  border-radius: 4px; margin-top: 5px; overflow: hidden;
}
.hbar-fill { height: 100%; border-radius: 4px; transition: width .4s cubic-bezier(.4,0,.2,1); }
.hbar-teal  { background: linear-gradient(90deg, var(--malachite), var(--malachite-2)); }
.hbar-steel { background: linear-gradient(90deg, var(--methyl), #3670A3); }
.hbar-val {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 11px; color: var(--ink); font-weight: 500;
}
.hbar-sub {
  font-size: 11px; color: var(--ink-soft); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Item-line tiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px; }
.tile {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--sh-1);
  transition: transform .13s, box-shadow .13s;
}
.tile::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--malachite); }
.tile:hover { transform: translateY(-3px); box-shadow: var(--sh-2); }
.tile-body { padding: 22px 20px 20px; cursor: pointer; }
.tile-body h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; letter-spacing: -.015em; }
.tile-body p { margin: 0 0 15px; font-size: 12.5px; color: var(--ink-soft); min-height: 34px; }
.tile-meta { font-family: var(--mono); font-size: 12px; color: var(--malachite); font-weight: 500; }
.tile-edit {
  position: absolute; top: 12px; right: 12px; padding: 3px 9px; font-size: 11px;
  background: var(--paper); border: 1px solid var(--line); box-shadow: none;
}
.tile-teal::before   { background: var(--malachite); }
.tile-amber::before  { background: var(--safranin); }
.tile-coral::before  { background: var(--eosin); }
.tile-purple::before { background: var(--crystal); }
.tile-blue::before   { background: var(--methyl); }

/* ---------- Sales order / invoice chain ---------- */
.so-block {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  margin-bottom: 12px; overflow: hidden;
}
.so-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 15px; background: var(--methyl-soft);
  border-bottom: 1px solid var(--line);
}
.inv-row {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 14px;
  padding: 12px 15px; border-bottom: 1px solid var(--line-soft); align-items: center;
}
.inv-row:last-child { border-bottom: none; }
.inv-main { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inv-items { grid-column: 1 / 2; font-size: 11.5px; color: var(--ink-soft); font-family: var(--mono); }
.inv-actions { grid-row: 1 / 3; grid-column: 2 / 3; display: flex; gap: 6px; align-items: center; }

/* ---------- Workflow steps ---------- */
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.step {
  display: flex; align-items: center; gap: 8px; padding: 8px 15px;
  border-radius: 24px; background: var(--panel); border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-soft);
}
.step .dot {
  width: 19px; height: 19px; border-radius: 50%; background: #D3DAD9; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; font-family: var(--mono);
}
.step.done { border-color: #BFE3D8; background: var(--malachite-soft); color: #076251; }
.step.done .dot { background: var(--malachite); }
.step.now { border-color: var(--crystal); background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--sh-1); }
.step.now .dot { background: var(--crystal); }

/* ---------- Product detail ---------- */
.pd-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .pd-grid { grid-template-columns: 1fr; } }
.pd-img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--line); display: block; background: #fff;
}
.pd-img-empty {
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); color: var(--ink-faint); font-size: 13px;
}
.pd-nav { display: flex; gap: 8px; align-items: center; }

/* ---------- Thumbnails & lightbox ---------- */
.thumb {
  width: 42px; height: 42px; object-fit: cover; border-radius: 5px;
  border: 1px solid var(--line); display: block; background: #fff;
}
.thumb-lg { width: 58px; height: 58px; border-radius: 6px; }
.thumb-empty {
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); color: #BCC6C5; font-size: 11px;
}
img.zoom-ready { cursor: zoom-in; transition: transform .13s, box-shadow .13s, border-color .13s; }
img.zoom-ready:hover { transform: scale(1.07); box-shadow: var(--sh-2); border-color: var(--malachite); }

.lightbox {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(14,17,30,.92); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: lbIn .15s ease-out;
}
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }
.lb-figure { margin: 0; max-width: 88vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.lb-figure img {
  max-width: 88vw; max-height: 78vh; object-fit: contain;
  border-radius: 9px; box-shadow: 0 24px 64px rgba(0,0,0,.55); background: #fff;
}
.lb-figure figcaption { color: #D6DEE9; font-size: 13px; text-align: center; display: flex; gap: 12px; align-items: center; }
.lb-count { font-family: var(--mono); font-size: 11px; color: #8794A8; }
.lb-close, .lb-nav {
  position: absolute; border: none; background: rgba(255,255,255,.13);
  color: #fff; cursor: pointer; box-shadow: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.lb-close { top: 18px; right: 22px; width: 40px; height: 40px; font-size: 25px; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 46px; height: 46px; font-size: 28px; }
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.26); color: #fff; }
.lb-prev { left: 20px; }
.lb-next { right: 20px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(23,26,46,.5);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 500; padding: 44px 20px; overflow-y: auto;
  animation: lbIn .13s ease-out;
}
.modal {
  background: #fff; border-radius: var(--radius-lg); padding: 26px;
  width: 100%; max-width: 660px; box-shadow: var(--sh-3);
}
.modal h2 { margin-bottom: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 18% 8%, rgba(93,74,148,.30), transparent 60%),
    radial-gradient(800px 500px at 84% 92%, rgba(11,122,99,.28), transparent 62%),
    linear-gradient(160deg, var(--ink) 0%, #101326 100%);
}
.login-card {
  background: #fff; border-radius: 14px; padding: 40px 38px;
  width: 100%; max-width: 396px; text-align: center;
  box-shadow: 0 26px 70px rgba(0,0,0,.4);
}
.login-card .mark {
  width: 50px; height: 50px; border-radius: 13px; margin: 0 auto 18px;
  background: linear-gradient(145deg, var(--malachite-2), var(--methyl) 60%, var(--crystal));
  position: relative; box-shadow: inset 0 1px 0 rgba(255,255,255,.3);
}
.login-card .mark::after {
  content: ''; position: absolute; inset: 17px; border-radius: 50%; background: #fff;
}
.login-card h1 { font-size: 19px; margin-bottom: 3px; }
.login-card .login-org {
  font-family: var(--cond); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .17em; color: var(--ink-faint); margin: 0 0 22px;
}
.login-card p { color: var(--ink-soft); font-size: 13px; margin-bottom: 22px; }
.login-card .field { text-align: left; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px; border-radius: var(--radius);
  border: 1px solid var(--line); background: #fff;
  font-weight: 500; font-size: 13.5px; cursor: pointer; color: var(--ink);
}
.google-btn:hover { background: var(--paper); text-decoration: none; border-color: var(--ink-faint); }
.login-note { margin-top: 16px; font-size: 11px; color: var(--ink-faint); line-height: 1.5; }
.or-divider {
  display: flex; align-items: center; gap: 11px; margin: 20px 0 15px;
  color: var(--ink-faint); font-family: var(--cond); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .13em;
}
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- Order builder ---------- */
.order-item-row {
  display: grid; grid-template-columns: 2fr 1fr 90px 110px 110px 40px;
  gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-soft);
}
.order-item-row .desc { font-size: 13px; }
.order-item-row .desc .code { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }
.order-totals { display: flex; justify-content: flex-end; gap: 24px; padding: 15px 0; font-size: 14px; }
.order-totals strong { font-family: var(--mono); font-size: 17px; letter-spacing: -.02em; }

/* ---------- Photo picker & QR ---------- */
.photo-preview { max-width: 220px; border-radius: var(--radius); border: 1px solid var(--line); display: block; margin-bottom: 10px; }
.photo-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
@media (max-width: 640px) { .photo-choices { grid-template-columns: 1fr; } }
.photo-choice { border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; }
.photo-choice h3 { font-size: 13px; margin-bottom: 5px; }
.qr-img { width: 190px; height: 190px; display: block; margin: 12px 0 8px; border-radius: 6px; }
.qr-waiting { font-size: 12px; color: var(--safranin); font-weight: 600; margin: 6px 0 0; }
.qr-waiting::after { content: ''; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- Dropdown (exports) ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 5px);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
  min-width: 216px; z-index: 200; box-shadow: var(--sh-3); overflow: hidden; padding: 4px;
}
.dropdown-menu.open { display: block; }
.dropdown-menu a { display: block; padding: 8px 12px; font-size: 13px; color: var(--ink); border-radius: 5px; }
.dropdown-menu a:hover { background: var(--paper); text-decoration: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; right: 22px; background: var(--ink); color: #fff;
  padding: 11px 17px; border-radius: var(--radius); font-size: 13px; z-index: 999;
  box-shadow: var(--sh-3); animation: fadein .16s ease-out;
  border-left: 3px solid var(--malachite);
}
.toast.error { border-left-color: var(--eosin); }
@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Values ---------- */
.pos { color: var(--malachite); font-weight: 600; }
.neg { color: var(--eosin); font-weight: 600; }

/* ---------- Print ---------- */
.print-order { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-order, .print-order * { visibility: visible; }
  .print-order { display: block; position: absolute; top: 0; left: 0; width: 100%; padding: 20px; }
}
.print-header { display: flex; justify-content: space-between; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 16px; }
.print-warning {
  margin-top: 24px; padding: 12px; border: 2px solid var(--eosin);
  background: var(--eosin-soft); font-weight: 600; text-align: center; color: var(--eosin);
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD4D3; border-radius: 7px; border: 3px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: #B0BCBA; }

/* ---------- Accessibility floor ---------- */
:focus-visible { outline: 2px solid var(--malachite); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
