/* WOKOS POS · Inventory v3 design system
   Tokens → base → shell → components → pages → responsive. No framework, no build step. */

/* Self-hosted font (no calls to Google: works offline and shares no visitor data). */
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 800; font-display: swap; src: url(fonts/plus-jakarta-sans-latin-800-normal.woff2) format("woff2"); }

:root {
  /* Brand palette */
  --bg: #F3F3F6;            /* soft cool grey: app background */
  --surface: #FFFFFF;       /* cards, panels, modals */
  --surface-2: #F8F9FA;
  --surface-3: #EDF1F1;
  --ink: #102B38;           /* dark text */
  --ink-2: #2D4752;
  --muted: #5E716F;         /* secondary text: darker shade of #899896 so small text stays readable */
  --muted-brand: #899896;   /* muted text colour from the brand palette (placeholders, hints, icons) */
  --line: #DEE5E4;          /* borders */
  --line-strong: #C9D3D2;
  --primary: #1B4D50;       /* deep teal green: buttons, headers, active elements */
  --primary-hover: #143B3D;
  --primary-ink: #ffffff;
  --primary-soft: #E2EDED;
  --secondary: #547378;     /* muted teal: secondary components, charts */
  --secondary-soft: #E5ECED;
  --ok: #12804A;      --ok-fill: #1BB75F;     --ok-soft: #E1F5EA;       /* success #1BB75F */
  --warn: #8A6500;    --warn-fill: #E7B215;   --warn-soft: #FBF2D6;     /* warning #E7B215 */
  --danger: #B4483D;  --danger-fill: #E58C83; --danger-soft: #FBE9E7;   /* danger #E58C83 */
  --info: #3F6266;    --info-soft: #E5ECED;
  --side-bg: #102B38;
  --side-ink: #CCDADC;
  --side-muted: #86A0A3;
  --side-hover: #173B4B;
  --side-line: #1E4252;
  --shadow-sm: 0 1px 2px rgba(16, 43, 56, .06);
  --shadow: 0 1px 2px rgba(16, 43, 56, .05), 0 6px 20px -8px rgba(16, 43, 56, .14);
  --shadow-lg: 0 24px 60px -20px rgba(16, 43, 56, .35);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --side-w: 252px;
  --top-h: 64px;
  color-scheme: light;
}

