/* EMP Gebang ATK: design tokens and components (no framework).
   On Vercel this file is served by api/index.php; on XAMPP Apache serves it directly. */

:root {
  --canvas: #f4f3ef;
  --surface: #ffffff;
  --sunken: #f9f8f5;
  --hover: #ebe9e3;
  --ink: #1b1d1f;
  --ink-2: #4f545a;
  --ink-3: #6c7177;
  --line: #e2e0d9;
  --line-2: #edebe6;
  --field: #d3d0c8;
  --accent: #0d5b62;
  --accent-strong: #0a474d;
  --accent-tint: #e2edec;
  --ok: #1d6a3a;
  --ok-tint: #e1efe5;
  --warn: #875600;
  --warn-tint: #f8edd5;
  --bad: #a3302b;
  --bad-tint: #f7e1de;
  --info: #3a4b60;
  --info-tint: #e5e9ee;
  --radius: 6px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 14px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); font-weight: 400; }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.text-ok { color: var(--ok); }
.stack > * + * { margin-top: 14px; }

/* App shell: sidebar on desktop, top bar with scrollable nav on mobile. */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
/* Sidebar: a deep petrol block, the one large colour surface in the app. */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 22px;
  padding: 20px 14px; background: #0e3a40; color: #d3e2e1;
}
.sidebar :focus-visible { outline-color: #8fd9cf; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px;
  border-radius: var(--radius); background: #f4f3ef; color: #0e3a40;
  font: 600 11px/1 var(--mono); letter-spacing: 0.04em;
}
.brand-name { display: block; font-weight: 600; line-height: 1.25; }
.brand-sub { display: block; color: #9dbcba; font-size: 12px; line-height: 1.25; }
.auth .brand { color: var(--ink); }
.auth .brand-mark { background: #0e3a40; color: #fff; }
.auth .brand-sub { color: var(--ink-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius); color: #c3d6d5; font-weight: 500;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.nav-link[aria-current="page"] { background: rgba(255, 255, 255, 0.12); color: #fff; box-shadow: inset 3px 0 0 #8fd9cf; }
.nav-count {
  min-width: 22px; padding: 0 7px; border-radius: 999px; background: #f6c453; color: #3a2a00;
  font-size: 12px; font-weight: 600; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums;
}
.sidebar-user { margin-top: auto; padding: 14px 6px 0; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.user-name { font-weight: 600; line-height: 1.3; color: #fff; }
.user-role { color: #9dbcba; font-size: 12.5px; }
.user-actions { display: flex; gap: 14px; margin-top: 10px; font-size: 13px; }
.user-actions a { color: #d3e2e1; }

.content { min-width: 0; padding: 28px 36px 56px; } /* fluid: uses the full width next to the sidebar */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; line-height: 1.25; }
.page-head p { margin-top: 4px; color: var(--ink-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel, .panel + .grid-2, .grid-2 + .panel, .stats + .panel, .stats + .grid-2 { margin-top: 16px; }
.grid-2 > .panel { margin-top: 0; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 13px 18px; border-bottom: 1px solid var(--line-2);
}
.panel-head h2 { font-size: 15px; }
.panel-head .count { color: var(--ink-3); font-weight: 400; margin-left: 6px; }
.panel-body { padding: 18px; }
.panel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--line-2); background: var(--sunken);
  border-radius: 0 0 var(--radius) var(--radius);
}
details.panel > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 18px; cursor: pointer; list-style: none; font-weight: 600;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "+"; font: 500 18px/1 var(--mono); color: var(--ink-3); }
details.panel[open] > summary { border-bottom: 1px solid var(--line-2); }
details.panel[open] > summary::after { content: "\2212"; }
.panel-sub { border-top: 1px solid var(--line-2); }
.list-row { padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.list-row:last-child { border-bottom: 0; }
.list-row-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.list-row .text-warn { margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-wide { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }

/* Stat strip: one bordered row, not floating cards */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.stat { padding: 16px 18px; color: var(--ink); }
.stat + .stat { border-left: 1px solid var(--line-2); }
a.stat:hover { background: var(--sunken); text-decoration: none; }
.stat-label { color: var(--ink-2); font-size: 13px; }
.stat-value { margin-top: 4px; font-size: 28px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-note { margin-top: 2px; color: var(--ink-3); font-size: 12.5px; }
.stat.is-warn .stat-value { color: var(--warn); }
.stat.is-bad .stat-value { color: var(--bad); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 9px 14px; text-align: left; white-space: nowrap;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: var(--sunken); border-bottom: 1px solid var(--line);
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfaf8; }
.table th.num { text-align: right; }
.table .col-tight { width: 1%; }
.table tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.table tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.cell-title { font-weight: 500; }
.cell-sub { display: block; color: var(--ink-3); font-size: 12.5px; }
.show-sm { display: none; }
/* Fixed-width unit after a number, so numbers and inputs line up down a column. */
.unit { display: inline-block; min-width: 3.2em; margin-left: 4px; text-align: left; color: var(--ink-3); font-size: 12.5px; font-weight: 400; }
.qty-in { color: var(--ok); font-weight: 600; }
.qty-out { color: var(--ink); font-weight: 600; }

/* Status pills: a dot plus a word, colour only reinforces the word */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px;
  background: var(--info-tint); color: var(--info); font-size: 12.5px; font-weight: 500; line-height: 20px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-pending, .pill-low { background: var(--warn-tint); color: var(--warn); }
.pill-approved, .pill-ok { background: var(--ok-tint); color: var(--ok); }
.pill-rejected, .pill-empty { background: var(--bad-tint); color: var(--bad); }
.pill-issued { background: #ecebe7; color: #52514e; }
.pill-in { background: #e6f0fb; color: #1c5cab; }
.pill-out { background: #fde9df; color: #a4421a; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border: 1px solid var(--field); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: 500 14px/1 var(--sans); white-space: nowrap; cursor: pointer;
}
.btn:hover { background: var(--sunken); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { color: var(--bad); border-color: #e3bdb8; }
.btn-danger:hover { background: var(--bad-tint); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 500; }
.label .opt { color: var(--ink-3); font-weight: 400; }
.hint { color: var(--ink-3); font-size: 12.5px; }
.input, .select {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--field); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: 14px var(--sans);
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.input::placeholder { color: #9a9ea3; }
.input.mono { font-family: var(--mono); font-size: 13px; }
.input-qty { width: 88px; text-align: right; font-variant-numeric: tabular-nums; }
.input-search { max-width: 260px; height: 32px; }
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.col-1 { grid-column: span 1; } .col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-6 { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.form-grid + datalist + datalist + .form-actions { margin-top: 18px; }
.filter-bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.filter-bar .field { width: 180px; }
.hint-list { margin: 0; padding-left: 18px; color: var(--ink-3); font-size: 12.5px; }
.narrow { max-width: 520px; }
.approve-note { flex: 1 1 260px; width: auto; }
.panel-foot .form-actions { margin-left: auto; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.segmented { display: inline-flex; border: 1px solid var(--field); border-radius: var(--radius); overflow: hidden; }
.segmented label { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 34px; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.segmented label + label { border-left: 1px solid var(--field); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent-tint); color: var(--accent-strong); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Messages */
.alert {
  padding: 11px 14px; margin-bottom: 16px; border: 1px solid var(--line); border-left: 3px solid var(--info);
  border-radius: var(--radius); background: var(--surface);
}
.alert-success { border-left-color: var(--ok); }
.alert-danger { border-left-color: var(--bad); }
.alert-warning { border-left-color: var(--warn); background: #fffbf3; }
.empty { padding: 32px 18px; text-align: center; color: var(--ink-2); }
.empty-lg { padding: 56px 24px; }
.empty strong { display: block; margin-bottom: 4px; color: var(--ink); }

/* Status filter tabs */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab { padding: 5px 10px; border-radius: var(--radius); color: var(--ink-2); font-weight: 500; font-size: 13px; }
.tab:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.tab[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

/* Request cards (approval, issue) */
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 24px; }
.meta dt { color: var(--ink-3); font-size: 12.5px; }
.meta dd { margin: 2px 0 0; }
.req-no { font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.lines { margin: 0; padding: 0; list-style: none; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.lines li:last-child { border-bottom: 0; }

/* Sign-in */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-aside { display: flex; flex-direction: column; justify-content: space-between; gap: 32px; padding: 40px 48px; border-right: 1px solid var(--line); }
.auth-title { margin-top: 48px; font-size: 26px; line-height: 1.25; max-width: 30ch; }
.auth-lead { margin-top: 10px; color: var(--ink-2); max-width: 46ch; }
.steps { list-style: none; counter-reset: step; display: grid; gap: 18px; margin: 32px 0 0; padding: 0; max-width: 46ch; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.steps li::before {
  content: counter(step); display: grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font: 600 13px var(--mono);
}
.steps strong { display: block; }
.steps span { color: var(--ink-2); }
.auth-foot { color: var(--ink-3); font-size: 13px; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h2 { font-size: 20px; }
.auth-sub { margin: 4px 0 20px; }

/* Error pages */
.error-box { max-width: 520px; margin: 12vh auto 0; padding: 0 16px; }
.error-code { color: var(--ink-3); }
.error-box h1 { margin-top: 6px; font-size: 22px; }
.error-box p { margin: 8px 0 20px; color: var(--ink-2); }

/* Dashboard tiles: label, value, delta, and a coloured chip that says what the number is about. */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel + .tiles { margin-top: 16px; }
.panel-head .legend { margin: 0; }
.tiles + .panel, .tiles + .grid-2, .tiles + .grid-main, .grid-main + .grid-2, .grid-2 + .grid-2, .grid-main + .panel { margin-top: 16px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
a.tile:hover { border-color: #c9c6bd; text-decoration: none; }
.tile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tile-label { color: var(--ink-2); font-size: 13px; font-weight: 500; padding-top: 4px; }
.tile-mid { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.tile-value { font-size: 30px; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.tile-foot { display: block; }
.tile-note { color: var(--ink-3); font-size: 12.5px; }
.delta { margin-right: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.delta-up::before { content: "\2191 "; }
.delta-down::before { content: "\2193 "; }
.spark { flex: none; width: 96px; height: 28px; }
.chip { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 8px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chip-blue { background: #e6f0fb; color: #1c5cab; }
.chip-amber { background: #fdf0d2; color: #8a5a00; }
.chip-green { background: #e2f3e2; color: #1a6b1a; }
.chip-red { background: #fbe3e1; color: #b42f2f; }
.chip-orange { background: #fde9df; color: #a4421a; }

.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.grid-eq { align-items: stretch; } /* dashboard rows: panels in a row share one height */
.grid-main > .panel { margin-top: 0; }
.period { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.period-label { color: var(--ink-2); font-size: 13px; }
.chart { padding: 16px 18px 14px; }
.chart-sub { display: block; margin-top: 2px; color: var(--ink-3); font-size: 12.5px; font-weight: 400; }

/* Column chart (one series) and two-sided column chart (in up, out down). */
.vc { padding-left: 30px; }
.vc-plot { position: relative; height: 190px; border-bottom: 1px solid #c3c2b7; }
.vc-div .vc-plot { height: 210px; border-bottom: 0; }
.vc-tick { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid #edebe6; }
.vc-tick > span { position: absolute; right: calc(100% + 8px); top: -8px; color: #898781; font-size: 11px; line-height: 16px; font-variant-numeric: tabular-nums; }
.vc-zero { position: absolute; left: 0; right: 0; bottom: 50%; border-top: 1px solid #c3c2b7; }
.vc-cols { position: absolute; inset: 0; display: flex; }
.vc-col { position: relative; flex: 1 1 0; min-width: 0; height: 100%; border-radius: 3px; }
.vc-col:hover, .vc-col:focus-visible { background: rgba(42, 120, 214, 0.07); outline: none; }
.vc-bar, .vc-up, .vc-down { position: absolute; left: 50%; transform: translateX(-50%); width: min(24px, 64%); min-height: 2px; }
.vc-bar { bottom: 0; background: var(--c); border-radius: 4px 4px 0 0; }
.vc-up { bottom: calc(50% + 1px); background: var(--in); border-radius: 4px 4px 0 0; }
.vc-down { top: calc(50% + 1px); background: var(--out); border-radius: 0 0 4px 4px; }
.vc-label { position: absolute; left: 50%; transform: translateX(-50%); color: var(--ink); font-size: 12px; font-weight: 600; }
.vc-x { display: flex; margin-top: 6px; }
.vc-x span { display: flex; justify-content: center; flex: 1 1 0; min-width: 0; color: #898781; font-size: 11px; white-space: nowrap; }

/* Horizontal bars with the value at the tip. */
.hb { display: grid; gap: 4px; }
.hb-row { display: grid; grid-template-columns: minmax(120px, 40%) minmax(0, 1fr); align-items: center; gap: 12px; padding: 5px 6px; border-radius: 4px; }
.hb-row:hover, .hb-row:focus-visible { background: var(--sunken); outline: none; }
.hb-name { display: block; font-weight: 500; line-height: 1.3; }
.hb-sub { display: block; color: var(--ink-3); font-size: 12px; }
.hb-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hb-bar { flex: none; height: 14px; min-width: 2px; border-radius: 0 4px 4px 0; } /* longest bar = 82% of the track, leaving room for its value */
.hb-val { color: var(--ink); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Legends and the stacked part-to-whole bar. */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 12px; padding: 0; list-style: none; color: var(--ink-2); font-size: 12.5px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }
.sb { display: flex; gap: 2px; height: 16px; }
.sb > span { min-width: 3px; }
.sb > span:first-child { border-radius: 4px 0 0 4px; }
.sb > span:last-child { border-radius: 0 4px 4px 0; }
.sb > span:only-child { border-radius: 4px; }
.sb > span:hover, .sb > span:focus-visible { filter: brightness(1.08); outline: none; }
.legend-stack { display: grid; gap: 9px; margin: 16px 0 0; }
.legend-stack li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 38px; gap: 8px; }
.legend-name { color: var(--ink); }
.legend-val { color: var(--ink); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.legend-pct { color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }

/* Stock meter: fill = severity, tick = the minimum. */
.meter { position: relative; display: block; height: 8px; border-radius: 4px; background: #e3f1e5; }
.meter-warning { background: #fcefd0; }
.meter-critical { background: #f9dedb; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: #0ca30c; }
.meter-warning .meter-fill { background: #fab219; }
.meter-critical .meter-fill { background: #d03b3b; }
.meter-min { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: #52514e; }
.restock { margin: 0; padding: 0; list-style: none; }
.restock li { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 4px 18px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--line-2); }
.restock li:last-child { border-bottom: 0; }
.restock-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 7px; color: var(--ink-3); font-size: 12.5px; }

/* Category marker: a small square in the category's chart colour, always beside its name. */
.cat { display: inline-flex; align-items: center; gap: 6px; }
.cat::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--cat, #b9b7ae); }

/* Table view under every chart, and the shared tooltip. */
.viz-table { margin-top: 12px; }
.viz-table summary { width: max-content; color: var(--ink-3); font-size: 12.5px; cursor: pointer; }
.viz-table summary:hover { color: var(--ink); }
.viz-table .table-wrap { max-height: 260px; margin-top: 8px; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: auto; }
.viz-tip {
  position: fixed; z-index: 50; max-width: 240px; padding: 8px 10px; pointer-events: none;
  background: #1b1d1f; color: #fff; border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); font-size: 12.5px; line-height: 1.35;
}
.viz-tip strong { display: block; font-size: 14px; }
.tip-label { display: flex; align-items: center; gap: 6px; color: #cfd2d6; }
.tip-key { flex: none; width: 12px; height: 2px; border-radius: 1px; }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-2, .grid-wide { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line-2); }
}

@media (max-width: 760px) {
  /* The header row stays as tall as its content; short pages give the spare height to main. */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    position: static; height: auto; overflow: visible; align-items: center;
    display: grid; grid-template-columns: 1fr auto; grid-template-areas: "brand user" "nav nav";
    gap: 12px; padding: 12px 16px 0; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { grid-area: brand; padding: 0; }
  .sidebar-user { grid-area: user; margin: 0; padding: 0; border: 0; }
  .sidebar-user .user-name, .sidebar-user .user-role { display: none; }
  .user-actions { margin: 0; }
  .nav { grid-area: nav; flex-direction: row; overflow-x: auto; margin: 0 -16px; padding: 0 16px 10px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-link { flex: none; }
  .content { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > * { grid-column: 1 / -1; }
  /* Wide tables scroll sideways instead of squeezing text to one word per line. */
  .table-wide { min-width: 720px; }
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .tiles { gap: 10px; }
  .tile { padding: 14px; }
  .tile-value { font-size: 24px; }
  .spark { display: none; }
  .hb-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .restock li { grid-template-columns: minmax(0, 1fr); }
  .vc { padding-left: 24px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { order: 2; padding: 28px 20px; border-right: 0; border-top: 1px solid var(--line); }
  .auth-title { margin-top: 24px; font-size: 20px; }
  .auth-main { padding: 32px 20px; }
  .input-search { max-width: none; }
}

@media print {
  .sidebar, .page-actions, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .panel { border-color: #bbb; }
  body { background: #fff; }
}