/* Dark mode. Default is "follow the device"; theme.js picks dark when the device states no light preference.
   Without JavaScript, the device setting decides. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1A20; --surface: #10242B; --surface-2: #132A32; --surface-3: #1A353E;
    --ink: #E8F0F0; --ink-2: #C5D3D4; --muted: #93A5A3; --muted-brand: #899896; --line: #1F3A43; --line-strong: #2B4A54;
    --primary: #5FB3AF; --primary-hover: #7CC3C0; --primary-ink: #0B1A20; --primary-soft: rgba(95, 179, 175, .15);
    --secondary: #8FB0B4; --secondary-soft: rgba(143, 176, 180, .14);
    --ok: #3DDC84; --ok-fill: #1BB75F; --ok-soft: rgba(27, 183, 95, .16);
    --warn: #F2C744; --warn-fill: #E7B215; --warn-soft: rgba(231, 178, 21, .15);
    --danger: #F0A39B; --danger-fill: #E58C83; --danger-soft: rgba(229, 140, 131, .16);
    --info: #8FB7BD; --info-soft: rgba(143, 183, 189, .14);
    --side-bg: #07141A; --side-hover: #12303A; --side-line: #173039;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -10px rgba(0,0,0,.5); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0B1A20; --surface: #10242B; --surface-2: #132A32; --surface-3: #1A353E;
    --ink: #E8F0F0; --ink-2: #C5D3D4; --muted: #93A5A3; --muted-brand: #899896; --line: #1F3A43; --line-strong: #2B4A54;
    --primary: #5FB3AF; --primary-hover: #7CC3C0; --primary-ink: #0B1A20; --primary-soft: rgba(95, 179, 175, .15);
    --secondary: #8FB0B4; --secondary-soft: rgba(143, 176, 180, .14);
    --ok: #3DDC84; --ok-fill: #1BB75F; --ok-soft: rgba(27, 183, 95, .16);
    --warn: #F2C744; --warn-fill: #E7B215; --warn-soft: rgba(231, 178, 21, .15);
    --danger: #F0A39B; --danger-fill: #E58C83; --danger-soft: rgba(229, 140, 131, .16);
    --info: #8FB7BD; --info-soft: rgba(143, 183, 189, .14);
    --side-bg: #07141A; --side-hover: #12303A; --side-line: #173039;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -10px rgba(0,0,0,.5); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 40;
  background: var(--side-bg); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #547378, #1B4D50); color: #fff; font-weight: 800; font-size: 18px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
  box-shadow: 0 6px 16px -6px rgba(16, 43, 56, .6);
}
.brand-mark.sm { width: 28px; height: 28px; font-size: 14px; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { color: #fff; font-size: 15px; letter-spacing: .02em; }
.brand-text small { color: var(--side-muted); font-size: 12px; }
.nav { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; }
.nav-group { margin: 18px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--side-muted); }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--side-ink); font-weight: 500; font-size: 14px; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--side-hover); color: #fff; }
.nav-link.active { background: rgba(95, 179, 175, .16); color: #fff; box-shadow: inset 3px 0 0 #5FB3AF; }
.nav-link.active .i { color: #8ED1CC; }
.nav-badge { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; background: var(--warn-fill); color: #102B38; border-radius: 99px; padding: 1px 7px; }
.sidebar-foot { border-top: 1px solid var(--side-line); padding-top: 14px; margin-top: 10px; }
.me { display: flex; align-items: center; gap: 10px; }
.me-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.me-text b { color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--side-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .icon-btn { color: var(--side-muted); }
.sidebar .icon-btn:hover { background: var(--side-hover); color: #fff; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #1E4252; color: #A9DCD8; font-weight: 700; font-size: 13px; flex: none; }
.main { flex: 1; min-width: 0; margin-left: var(--side-w); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h);
  display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.global-search { flex: 1; max-width: 520px; position: relative; display: flex; align-items: center; }
.global-search > .i { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.global-search input[type=search] {
  width: 100%; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  padding: 0 46px 0 40px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.global-search input[type=search]:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.scan-btn { position: absolute; right: 6px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.scan-btn:hover { background: var(--surface-3); color: var(--ink); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 11px; border: 0; background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn .dot { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--danger-fill); color: #102B38; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.theme-light, .theme-dark { display: none; }
:root[data-theme-pref="light"] .theme-light, :root[data-theme-pref="dark"] .theme-dark { display: block; }
:root[data-theme-pref="light"] .theme-system, :root[data-theme-pref="dark"] .theme-system { display: none; }
.content { padding: 28px; max-width: 1440px; width: 100%; margin: 0 auto; }
.tabbar, .scrim, .only-mobile { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 28px; font-weight: 800; }
.page-head .sub { color: var(--muted); margin-top: 6px; max-width: 680px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--primary); margin-bottom: 6px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.back-link:hover { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 14px -8px var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link { color: var(--primary); font-weight: 600; }
.link:hover { text-decoration: underline; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-actions .icon-btn { width: 34px; height: 34px; border-radius: 9px; color: var(--muted); }
.row-actions .icon-btn:hover { color: var(--ink); }

/* ---------- Cards and stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 16px; font-weight: 700; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 20px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.stat > div { min-width: 0; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); flex: none; }
.stat-icon .i { width: 20px; height: 20px; }
.stat-label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-primary .stat-icon { background: var(--primary-soft); color: var(--primary); }
.stat-warn .stat-icon { background: var(--warn-soft); color: var(--warn); }
.stat-danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat-ok .stat-icon { background: var(--ok-soft); color: var(--ok); }
.stat-info .stat-icon { background: var(--info-soft); color: var(--info); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-neutral { background: var(--surface-3); color: var(--muted); }
.pill-primary { background: var(--primary-soft); color: var(--primary); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.dir-in { color: var(--ok); font-weight: 700; }
.dir-out { color: var(--danger); font-weight: 700; }

/* ---------- Toolbar, filters, chips ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.search-input { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.search-input .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-input input { padding-left: 38px !important; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--line-strong); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip em { font-style: normal; font-size: 11px; opacity: .7; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-form .field { min-width: 150px; }
.bulkbar { display: none; align-items: center; gap: 10px; padding: 10px 20px; background: var(--primary-soft); border-bottom: 1px solid var(--line); flex-wrap: wrap; font-size: 14px; }
.bulkbar.show { display: flex; }
.bulkbar b { font-weight: 700; }
.bulkbar select, .bulkbar input { height: 34px !important; min-width: 140px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field small, .help { font-size: 12px; color: var(--muted); }
input[type=text], input[type=search], input[type=number], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=datetime-local], input:not([type]), select, textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23857c71' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
input[type=file] { font-size: 13px; padding: 9px; height: auto; border: 1px dashed var(--line-strong); border-radius: 10px; width: 100%; background: var(--surface-2); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-section { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }
.input-group { display: flex; }
.input-group input { border-radius: 10px 0 0 10px; }
.input-group select { border-radius: 0 10px 10px 0; border-left: 0; width: auto; min-width: 110px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { margin-top: 2px; }
.seg { display: inline-flex; padding: 4px; background: var(--surface-3); border-radius: 12px; gap: 4px; flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 44px; height: 26px; border-radius: 99px; background: var(--line-strong); transition: background .2s; position: relative; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row b { display: block; font-weight: 600; }
.setting-row p { color: var(--muted); font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable::after { content: " ↕"; opacity: .35; }
.table th.sort-asc::after { content: " ↑"; opacity: .9; }
.table th.sort-desc::after { content: " ↓"; opacity: .9; }
.table .w-check { width: 44px; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
.cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-main b { font-weight: 600; display: block; }
.cell-main small { color: var(--muted); font-size: 12px; display: block; }
.thumb { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-3); }
.thumb-empty { display: grid; place-items: center; color: var(--muted); }
.thumb-empty .i { width: 18px; height: 18px; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.danger > i { background: var(--danger); }
.qty-cell { display: flex; flex-direction: column; gap: 5px; min-width: 110px; }
.qty-cell b { font-variant-numeric: tabular-nums; }
.table-foot { padding: 12px 20px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.pager { display: flex; gap: 6px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list small { color: var(--muted); font-size: 12px; }
.mv-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.mv-icon.in { background: var(--ok-soft); color: var(--ok); }
.mv-icon.out { background: var(--danger-soft); color: var(--danger); }
.mv-icon .i { width: 16px; height: 16px; }

/* ---------- Empty, toast, dialog ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state h2, .empty-state h3 { color: var(--ink); font-size: 18px; margin: 14px 0 6px; }
.empty-state p { max-width: 420px; margin: 0 auto 18px; }
.empty-icon { width: 60px; height: 60px; margin: 0 auto; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty-icon .i { width: 26px; height: 26px; }
.toast {
  position: fixed; z-index: 100; top: 76px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500; max-width: min(560px, calc(100vw - 32px));
  animation: toast-in .25s ease-out;
}
.toast-success .i:first-child { color: #4ade9a; }
.toast-error { background: #A33E33; color: #fff; }
.toast-x { border: 0; background: transparent; color: inherit; opacity: .7; cursor: pointer; display: grid; place-items: center; padding: 4px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: 100vw; max-height: 100vh; }
dialog::backdrop { background: rgba(15, 12, 9, .5); backdrop-filter: blur(2px); }
.sheet-card { background: var(--surface); border-radius: 18px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; box-shadow: var(--shadow-lg); padding: 22px; }
.sheet.wide .sheet-card { width: min(820px, calc(100vw - 32px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.sheet-head h2 { font-size: 19px; font-weight: 700; }
.sheet-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
dialog[open] .sheet-card { animation: sheet-in .2s ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
#scan-video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4/3; object-fit: cover; margin-bottom: 10px; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--info-soft); color: var(--ink-2); font-size: 14px; }
.callout .i { color: var(--info); margin-top: 2px; }
.callout.warn { background: var(--warn-soft); }
.callout.warn .i { color: var(--warn); }

/* ---------- Dashboard ---------- */
.hero-dash {
  position: relative; overflow: hidden; border-radius: 18px; padding: 26px 28px; margin-bottom: 22px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #6E9297 0%, #1B4D50 42%, #0B1E26 100%);
  display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; flex-wrap: wrap;
}
.hero-dash h1 { font-size: 26px; font-weight: 800; }
.hero-dash p { opacity: .85; margin-top: 6px; }
.hero-dash .btn { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.14); color: #fff; }
.hero-dash .btn:hover { background: rgba(255,255,255,.24); }
.hero-dash .btn-primary { background: #fff; color: #1B4D50; border-color: #fff; }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.quick { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); font-weight: 600; transition: border-color .15s, transform .1s; }
.quick:hover { border-color: var(--primary); transform: translateY(-1px); }
.quick .stat-icon { width: 38px; height: 38px; }
.chart { width: 100%; height: 220px; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid line { stroke: var(--line); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbar-list { list-style: none; margin: 0; padding: 6px 20px 16px; }
.hbar-list li { padding: 8px 0; }
.hbar-list .top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 6px; }
.hbar-list .top span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

/* ---------- Detail pages ---------- */
.detail-head { display: flex; gap: 18px; align-items: center; margin-bottom: 22px; flex-wrap: wrap; }
.detail-head .thumb { width: 72px; height: 72px; border-radius: 16px; }
.detail-head .thumb-empty .i { width: 28px; height: 28px; }
.detail-head h1 { font-size: 26px; font-weight: 800; }
.detail-head .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.detail-head .page-actions { margin-left: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- Count mode ---------- */
.count-input { width: 120px !important; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.count-row.done td { background: color-mix(in srgb, var(--ok-soft) 60%, transparent); }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.progress { height: 8px; width: 180px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .2s; }

/* ---------- Line item editor (recipes, POs) ---------- */
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
.line.two { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr) 40px; }
.line-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.total-row { display: flex; justify-content: flex-end; gap: 18px; font-size: 15px; padding-top: 10px; }
.total-row b { font-size: 18px; }

/* ---------- Auth ---------- */
body.bare { background: var(--bg); }
.bare-main { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(120% 120% at 0% 100%, #6E9297 0%, #1B4D50 38%, #0B1E26 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h2 { font-size: 40px; font-weight: 800; line-height: 1.1; max-width: 460px; }
.auth-art p { opacity: .8; max-width: 420px; margin-top: 14px; font-size: 16px; }
.auth-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.auth-art li { display: flex; gap: 10px; align-items: center; opacity: .92; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }
.auth-error { background: var(--danger-soft); color: var(--danger); padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; font-weight: 500; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-color: var(--primary); }

/* ---------- Print (purchase orders) ---------- */
@media print {
  .sidebar, .topbar, .tabbar, .page-actions, .no-print, .toast { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; color: #000; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tablet: icon rail */
@media (max-width: 1100px) and (min-width: 761px) {
  :root { --side-w: 76px; }
  .sidebar { padding: 18px 10px; align-items: center; }
  .brand { padding: 4px 0 18px; }
  .brand-text, .nav-group, .nav-link span, .me-text, .sidebar-foot .icon-btn { display: none; }
  .nav { margin: 0; padding: 0; width: 100%; }
  .nav-link { justify-content: center; padding: 12px; position: relative; margin-bottom: 4px; }
  .nav-link .i { width: 20px; height: 20px; }
  .nav-badge { position: absolute; top: 4px; right: 4px; padding: 0 5px; font-size: 10px; }
  .me { justify-content: center; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* Phone: drawer + bottom tabs + card lists */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .main { margin-left: 0; }
  .only-mobile { display: inline-flex; }
  .hide-sm { display: none !important; }
  .sidebar { transform: translateX(-102%); transition: transform .25s ease; width: min(300px, 86vw); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.45); }
  .topbar { padding: 0 12px; gap: 8px; height: 58px; }
  .global-search { display: none; }
  body.search-open .global-search { display: flex; position: absolute; inset: 8px 12px; max-width: none; z-index: 2; }
  .content { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head h1 { font-size: 23px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .stats, .stats.three { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
  /* Phone stat cards: about 20% smaller than before (dashboard, recipes and other summary rows). */
  .stat { padding: 11px; gap: 7px; flex-direction: column; border-radius: 12px; }
  .stat-icon { width: 27px; height: 27px; border-radius: 8px; }
  .stat-icon .i { width: 14px; height: 14px; }
  .stat-label { font-size: 11.5px; line-height: 1.3; }
  .stat-value { font-size: 17px; margin-top: 1px; }
  .stat-hint { font-size: 11px; line-height: 1.3; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .quick { padding: 12px; font-size: 14px; }
  .grid-2, .grid-2.even { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .hero-dash { padding: 20px; border-radius: 16px; }
  .hero-dash h1 { font-size: 21px; }
  .card-head, .toolbar, .card-body { padding-left: 16px; padding-right: 16px; }
  .search-input { max-width: none; min-width: 100%; }
  .chips { overflow-x: auto; flex-wrap: nowrap; width: 100%; scrollbar-width: none; padding-bottom: 2px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); border: 0; background: none; padding: 6px 0; cursor: pointer; }
  .tabbar .i { width: 22px; height: 22px; }
  .tabbar .on { color: var(--primary); }
  .tabbar .tab-fab { width: 54px; height: 54px; margin: -22px auto 0; border-radius: 18px; background: var(--primary); color: #fff; justify-content: center; box-shadow: 0 10px 22px -8px var(--primary); }
  .tabbar .tab-fab .i { width: 26px; height: 26px; }

  /* Tables stay real tables on phones: see "Mobile tables" further down. */
  .count-input { width: 130px !important; height: 46px !important; font-size: 17px; }
  .sheet-card { width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; max-height: 92vh; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .sheet.wide .sheet-card { width: 100vw; }
  dialog.sheet { margin: auto 0 0 0; width: 100vw; }
  dialog.sheet[open] .sheet-card { animation: sheet-up .25s ease-out; }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } }
  .line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; }
  .line > :first-child { grid-column: 1 / -1; }
  .line.two { grid-template-columns: minmax(0, 1fr) 40px; }
  .line-head { display: none; }
  .bare-main { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .toast { top: 66px; }
  .detail-head .page-actions { margin-left: 0; }
  .sticky-actions { bottom: calc(70px + env(safe-area-inset-bottom)); border-radius: 0; }
  .progress { width: 110px; }
}
.hide-desktop{display:none}
@media (max-width:760px){.hide-desktop{display:block}}

/* ---------- Refinements after visual review ---------- */
.toolbar .chips { flex: 1 1 100%; }
.toolbar .search-input { flex: 1 1 260px; }
.table td.num, .table th.num { white-space: nowrap; }
.table .cell-primary .cell-main > span:not(.thumb):not(.avatar):not(.mv-icon) { min-width: 170px; }
.table .cell-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.table .actions-cell { white-space: nowrap; width: 1%; }
@media (max-width: 1300px) and (min-width: 761px) { .table .hide-md { display: none; } }
@media (max-width: 760px) {
  .page-actions .btn-ghost { flex: 0 0 auto; }
}
.stack > .card .hbar-list { columns: 2; column-gap: 32px; }
@media (max-width: 760px) { .stack > .card .hbar-list { columns: 1; } }
.hbar-list li { break-inside: avoid; }

/* ---------- v3: brand, security, logs, notifications ---------- */
::placeholder { color: var(--muted-brand); opacity: 1; }
.brand-logo { width: 40px; height: 40px; border-radius: 11px; object-fit: contain; background: #fff; padding: 3px; flex: none; }
.brand-logo.sm { width: 28px; height: 28px; border-radius: 8px; padding: 2px; }
.brand-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.me-text { min-width: 0; }
.sidebar-foot form { margin: 0; }
.eyebrow.on-dark { color: #BFE0DD; }
.auth-art .brand-text small, .auth-art small { color: rgba(255,255,255,.72); }
.auth-foot { display: inline-flex; gap: 6px; align-items: center; opacity: .75; }
.auth-foot .i { width: 14px; height: 14px; }
.btn-tall { height: 48px; }
.code-input { font-size: 22px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.btn-secondary { background: var(--secondary); border-color: var(--secondary); color: #fff; }

/* Tone helpers for icons in lists */
.tone-ok { background: var(--ok-soft) !important; color: var(--ok) !important; }
.tone-warn { background: var(--warn-soft) !important; color: var(--warn) !important; }
.tone-danger { background: var(--danger-soft) !important; color: var(--danger) !important; }
.tone-info { background: var(--info-soft) !important; color: var(--info) !important; }
.tone-primary { background: var(--primary-soft) !important; color: var(--primary) !important; }
.tone-neutral { background: var(--surface-3) !important; color: var(--muted) !important; }
.callout.ok { background: var(--ok-soft); }
.callout.ok .i { color: var(--ok); }

/* Notifications */
.notify { position: relative; }
.notify-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(360px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 60; overflow: hidden; }
.notify-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notify-head form { margin: 0; }
.notify-head .link { border: 0; background: none; cursor: pointer; color: var(--primary); font-weight: 600; padding: 0; }
.notify-list { max-height: 380px; overflow-y: auto; }
.notify-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.notify-item:hover { background: var(--surface-2); }
.notify-item b { display: block; font-size: 14px; font-weight: 600; }
.notify-item small { display: block; font-size: 12px; color: var(--ink-2); }
.notify-item small.muted { color: var(--muted); }
.notify-item.unread b { font-weight: 800; }
.notify-type { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--line-strong); }
.notify-item.unread .notify-type { background: var(--primary); }
.notify-item.unread .notify-type.t-lockout, .notify-item.unread .notify-type.t-error { background: var(--danger-fill); }
.notify-empty { padding: 18px 14px; }
.notify-all { display: block; text-align: center; padding: 11px; font-weight: 600; color: var(--primary); font-size: 14px; }
.notify-page li.unread { background: var(--primary-soft); }
.notify-page li { align-items: flex-start; }
.notify-page p { margin-top: 2px; color: var(--ink-2); }
.tabbar a { position: relative; }
.tab-dot { position: absolute; top: 6px; left: calc(50% + 6px); width: 8px; height: 8px; border-radius: 50%; background: var(--danger-fill); }

/* Settings, logs, security */
.narrow-card { max-width: 820px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.card-body.bordered { border-bottom: 1px solid var(--line); }
.card-body.tight { padding-top: 4px; padding-bottom: 4px; }
.logo-row { display: flex; gap: 16px; align-items: center; }
.logo-preview { width: 84px; height: 84px; border-radius: 16px; border: 1px dashed var(--line-strong); display: grid; place-items: center; background: var(--surface-2); flex: none; overflow: hidden; }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.grow { flex: 1; min-width: 0; }
.qr { width: 196px; height: 196px; background: #fff; border-radius: 12px; padding: 6px; border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; display: block; }
.steps { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.strength { min-height: 1em; font-weight: 600; }
.strength[data-level="0"], .strength[data-level="1"] { color: var(--danger); }
.strength[data-level="2"] { color: var(--warn); }
.strength[data-level="3"], .strength[data-level="4"], .strength[data-level="5"] { color: var(--ok); }
.matrix th.c, .matrix td.c { text-align: center; width: 1%; white-space: nowrap; }
.matrix th small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.matrix tr.group td { background: var(--surface-2); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.matrix .yes { color: var(--ok); display: inline-grid; }
.matrix .no { color: var(--line-strong); }
.score { font-size: 22px; font-weight: 800; padding: 6px 12px; border-radius: 12px; }
.score.ok { background: var(--ok-soft); color: var(--ok); }
.score.warn { background: var(--warn-soft); color: var(--warn); }
.checks li { align-items: flex-start; }
.checks small { display: block; color: var(--ink-2); margin-top: 2px; }
.list.compact li { padding-top: 10px; padding-bottom: 10px; }
.key-show { margin-top: 10px; }
.key-show input { flex: 1; min-width: 0; }
.input-group { display: flex; gap: 0; }
.input-group > input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.log-table td { vertical-align: top; }
.log-table .ua { max-width: 220px; }
.trace { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 8px 0 0; max-height: 300px; overflow: auto; }
details summary { cursor: pointer; }
.avatar.soft { background: var(--primary-soft); color: var(--primary); }

@media (max-width: 1100px) {
  .grid-2.wide-left { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .logo-row { flex-direction: column; align-items: flex-start; }
  .notify-panel { position: fixed; left: 16px; right: 16px; top: 64px; width: auto; }
  .matrix { font-size: 13px; }
}

/* Searchable picker (select[data-combo]) */
.combo { position: relative; min-width: 0; }
.combo-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; overflow: hidden; clip-path: inset(50%); }
.combo-input { width: 100%; padding-right: 32px !important; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23899896' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 80; margin: 0; padding: 4px; list-style: none; max-height: 248px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.combo-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-list li.on { background: var(--primary-soft); color: var(--primary); }
.combo-list li[aria-selected="true"] { font-weight: 700; }
.combo-list li.combo-empty { color: var(--muted); cursor: default; white-space: normal; }

/* Printable purchase order */
.print-only { display: none; }
.po-toolbar { display: flex; gap: 10px; justify-content: space-between; max-width: 860px; margin: 0 auto 14px; }
.po-doc { background: #fff; color: #102B38; font-size: 13px; line-height: 1.45; }
.po-doc-screen { display: block; max-width: 860px; margin: 0 auto; padding: 40px 44px; border-radius: 6px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.po-doc-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 18px; border-bottom: 3px solid #1B4D50; }
.po-doc-brand { display: flex; gap: 14px; align-items: flex-start; }
.po-doc-brand img { width: 64px; height: 64px; object-fit: contain; }
.po-doc-brand b { display: block; font-size: 18px; }
.po-doc-brand small { display: block; color: #4A5F5D; font-size: 12px; }
.po-doc-title { text-align: right; }
.po-doc-title h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: .02em; text-transform: uppercase; color: #1B4D50; }
.po-doc-title table { margin-left: auto; border-collapse: collapse; }
.po-doc-title th { text-align: right; font-weight: 600; color: #4A5F5D; padding: 1px 10px 1px 0; }
.po-doc-title td { text-align: right; font-weight: 700; padding: 1px 0; }
.po-doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 20px 0; }
.po-doc-parties span { display: block; color: #2D4752; }
.po-doc-parties b { display: block; font-size: 15px; }
.po-doc-label { margin: 0 0 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #547378; }
.po-doc-lines { width: 100%; border-collapse: collapse; }
.po-doc-lines th { background: #1B4D50; color: #fff; text-align: left; font-weight: 600; padding: 8px 10px; font-size: 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.po-doc-lines td { padding: 8px 10px; border-bottom: 1px solid #DEE5E4; vertical-align: top; }
.po-doc-lines tbody tr:nth-child(even) td { background: #F6F8F8; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.po-doc-lines .num { text-align: right; white-space: nowrap; }
.po-doc-lines .c { text-align: center; width: 1%; }
.po-doc-lines tfoot td { border-bottom: 0; border-top: 2px solid #1B4D50; font-size: 15px; padding-top: 10px; }
.po-doc-notes { margin-top: 18px; padding: 12px 14px; border: 1px solid #DEE5E4; border-radius: 6px; }
.po-doc-notes p:last-child { margin: 0; }
.po-doc-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 56px; }
.po-doc-sign div { border-top: 1px solid #102B38; padding-top: 6px; }
.po-doc-sign span { display: block; font-size: 11px; color: #4A5F5D; text-transform: uppercase; letter-spacing: .06em; }
.po-doc-sign b { display: block; min-height: 1.4em; }
.po-doc-foot { margin-top: 26px; font-size: 11px; color: #5E716F; text-align: center; }
@media (max-width: 760px) {
  .po-doc-screen { padding: 22px 18px; }
  .po-doc-head, .po-doc-parties { display: block; }
  .po-doc-title { text-align: left; margin-top: 14px; }
  .po-doc-title table { margin-left: 0; }
  .po-doc-parties > div + div { margin-top: 14px; }
  .po-doc-lines { font-size: 12px; }
  .po-doc-lines th:nth-child(3), .po-doc-lines td:nth-child(3) { display: none; }
  .po-doc-sign { grid-template-columns: 1fr; gap: 28px; }
}
@page { margin: 14mm; }
@media print {
  .screen-only { display: none !important; }
  .print-only, .po-doc { display: block !important; }
  .po-doc-screen { box-shadow: none; border: 0; padding: 0; max-width: none; }
  .po-doc-lines tr { break-inside: avoid; }
  .po-doc-sign { break-inside: avoid; }
}

/* Chart animations: bars grow, lines draw left to right, ranked bars slide in.
   They start when the chart scrolls into view, and are skipped for reduced motion and print. */
@keyframes bar-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes line-draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes hbar-grow { from { width: 0; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(0); } 70% { opacity: 1; transform: scale(1.4); } 100% { opacity: 1; transform: scale(1); } }
.chart-anim .cbar { transform-box: fill-box; transform-origin: 50% 100%; animation: bar-grow .75s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 22ms); transition: opacity .15s, filter .15s; }
.chart-anim .cbar:hover { filter: brightness(1.12); }
.chart-anim .line-reveal { animation: line-draw 1.2s cubic-bezier(.4, 0, .2, 1) both; }
.chart-anim .line-end { transform-box: fill-box; transform-origin: center; animation: pop-in .45s ease-out 1.1s both; }
.chart-anim .hbar i { animation: hbar-grow .9s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(80ms + var(--i, 0) * 70ms); }
.chart-anim:not(.in-view) .cbar, .chart-anim:not(.in-view) .line-reveal, .chart-anim:not(.in-view) .line-end, .chart-anim:not(.in-view) .hbar i { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .chart-anim .cbar, .chart-anim .line-reveal, .chart-anim .line-end, .chart-anim .hbar i { animation: none !important; }
}
@media print {
  .chart-anim .cbar, .chart-anim .line-reveal, .chart-anim .line-end, .chart-anim .hbar i { animation: none !important; }
}

/* Dashboard consumption analysis */
.consumption { margin-bottom: 18px; }
.consumption .card-head { flex-wrap: wrap; gap: 10px; }
.consumption-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 8px; padding: 4px 20px 18px; align-items: start; }
.consumption-chart .legend { margin: 0 0 8px; }
.chart.chart-tall { height: 250px; }
.chart .avg-label { fill: var(--ink); font-size: 11px; font-weight: 700; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.consumption-side { border-left: 1px solid var(--line); padding-left: 18px; }
.cons-kpis { display: grid; gap: 12px; }
.cons-kpis span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.cons-kpis b { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cons-kpis small { display: block; font-size: 12px; color: var(--muted); }
.cons-sub { margin: 16px 0 0; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.consumption-side .hbar-list { padding: 4px 0 0; columns: 1 !important; }
@media (max-width: 1100px) {
  .consumption-body { grid-template-columns: minmax(0, 1fr); }
  .consumption-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 14px; }
  .cons-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .consumption-body { padding: 4px 16px 16px; }
  .cons-kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .cons-kpis > div:first-child { grid-column: 1 / -1; }
  .cons-kpis b { font-size: 17px; }
}

/* Profile pictures */
.avatar.has-img { padding: 0; overflow: hidden; background: var(--surface-3); }
.avatar.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.avatar.xl { width: 76px; height: 76px; font-size: 24px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line-strong); }
.avatar-row { display: flex; gap: 16px; align-items: center; }
@media (max-width: 760px) { .avatar-row { align-items: flex-start; } .avatar.xl { width: 60px; height: 60px; font-size: 20px; } }

/* Settings → Users: minimal user cards */
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; padding: 18px 20px 20px; }
.user-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 22px 14px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s, box-shadow .15s, transform .15s; min-width: 0; }
.user-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.user-card.is-off { opacity: .62; }
.user-card .avatar.xl { margin-bottom: 8px; }
.user-name { font-size: 15px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-handle { font-size: 12px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.user-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.user-tags .pill .i { width: 12px; height: 12px; margin-right: 3px; vertical-align: -2px; }
.user-seen { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.user-actions { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); width: 100%; }
.user-actions form { margin: 0; }
.user-dot { position: absolute; top: 12px; right: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.user-dot.dot-ok { background: var(--ok-fill); box-shadow: 0 0 0 3px var(--ok-soft); }
.user-dot.dot-warn { background: var(--warn-fill); box-shadow: 0 0 0 3px var(--warn-soft); }
.user-dot.dot-danger { background: var(--danger-fill); box-shadow: 0 0 0 3px var(--danger-soft); }
@media (max-width: 760px) {
  .user-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px 16px 16px; }
  .user-card { padding: 18px 10px 12px; }
  .user-card .avatar.xl { width: 56px; height: 56px; font-size: 18px; }
}

/* Settings → Users: minimal table */
.user-table .show-xs { display: none; }
.head-tools { display: flex; gap: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: var(--surface-2); }
.seg a { display: grid; place-items: center; width: 32px; height: 28px; border-radius: 8px; color: var(--muted); }
.seg a .i { width: 16px; height: 16px; }
.seg a.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.user-table thead th { background: transparent; font-size: 11px; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--line); }
.user-table td { border-bottom: 1px solid var(--line); padding-top: 12px; padding-bottom: 12px; vertical-align: middle; }
.user-table tbody tr:last-child td { border-bottom: 0; }
.user-table tbody tr:hover td { background: var(--surface-2); }
.user-table tr.is-off td { opacity: .55; }
.user-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-cell .avatar { width: 38px; height: 38px; }
.user-cell b { display: block; font-weight: 600; font-size: 14px; }
.user-cell small { display: block; font-size: 12px; color: var(--muted); }
.role-tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); }
.role-tag.role-primary { background: var(--primary-soft); color: var(--primary); }
.role-tag.role-info { background: var(--info-soft); color: var(--info); }
.status-text { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.user-dot-inline { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.user-dot-inline.dot-ok { background: var(--ok-fill); }
.user-dot-inline.dot-warn { background: var(--warn-fill); }
.user-dot-inline.dot-danger { background: var(--danger-fill); }
.user-table .row-end { text-align: right; width: 1%; white-space: nowrap; }
.row-actions.quiet { justify-content: flex-end; opacity: .55; transition: opacity .15s; }
.user-table tr:hover .row-actions.quiet, .row-actions.quiet:focus-within { opacity: 1; }
@media (hover: none) { .row-actions.quiet { opacity: 1; } }
@media (max-width: 760px) {
  .user-table th:nth-child(2), .user-table td:nth-child(2), .user-table th:nth-child(3), .user-table td:nth-child(3) { display: none; }
  .user-table .show-xs { display: inline; }
  .user-cell b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .user-cell > span { min-width: 0; }
  .user-table td:first-child { max-width: 0; width: 100%; }
  .user-table .row-actions.quiet { gap: 2px; }
  .user-table td { padding-left: 10px; padding-right: 10px; }
  .user-table td:first-child { padding-left: 16px; }
  .user-cell .avatar { width: 34px; height: 34px; }
  .hide-xs { display: none; }
  .head-tools .btn { padding: 0 10px; }
}

/* Bulk import */
.import-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.import-steps { display: flex; flex-direction: column; gap: 10px; }
.import-file { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none; transition: border-color .15s, background .15s; }
.import-file:hover { border-color: var(--primary); background: var(--surface-2); }
.import-file > span:nth-child(2) { flex: 1; min-width: 0; }
.import-file b { display: block; font-weight: 600; }
.import-file small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.import-file > .i { color: var(--muted); flex: none; }
.import-ico { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.import-ico.xlsx { background: var(--ok-soft); color: var(--ok); }
.import-ico.csv { background: var(--info-soft); color: var(--info); }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 170px; padding: 20px; text-align: center; border: 2px dashed var(--line-strong); border-radius: 14px; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone .i { width: 30px; height: 30px; color: var(--primary); }
.dropzone b { font-weight: 600; word-break: break-all; }
.dropzone small { color: var(--muted); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone.drag, .dropzone:hover, .dropzone:focus-within { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--ok-fill); }
.import-table td { vertical-align: top; }
.import-table small.block { display: block; margin-top: 2px; }
.import-table tr.imp-error td { background: color-mix(in srgb, var(--danger-soft) 45%, transparent); }
.imp-msgs { font-size: 13px; line-height: 1.45; }
.imp-err { color: var(--danger); }
.imp-err::before { content: "• "; }
.imp-note { color: var(--muted); }
.imp-note::before { content: "• "; }
.imp-lines { color: var(--ink-2); font-size: 12.5px; }
.import-foot { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.import-foot form { margin: 0; }
.import-foot form:first-child { margin-right: auto; }
@media (max-width: 900px) { .import-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .import-table th:nth-child(1), .import-table td:nth-child(1) { display: none; }
  .import-foot .btn { flex: 1; }
  .import-foot form { flex: 1; display: flex; }
}

/* Notifications: clearing */
.notify-head-actions { display: flex; gap: 12px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.btn-danger-soft { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger-soft:hover { background: var(--danger-soft); }
.notify-page li { gap: 12px; }
.notify-check { margin-top: 12px; flex: none; width: 18px; height: 18px; accent-color: var(--primary); }
.notify-toolbar { display: flex; flex-direction: row !important; align-items: center !important; flex-wrap: wrap; gap: 12px; }
.select-all-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-right: 6px; }
.notify-page .row-actions { flex: none; }
@media (max-width: 760px) {
  .head-actions .btn { flex: 1; padding: 0 10px; }
  .notify-page li { padding-left: 14px; padding-right: 12px; flex-wrap: wrap; }
  .notify-page .grow { flex: 1 1 0; }
}

/* =====================================================================
   Round 9: phone view that feels like an app
   Quick actions, charts drawn for phones, real tables with their own
   scroll area, and touch behaviour (no zoom on inputs, press feedback,
   safe areas, installable to the home screen).
   ===================================================================== */

/* Quick actions (dashboard) */
.quick { position: relative; }
.quick-icon { position: relative; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.quick-icon .i { width: 20px; height: 20px; }
.quick-label { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.quick-sub { font-size: 12px; font-weight: 500; color: var(--muted); }
.quick-badge { display: none; position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--warn-fill); color: #102B38; font: 700 11px/16px var(--font); font-style: normal; text-align: center; border: 2px solid var(--surface); }

/* Charts: one drawing for wide screens, one for phones */
.chart-box { position: relative; width: 100%; }
.chart.chart-sm { display: none; }
.chart-box.chart-tall .chart-lg { height: 250px; }


@media (hover: none) {
  .quick:hover { transform: none; border-color: var(--line); }
  .table tbody tr:hover td { background: inherit; }
}

@media (max-width: 760px) {
  /* ---- Touch behaviour ---- */
  html { -webkit-tap-highlight-color: transparent; }
  body { overflow-x: hidden; }
  a, button, input, select, textarea, label, summary, .chip { touch-action: manipulation; }
  .tabbar, .quick, .btn, .chip, .nav, .topbar, .seg, .tabs { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  /* 16px stops phones zooming into a field when it is tapped */
  input[type=text], input[type=search], input[type=number], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=datetime-local], input:not([type]), select, textarea { font-size: 16px; height: 46px; }
  textarea { height: auto; }
  .bulkbar select, .bulkbar input { font-size: 15px; }
  .btn { height: 46px; border-radius: 13px; }
  .btn-sm { height: 38px; }
  .btn, .chip, .quick, .icon-btn, .tabbar a, .tabbar button, .list li > a, .nav-link, .seg span { transition: transform .12s ease, background .15s, opacity .15s; }
  .btn:active, .chip:active, .icon-btn:active, .seg span:active { transform: scale(.96); }
  .tabbar a:active, .tabbar button:active { transform: scale(.9); }

  /* ---- App shell ---- */
  .topbar { height: calc(58px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); background: color-mix(in srgb, var(--bg) 92%, transparent); }
  .topbar-brand { font-size: 17px; font-weight: 800; }
  .sidebar { padding-top: calc(18px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .content { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); animation: page-in .22s ease-out both; }
  .toast { top: calc(66px + env(safe-area-inset-top)); }
  .notify-panel { top: calc(64px + env(safe-area-inset-top)); }
  .page-head .eyebrow { display: none; }
  .page-head h1 { font-size: 22px; }
  .card { border-radius: 16px; }
  .tabbar { grid-template-columns: repeat(var(--tabs, 5), 1fr); padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); box-shadow: 0 -6px 20px -14px rgba(0,0,0,.35); }
  .tabbar a, .tabbar button { padding: 4px 0 2px; }
  .tabbar .on .i { background: var(--primary-soft); border-radius: 99px; width: 52px; height: 28px; padding: 3px 15px; box-sizing: border-box; }
  .tabbar .tab-fab .i { background: none; }
  .tab-dot { left: calc(50% + 8px); top: 4px; }

  /* ---- Dashboard ---- */
  .hero-dash { padding: 18px; margin-bottom: 14px; }
  .hero-dash .page-actions .btn { height: 44px; }
  /* Quick actions: four real buttons, two per row */
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .quick { flex-direction: row; align-items: center; gap: 9px; min-height: 52px; padding: 8px 10px; border-radius: 14px; font-size: 13px; font-weight: 700; line-height: 1.2; color: var(--ink); box-shadow: var(--shadow-sm); }
  .quick-icon { width: 34px; height: 34px; border-radius: 10px; transition: transform .12s ease; }
  .quick-icon .i { width: 18px; height: 18px; }
  .quick-label { min-width: 0; }
  .quick-sub { font-size: 11px; font-weight: 600; }
  .quick-badge { display: none; }
  .quick:active { transform: scale(.97); background: var(--surface-3); }
  .card-head .legend { width: 100%; gap: 6px 14px; }

  /* ---- Charts: phone drawing, scaled evenly to the card width ---- */
  .chart.chart-lg { display: none; }
  .chart.chart-sm { display: block; width: 100%; height: auto; max-height: 62vh; }
  .chart.chart-sm text { font-size: 12px; }
  .chart.chart-sm .avg-label { font-size: 12px; }
  .card-body:has(> .chart-box) { padding: 12px 10px 10px; }
  .consumption-body { padding: 4px 10px 16px; }
  .consumption-chart .legend { padding: 0 6px; }
  .consumption-side { padding-left: 6px; padding-right: 6px; }

}

@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .content { animation: none !important; } }

/* Opened from the home screen (installed app): no browser bar, no pull-to-refresh bounce */
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: none; }
  body { -webkit-user-select: none; user-select: none; }
  input, textarea, select, [contenteditable], .table td, .list small, p { -webkit-user-select: text; user-select: text; }
}

/* =====================================================================
   Round 10: phone pages fit the screen width (no sideways scrolling),
   tables become small cards, Settings tables fit, less top spacing.
   ===================================================================== */
@media (max-width: 760px) {
  /* Nothing may push the page wider than the phone */
  html, body { overflow-x: clip; max-width: 100%; }
  .main, .content, .card, .stat, .grid-2 > *, .stack > *, .page-head > *, .card-head > * { min-width: 0; }
  .content { overflow-wrap: break-word; }
  svg, video, canvas, iframe { max-width: 100%; }
  .table-wrap { overflow-x: auto; max-height: none; }

  /* Tighter top: page starts right under the top bar */
  .content { padding-top: 10px; }
  .page-head { margin-bottom: 12px; gap: 10px; }
  .page-head .sub { margin-top: 3px; font-size: 13.5px; }
  .back-link { margin-bottom: 6px; }
  .hero-dash { padding: 16px; margin-bottom: 12px; gap: 12px; }
  .hero-dash h1 { font-size: 20px; }
  .hero-dash p { font-size: 13.5px; margin-top: 4px; }
  .stats, .stats.three { margin-bottom: 12px; gap: 8px; }
  .grid-2, .stack { gap: 12px; margin-bottom: 12px; }
  .card-head { padding-top: 14px; padding-bottom: 12px; }
  .card-head h2, .card-head h3 { font-size: 15px; }
  .card-head p { font-size: 12.5px; }

  /* Charts sized to fit inside the screen */
  .chart.chart-sm { max-height: min(240px, 34dvh); }
  .legend { font-size: 11.5px; gap: 4px 12px; }
  .consumption { margin-bottom: 12px; }
  .cons-kpis b { font-size: 16px; }

  /* ---- Tables become small cards: no sideways scroll, no scroll box ---- */
  .table .cell-primary .cell-main > span:not(.thumb):not(.avatar):not(.mv-icon) { min-width: 0; }
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tfoot { display: block; width: 100%; }
  .table-cards tr { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px 10px; align-items: end; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .table-cards tbody tr:last-child { border-bottom: 0; }
  .table-cards td { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 0; border: 0; font-size: 12.5px; line-height: 1.3; text-align: left; white-space: normal; overflow-wrap: anywhere; background: none !important; }
  .table-cards td::before { content: attr(data-label); font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
  .table-cards td:not([data-label])::before, .table-cards td[data-label=""]::before, .table-cards td.cell-primary::before, .table-cards td.actions-cell::before { display: none; }
  .table-cards td.num { text-align: left; }
  .table-cards td.cell-primary { grid-column: 1 / -1; }
  .table-cards tr.has-check td.cell-primary { padding-right: 30px; }
  .table-cards td.w-check { position: absolute; top: 12px; right: 12px; width: auto; }
  .table-cards td.actions-cell { grid-column: 2 / -1; flex-direction: row; justify-content: flex-end; align-items: center; width: auto; }
  .table-cards td[data-label="Status"]::before { display: none; }
  .table-cards .row-actions { flex-wrap: nowrap; }
  #ing-table .row-actions a[href^="ingredient?id"] { display: none; }
  .table-cards td.hide-sm-cell { display: none; }
  .table-cards .cell-main { gap: 9px; }
  .table-cards .cell-main b { font-size: 13.5px; line-height: 1.25; white-space: normal; }
  .table-cards .cell-main small { font-size: 11px; max-width: none; }
  .table-cards .thumb { width: 32px; height: 32px; border-radius: 9px; }
  .table-cards .thumb-empty .i { width: 15px; height: 15px; }
  .table-cards .mv-icon { width: 30px; height: 30px; }
  .table-cards td > .pill { align-self: flex-start; }
  .table-cards .pill { height: 20px; font-size: 10.5px; padding: 0 7px; gap: 4px; }
  .table-cards .pill::before { width: 5px; height: 5px; }
  .table-cards .tag { font-size: 11px; padding: 1px 6px; }
  .table-cards .qty-cell { min-width: 0; gap: 3px; align-items: stretch; }
  .table-cards .bar { min-width: 0; height: 4px; }
  .table-cards .row-actions { gap: 6px; justify-content: flex-end; }
  .table-cards .row-actions .icon-btn { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-3); color: var(--ink-2); }
  .table-cards .row-actions .icon-btn .i { width: 15px; height: 15px; }
  .table-cards .row-actions .btn, .table-cards .btn-sm { height: 30px; font-size: 12px; padding: 0 10px; border-radius: 9px; }
  .table-cards tfoot tr { display: flex; justify-content: space-between; gap: 10px; }
  .table-cards tfoot td { background: none; }
  .table-cards tr.empty-row { display: block; }
  .table-cards tr.empty-row td { display: block; }
  .table-cards .count-input { width: 100% !important; height: 40px !important; font-size: 16px !important; }
  .table-cards input:not([type=checkbox]), .table-cards select { height: 40px; }

  /* Plain tables (no card layout): small text that wraps to fit */
  .table:not(.table-cards) { font-size: 12.5px; }
  .table:not(.table-cards) th { padding: 8px 10px; font-size: 10.5px; white-space: normal; }
  .table:not(.table-cards) td { padding: 9px 10px; }

  /* Settings → Users list */
  .user-table .row-actions .icon-btn { width: 30px; height: 30px; }
  .user-table .row-actions .btn-sm { height: 30px; font-size: 12px; padding: 0 8px; }
  .user-table td:first-child { padding-right: 4px; }

  /* Settings → Roles & permissions matrix: every role column fits */
  .matrix { table-layout: fixed; width: 100%; font-size: 12px; }
  .matrix th, .matrix td { padding: 7px 3px; white-space: normal; }
  .matrix th:first-child, .matrix td:first-child { width: 40%; padding-left: 12px; }
  .matrix th.c, .matrix td.c { width: auto; padding-left: 1px; padding-right: 1px; }
  .matrix th:first-child, .matrix td:first-child { width: 38%; }
  .matrix tbody td:first-child { font-size: 11.5px; line-height: 1.35; }
  .matrix th.c a { font-size: 9.5px; letter-spacing: 0; text-transform: none; overflow-wrap: normal; word-break: normal; display: block; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
  .matrix th small { display: none; }
  .matrix .yes .i { width: 15px; height: 15px; }
  .matrix tr.group td { padding-left: 12px; font-size: 10.5px; }
}
