/* =============================================================================
   ERP design system. Plain CSS, no build step.

   Theme   : light + dark, tokens on :root. Follows the OS unless the viewer
             picks one (stored as data-theme on <html>).
   Accent  : one accent, ocean blue. Status colours are reserved for state.
   Shape   : one rule, used everywhere. Panels 14px, controls 9px,
             badges/chips full pill. Nothing else.
   Motion  : short, eased, transform/opacity only; off under reduced motion.
============================================================================= */

:root {
  color-scheme: light;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --bg: #f4f6f9;
  --bg-grad: radial-gradient(1200px 500px at 85% -120px, rgb(57 135 229 / .07), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f8;
  --line: #e4e8ee;
  --line-strong: #d3dae3;
  --ink: #0d1524;
  --text: #273244;
  --muted: #677487;
  --faint: #95a1b2;

  --accent: #256abf;
  --accent-strong: #1c5cab;
  --accent-soft: #eaf2fc;
  --accent-ring: rgb(37 106 191 / .22);
  --on-accent: #ffffff;

  --success: #13803a; --success-soft: #e7f6ec;
  --warn: #a35a00;    --warn-soft: #fdf3e2;
  --danger: #c22f2f;  --danger-soft: #fdecec;
  --info: #256abf;    --info-soft: #eaf2fc;

  /* data-viz roles (validated palette) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
  --grid: #eceff3;

  --side: #0b1625;
  --side-2: #102036;
  --side-text: #a9b8cc;
  --side-strong: #eef3f9;
  --side-line: rgb(255 255 255 / .06);

  --r-panel: 14px;
  --r-ctl: 9px;
  --shadow-1: 0 1px 2px rgb(16 32 54 / .05);
  --shadow-2: 0 1px 2px rgb(16 32 54 / .04), 0 10px 28px -14px rgb(16 32 54 / .18);
  --shadow-pop: 0 24px 60px -12px rgb(11 22 37 / .35), 0 0 0 1px rgb(11 22 37 / .06);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --side-w: 260px;
}

/* Dark values live in one block, applied by both the OS and the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0f18; --bg-grad: radial-gradient(1200px 500px at 85% -120px, rgb(57 135 229 / .10), transparent 60%);
    --surface: #111827; --surface-2: #141c2c; --surface-3: #18223a;
    --line: #1f2a3d; --line-strong: #2a3850;
    --ink: #f2f6fb; --text: #d3dbe7; --muted: #8e9bb0; --faint: #66748a;
    --accent: #3987e5; --accent-strong: #5598e7; --accent-soft: rgb(57 135 229 / .14); --accent-ring: rgb(57 135 229 / .35);
    --success: #4ccf72; --success-soft: rgb(76 207 114 / .12);
    --warn: #f3b44c; --warn-soft: rgb(243 180 76 / .12);
    --danger: #f07474; --danger-soft: rgb(240 116 116 / .12);
    --info: #6da7ec; --info-soft: rgb(57 135 229 / .14);
    --series-1: #3987e5; --series-2: #d95926; --grid: #1c2638;
    --side: #080d16; --side-2: #0e1726;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .3);
    --shadow-2: 0 1px 2px rgb(0 0 0 / .3), 0 12px 30px -14px rgb(0 0 0 / .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f18; --bg-grad: radial-gradient(1200px 500px at 85% -120px, rgb(57 135 229 / .10), transparent 60%);
  --surface: #111827; --surface-2: #141c2c; --surface-3: #18223a;
  --line: #1f2a3d; --line-strong: #2a3850;
  --ink: #f2f6fb; --text: #d3dbe7; --muted: #8e9bb0; --faint: #66748a;
  --accent: #3987e5; --accent-strong: #5598e7; --accent-soft: rgb(57 135 229 / .14); --accent-ring: rgb(57 135 229 / .35);
  --success: #4ccf72; --success-soft: rgb(76 207 114 / .12);
  --warn: #f3b44c; --warn-soft: rgb(243 180 76 / .12);
  --danger: #f07474; --danger-soft: rgb(240 116 116 / .12);
  --info: #6da7ec; --info-soft: rgb(57 135 229 / .14);
  --series-1: #3987e5; --series-2: #d95926; --grid: #1c2638;
  --side: #080d16; --side-2: #0e1726;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .3);
  --shadow-2: 0 1px 2px rgb(0 0 0 / .3), 0 12px 30px -14px rgb(0 0 0 / .6);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--bg-grad), var(--bg); background-attachment: fixed;
  -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11";
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.2; letter-spacing: -.015em; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -.025em; }
h2 { font-size: 1rem; font-weight: 600; }
h3 { font-size: .92rem; font-weight: 600; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-3); padding: .1rem .35rem; border-radius: 6px; }
::selection { background: var(--accent-ring); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); }
.mt { margin-top: 1.25rem; } .mb { margin-bottom: 1.25rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100dvh; }
.sidebar {
  width: var(--side-w); flex-shrink: 0; position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; color: var(--side-text);
  background: linear-gradient(180deg, var(--side-2) 0%, var(--side) 42%);
  border-right: 1px solid var(--side-line); z-index: 40;
  transition: width .28s var(--ease);
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.05rem 1rem .95rem; border-bottom: 1px solid var(--side-line); min-height: 68px; }
.monogram {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; letter-spacing: .02em; color: #fff;
  background: linear-gradient(140deg, #3d8ef0 0%, #1c5cab 55%, #123e78 100%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .25), 0 6px 16px -6px rgb(57 135 229 / .6);
}
.brand-text { min-width: 0; }
.brand-name { color: var(--side-strong); font-weight: 650; font-size: .98rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.brand-sub { font-size: .72rem; color: #7f93ad; display: flex; align-items: center; gap: .35rem; }
.nav { padding: .5rem .6rem 1rem; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: #233249 transparent; }
.nav-group { margin-top: 1.05rem; }
.nav-group-title { font-size: .66rem; text-transform: uppercase; letter-spacing: .09em; color: #5f7593; padding: 0 .7rem .35rem; font-weight: 600; white-space: nowrap; }
.nav a {
  position: relative; display: flex; align-items: center; gap: .7rem; padding: .48rem .7rem; margin: 1px 0;
  border-radius: var(--r-ctl); color: var(--side-text); font-size: .875rem; font-weight: 450; white-space: nowrap;
  transition: background .18s ease, color .18s ease;
}
.nav a:hover { background: rgb(255 255 255 / .05); color: var(--side-strong); }
.nav a.active { background: rgb(57 135 229 / .16); color: #fff; font-weight: 550; }
.nav a.active::before { content: ""; position: absolute; left: -.6rem; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0; background: #5aa2f2; }
.nav a .bi { font-size: 1.05rem; width: 1.1rem; text-align: center; opacity: .85; }
.nav a.active .bi { opacity: 1; color: #7db7f6; }
.nav .count { margin-left: auto; background: #f5a524; color: #1a1300; border-radius: 999px; font-size: .68rem; padding: .05rem .45rem; font-weight: 700; }
.side-foot { padding: .75rem; border-top: 1px solid var(--side-line); }
.collapse-btn {
  width: 100%; display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; border: 0; border-radius: var(--r-ctl);
  background: transparent; color: #7f93ad; font: inherit; font-size: .8rem; cursor: pointer;
}
.collapse-btn:hover { background: rgb(255 255 255 / .05); color: var(--side-strong); }
/* Vendor credit (Bizentrix) */
.made-by {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; margin-bottom: .45rem; border-radius: var(--r-ctl);
  color: #7f93ad; text-decoration: none; font-size: .7rem; line-height: 1.3; transition: background .18s ease, color .18s ease;
}
.made-by:hover { background: rgb(255 255 255 / .05); color: var(--side-strong); }
.made-by b { display: block; font-weight: 600; color: #b8c6d8; font-size: .72rem; }
.made-by:hover b { color: #fff; }
.made-by-mark {
  flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  font-weight: 800; font-size: .8rem; color: #fff; background: linear-gradient(140deg, #4b97ee, #1c5cab);
}
.rail .made-by { justify-content: center; padding-inline: 0; }
.rail .made-by-text { display: none; }
.login-pane { position: relative; }
.login-credit { position: absolute; left: 16px; right: 16px; bottom: 1rem; margin: 0; text-align: center; font-size: .76rem; color: var(--muted); }
.login-credit a { color: var(--accent); font-weight: 600; text-decoration: none; }
.login-credit a:hover { text-decoration: underline; }

/* Collapsed rail */
.rail .sidebar { width: 72px; }
.rail .brand-text, .rail .nav-group-title, .rail .nav a span.label, .rail .nav .count, .rail .collapse-btn span { display: none; }
.rail .brand { justify-content: center; padding-inline: 0; }
.rail .nav a { justify-content: center; padding: .6rem 0; }
.rail .nav-group { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--side-line); }
.rail .collapse-btn { justify-content: center; }
.rail .collapse-btn .bi { transform: rotate(180deg); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--line);
}
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: var(--r-ctl); position: relative;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; font-size: 1.05rem;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.icon-btn:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(.96); }
.icon-btn .dot-count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #f5a524; color: #1a1300; font-size: .66rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.search-trigger {
  display: flex; align-items: center; gap: .6rem; height: 38px; min-width: 300px; padding: 0 .55rem 0 .8rem;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); color: var(--muted);
  font: inherit; font-size: .86rem; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease;
}
.search-trigger:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.search-trigger kbd, .kbd { margin-left: auto; font-family: var(--mono); font-size: .7rem; color: var(--muted); background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: .05rem .4rem; }
.entity-switch { position: relative; }
.entity-switch select {
  appearance: none; height: 38px; padding: 0 2.2rem 0 2.6rem; border-radius: var(--r-ctl); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: .86rem; cursor: pointer; min-width: 190px;
}
.entity-switch::before { content: "\F1DD"; font-family: "bootstrap-icons"; position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--accent); pointer-events: none; }
.entity-switch::after { content: "\F282"; font-family: "bootstrap-icons"; position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); font-size: .7rem; color: var(--muted); pointer-events: none; }
.user-menu { position: relative; }
.user-menu > button {
  display: flex; align-items: center; gap: .55rem; height: 38px; padding: 0 .6rem 0 .3rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .86rem; cursor: pointer;
}
.avatar { width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; font-size: .72rem; font-weight: 700; color: #fff; background: linear-gradient(140deg, #4b97ee, #1c5cab); }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; padding: .4rem; z-index: 60;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top right; pointer-events: none;
  transition: opacity .16s ease, transform .2s var(--ease);
}
.open > .dropdown { opacity: 1; transform: none; pointer-events: auto; }
.dropdown a, .dropdown button {
  display: flex; gap: .6rem; align-items: center; width: 100%; text-align: left; padding: .5rem .65rem; border-radius: var(--r-ctl);
  color: var(--text); background: none; border: 0; font: inherit; font-size: .86rem; cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-3); color: var(--ink); }
.dropdown .meta { padding: .6rem .65rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .35rem; }
.dropdown .sep { height: 1px; background: var(--line); margin: .35rem 0; }
.wrap-any { overflow-wrap: anywhere; word-break: break-all; }
.menu-wrap { position: relative; display: inline-flex; }
.menu-wrap .dropdown { min-width: 280px; left: 0; right: auto; transform-origin: top left; }
.page-head { position: relative; z-index: 20; }
.print-menu a { align-items: flex-start; }
.print-menu a .bi { margin-top: .15rem; color: var(--accent); }
.print-menu small { display: block; color: var(--muted); font-size: .76rem; margin-top: .1rem; }
.theme-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; margin: .25rem .3rem .4rem; background: var(--surface-3); border-radius: var(--r-ctl); }
.theme-seg button { justify-content: center; padding: .35rem; font-size: .78rem; border-radius: 7px; color: var(--muted); }
.theme-seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.content { padding: 1.75rem 2rem 4rem; width: 100%; max-width: 1480px; margin: 0 auto; }
.page-enter { animation: rise .45s var(--ease) both; }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head p { margin: .35rem 0 0; color: var(--muted); max-width: 70ch; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.crumb { font-size: .8rem; margin-bottom: .45rem; }
.crumb a { color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; }
.crumb a:hover { color: var(--accent); }

/* ---------- Panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-1); }
.card + .card { margin-top: 1.25rem; }
.card-body { padding: 1.25rem 1.35rem; }
.card-head { padding: 1rem 1.35rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-head h2 { display: flex; align-items: center; gap: .55rem; }
.card-head h2 .bi { color: var(--muted); font-size: 1rem; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid > .card + .card, .kpi-grid > .card + .card, .dash-grid .col > .card + .card, .doc-side > .card + .card { margin-top: 0; }
.doc-side { display: grid; gap: 1.25rem; }
.doc-layout > div { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 1.25rem; align-content: start; }
.doc-layout > div > .card + .card { margin-top: 0; }
.stat { display: flex; gap: .95rem; align-items: center; padding: 1.1rem 1.2rem; color: inherit; transition: border-color .2s ease, transform .25s var(--ease), box-shadow .25s ease; }
a.stat:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-2); color: inherit; }
.stat .icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.stat .value { font-size: 1.4rem; font-weight: 650; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: .8rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 38px; padding: 0 1rem;
  border-radius: var(--r-ctl); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; font-size: .86rem; cursor: pointer; white-space: nowrap; line-height: 1;
  box-shadow: var(--shadow-1); transition: background .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); color: var(--ink); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff) 0%, var(--accent) 100%); border-color: var(--accent-strong); color: var(--on-accent); box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset, 0 6px 16px -8px var(--accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-secondary { }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-sm { height: 30px; padding: 0 .7rem; font-size: .8rem; }
.btn-link { border: 0; background: none; box-shadow: none; color: var(--accent); padding: 0 .3rem; height: auto; }
.btn-link:hover { background: none; text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

/* ---------- Badges (pill) ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; height: 22px; padding: 0 .6rem; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; letter-spacing: .01em; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .9; }
.badge-neutral { background: var(--surface-3); color: var(--muted); }
.badge-muted { background: var(--surface-3); color: var(--faint); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge.plain::before { display: none; }
.yes { color: var(--success); } .no { color: var(--faint); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: .72rem 1rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.table thead th:first-child { border-top-left-radius: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table td a { font-weight: 550; }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--line-strong); color: var(--ink); }
.table .empty { padding: 0; }
.table-compact th, .table-compact td { padding: .5rem .9rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .bi { font-size: 1.8rem; color: var(--faint); display: block; margin-bottom: .6rem; }
.empty-state strong { color: var(--ink); display: block; font-weight: 600; margin-bottom: .2rem; }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.toolbar .input, .toolbar .select { width: auto; min-width: 170px; height: 36px; }
.toolbar .grow { flex: 1; min-width: 220px; }
.search-wrap { position: relative; flex: 1; min-width: 220px; }
.search-wrap .bi { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search-wrap .input { padding-left: 2.2rem; width: 100%; }
.result-count { margin-left: auto; font-size: .8rem; color: var(--muted); }

/* ---------- Forms ---------- */
.input, .select {
  width: 100%; height: 38px; padding: 0 .75rem; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--surface); font: inherit; font-size: .88rem; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
select[multiple].select { height: auto; background-image: none; padding: .4rem; }
.input::placeholder { color: var(--faint); }
.input:hover, .select:hover { border-color: var(--faint); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.input[disabled], .select[disabled] { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
input[type=file].input { padding: .45rem .6rem; height: auto; }
.textarea { height: auto; min-height: 84px; padding: .6rem .75rem; resize: vertical; line-height: 1.5; }
.check { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.05rem 1.25rem; }
.field label { display: block; font-weight: 550; font-size: .8rem; margin-bottom: .4rem; color: var(--ink); }
.field .help { font-size: .76rem; color: var(--muted); margin-top: .35rem; }
.field .errors { color: var(--danger); font-size: .78rem; margin-top: .35rem; display: flex; gap: .3rem; align-items: center; }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.field.wide { grid-column: 1 / -1; }
.field-check { display: flex; align-items: flex-start; gap: .6rem; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface-2); align-self: end; min-height: 38px; flex-wrap: wrap; }
.field-check label { margin: 0; font-weight: 550; cursor: pointer; }
.field-check .help { flex-basis: 100%; margin: 0 0 0 1.7rem; }
.req { color: var(--danger); }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; padding-top: 1.1rem; margin-top: 1.25rem; border-top: 1px solid var(--line); }
.form-errors { background: var(--danger-soft); color: var(--danger); border-radius: var(--r-ctl); padding: .7rem .9rem; margin-bottom: 1rem; font-weight: 500; }
/* Radio groups and checkbox lists, rendered by Django as nested divs. */
.choice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem; }
.choice-list.multi { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .45rem; }
.choice-list > div { margin: 0; }
.choice-list label {
  display: flex !important; align-items: center; gap: .65rem; margin: 0 !important; height: 100%;
  padding: .7rem .85rem; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--text); font-weight: 450 !important; font-size: .86rem; line-height: 1.35;
  cursor: pointer; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.choice-list.multi label { padding: .55rem .75rem; }
.choice-list label:hover { border-color: var(--faint); }
.choice-list input { width: 17px; height: 17px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.choice-list label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); box-shadow: 0 0 0 3px var(--accent-ring); }
.choice-list label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.field.has-error .choice-list label { border-color: var(--danger); }

/* Line editor */
.lines th { white-space: nowrap; }
.lines td { padding: .5rem .5rem; vertical-align: top; }
.lines td:first-child { padding-left: 1rem; }
.lines .input, .lines .select { min-width: 84px; height: 36px; }
.lines td.item-cell { min-width: 260px; }
.lines td.desc-cell { min-width: 170px; }
.lines .line-info { font-size: .72rem; color: var(--muted); margin-top: .3rem; min-height: 1em; }
.lines tr.deleted td { opacity: .35; }
.lines .line-amount { font-weight: 600; color: var(--ink); padding-top: 1rem; }
.lines .errors { color: var(--danger); font-size: .75rem; margin-top: .25rem; }
.lines tbody tr:hover { background: transparent; }
.totals { margin-left: auto; min-width: 300px; border-collapse: collapse; }
.totals td { padding: .38rem .2rem; color: var(--muted); }
.totals td.num { color: var(--ink); font-weight: 550; }
.totals tr.grand td { font-weight: 700; font-size: 1.1rem; color: var(--ink); border-top: 1px solid var(--line-strong); padding-top: .7rem; }
.add-line { border-style: dashed; box-shadow: none; }

/* Detail */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.1rem 1.5rem; margin: 0; }
.kv dt { font-size: .72rem; color: var(--muted); font-weight: 500; }
.kv dd { margin: .25rem 0 0; color: var(--ink); font-weight: 550; }
.doc-title { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.doc-side { position: sticky; top: 84px; }
.summary-total { font-size: 1.9rem; font-weight: 700; color: var(--ink); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

/* Status stepper */
.stepper { display: flex; align-items: center; gap: 0; padding: 1rem 1.35rem; overflow-x: auto; }
.step { display: flex; align-items: center; gap: .55rem; white-space: nowrap; font-size: .82rem; color: var(--faint); font-weight: 500; }
.step .knob { width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; border: 1.5px solid var(--line-strong); background: var(--surface); font-size: .8rem; color: var(--faint); transition: all .3s var(--ease); }
.step.done { color: var(--text); }
.step.done .knob { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.current { color: var(--ink); font-weight: 650; }
.step.current .knob { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 5px var(--accent-ring); }
.step.halt .knob { background: var(--danger); border-color: var(--danger); color: #fff; }
.step.halt { color: var(--danger); font-weight: 650; }
.step-line { flex: 1; min-width: 28px; height: 2px; margin: 0 .75rem; background: var(--line); border-radius: 2px; }
.step-line.done { background: var(--accent); }

/* Messages and toasts */
.messages { margin-bottom: 1rem; display: grid; gap: .5rem; }
.msg { padding: .7rem .95rem; border-radius: var(--r-ctl); display: flex; gap: .6rem; align-items: flex-start; border: 1px solid; font-weight: 500; }
.msg-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.msg-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.msg-warning { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.msg-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.toasts { position: fixed; top: 78px; right: 1.25rem; z-index: 80; display: grid; gap: .6rem; width: min(400px, calc(100vw - 2rem)); }
.toast {
  display: flex; gap: .75rem; align-items: flex-start; padding: .85rem .95rem; border-radius: var(--r-panel);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); color: var(--ink);
  animation: toast-in .45s var(--ease) both; font-size: .86rem; font-weight: 500;
}
.toast .bi { font-size: 1.1rem; margin-top: .05rem; }
.toast.success .bi { color: var(--success); } .toast.error .bi { color: var(--danger); }
.toast.warning .bi { color: var(--warn); } .toast.info .bi { color: var(--info); }
.toast .close { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0; }
.toast.leaving { animation: toast-out .3s ease forwards; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: var(--r-ctl); padding: .75rem .95rem; display: flex; gap: .55rem; align-items: center; font-weight: 500; }

/* Pagination */
.pagination { display: flex; gap: .5rem; align-items: center; justify-content: space-between; padding: .8rem 1rem; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); }
.pagination > span:last-child { display: flex; align-items: center; gap: .5rem; }

/* History timeline */
.history { list-style: none; margin: 0; padding: 0; position: relative; }
.history li { position: relative; padding: 0 0 1.1rem 1.6rem; }
.history li::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: -4px; width: 1.5px; background: var(--line); }
.history li:last-child::before { display: none; }
.history li::after { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 999px; background: var(--surface); border: 2px solid var(--accent); }
.history .when { color: var(--muted); font-size: .76rem; margin-top: .1rem; }
.changes { margin: .45rem 0 0; font-size: .78rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: .5rem .65rem; display: grid; gap: .15rem; }
.changes span.old { text-decoration: line-through; color: var(--faint); }
.changes b { color: var(--text); font-weight: 550; }
details.changes-toggle summary { cursor: pointer; color: var(--accent); font-size: .78rem; list-style: none; }
details.changes-toggle summary::-webkit-details-marker { display: none; }

/* Permission matrix */
.matrix th.action { text-align: center; font-size: .64rem; }
.matrix td.cell { text-align: center; }
.matrix td:first-child { min-width: 220px; font-weight: 500; color: var(--ink); }
.matrix tr.group td { background: var(--surface-2); font-weight: 650; font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

/* Reason dialog and command palette */
dialog { color: var(--text); }
dialog.reason { border: 1px solid var(--line); border-radius: var(--r-panel); padding: 0; width: min(460px, 92vw); background: var(--surface); box-shadow: var(--shadow-pop); }
dialog.reason[open] { animation: pop .3s var(--ease); }
dialog::backdrop { background: rgb(8 13 22 / .5); backdrop-filter: blur(3px); }
dialog.reason form { padding: 1.4rem; }
.palette { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(640px, 94vw); margin-top: 12vh; background: var(--surface); box-shadow: var(--shadow-pop); overflow: hidden; }
.palette[open] { animation: pop .28s var(--ease); }
.palette-search { display: flex; align-items: center; gap: .7rem; padding: 0 1.1rem; border-bottom: 1px solid var(--line); }
.palette-search .bi { color: var(--muted); font-size: 1.05rem; }
.palette-search input { flex: 1; height: 56px; border: 0; outline: 0; background: transparent; font: inherit; font-size: 1rem; color: var(--ink); }
.palette-list { max-height: 380px; overflow-y: auto; padding: .4rem; }
.palette-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: .65rem .75rem .3rem; font-weight: 600; }
.palette-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: var(--r-ctl); color: var(--text); cursor: pointer; }
.palette-item .bi { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-3); color: var(--muted); }
.palette-item.on { background: var(--accent-soft); color: var(--ink); }
.palette-item.on .bi { background: var(--accent); color: #fff; }
.palette-item .hint { margin-left: auto; font-size: .72rem; color: var(--faint); }
.palette-foot { display: flex; gap: 1rem; padding: .6rem 1rem; border-top: 1px solid var(--line); font-size: .72rem; color: var(--muted); background: var(--surface-2); }
.palette-empty { padding: 2rem; text-align: center; color: var(--muted); }

/* ---------- Dashboard ---------- */
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.hello h1 { font-size: 1.75rem; }
.hello p { margin: .3rem 0 0; color: var(--muted); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; }
.kpi { padding: 1.15rem 1.25rem; display: flex; flex-direction: column; gap: .7rem; color: inherit; transition: transform .3s var(--ease), box-shadow .3s ease, border-color .2s ease; }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); color: inherit; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .82rem; font-weight: 500; }
.kpi-top .bi { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 1rem; }
.kpi-value { font-size: 1.85rem; font-weight: 700; color: var(--ink); letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.delta { display: inline-flex; align-items: center; gap: .2rem; font-weight: 650; border-radius: 999px; padding: .05rem .45rem; font-size: .74rem; }
.delta.up { color: var(--success); background: var(--success-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 1.25rem; margin-top: 1.25rem; }
.dash-grid > .col { display: grid; gap: 1.25rem; align-content: start; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.15rem 1.35rem .35rem; }
.chart-head .big { font-size: 1.6rem; font-weight: 700; color: var(--ink); letter-spacing: -.03em; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.chart-wrap { padding: .25rem 1rem .5rem .6rem; position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { transition: opacity .2s ease; }
.chart .hit { fill: transparent; cursor: default; }
.chart .grp:hover .bar { opacity: 1; }
.chart:hover .grp .bar { opacity: .45; }
.chart:hover .grp:hover .bar { opacity: 1; }
.chart .grp:hover .hover-band { fill: var(--surface-3); }
.chart .hover-band { fill: transparent; transition: fill .15s ease; }
@media (prefers-reduced-motion: no-preference) {
  .chart .bar { transform-box: fill-box; transform-origin: bottom; animation: grow .8s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms); }
}
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--text); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-tip { position: fixed; z-index: 90; pointer-events: none; background: var(--ink); color: var(--surface); padding: .4rem .6rem; border-radius: 8px; font-size: .78rem; font-weight: 550; white-space: nowrap; box-shadow: var(--shadow-pop); opacity: 0; transform: translate(-50%, -120%); transition: opacity .12s ease; }
.chart-tip.on { opacity: 1; }
details.chart-table { padding: 0 1.35rem 1rem; }
details.chart-table summary { cursor: pointer; font-size: .78rem; color: var(--muted); }
details.chart-table table { margin-top: .5rem; font-size: .8rem; }
.health-bar { display: flex; gap: 2px; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-3); margin: .5rem 0 1rem; }
.health-bar span { display: block; height: 100%; min-width: 0; transition: width .8s var(--ease); }
.health-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.health-legend div { padding: .65rem .75rem; border-radius: var(--r-ctl); background: var(--surface-2); border: 1px solid var(--line); }
.health-legend b { display: block; font-size: 1.25rem; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.health-legend small { display: flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .74rem; font-weight: 500; }
.health-legend small .bi { font-size: .8rem; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; padding: 1rem 1.15rem 1.15rem; }
.quick { display: flex; flex-direction: row; align-items: center; gap: .6rem; padding: .85rem; border: 1px solid var(--line); border-radius: var(--r-ctl); color: var(--ink); font-weight: 550; font-size: .82rem; background: var(--surface-2); transition: border-color .2s ease, background .2s ease, transform .25s var(--ease); }
.quick .bi { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface); color: var(--accent); border: 1px solid var(--line); font-size: 1rem; transition: background .2s ease, color .2s ease; }
.quick:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); transform: translateY(-1px); }
.quick:hover .bi { background: var(--accent); color: #fff; border-color: var(--accent); }
.list-rows { list-style: none; margin: 0; padding: .35rem .6rem .6rem; }
.list-rows li a, .list-rows li > div { display: flex; align-items: center; gap: .75rem; padding: .6rem .6rem; border-radius: var(--r-ctl); color: var(--text); }
.list-rows li a:hover { background: var(--surface-2); color: var(--ink); }
.list-rows .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex-shrink: 0; }
.list-rows .main-line { color: var(--ink); font-weight: 550; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-rows .sub-line { color: var(--muted); font-size: .76rem; }
.list-rows .grow { min-width: 0; flex: 1; }
.counts-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.counts-row a { display: inline-flex; gap: .45rem; align-items: center; padding: .4rem .75rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: .8rem; font-weight: 500; }
.counts-row a b { color: var(--ink); }
.counts-row a:hover { border-color: var(--accent); color: var(--ink); }
.approval-card { border-color: color-mix(in srgb, #f5a524 45%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, #f5a524 7%, var(--surface)), var(--surface)); }

/* ---------- Login ---------- */
.login-split { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.login-art {
  position: relative; overflow: hidden; color: #eaf2fc; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(900px 500px at 15% 110%, rgb(34 211 238 / .28), transparent 60%),
    radial-gradient(700px 520px at 95% -10%, rgb(57 135 229 / .55), transparent 60%),
    linear-gradient(160deg, #0b1a33 0%, #0b1625 55%, #07101c 100%);
}
.login-art::before {
  content: ""; position: absolute; inset: -20%; opacity: .5;
  background: repeating-radial-gradient(circle at 30% 120%, transparent 0 38px, rgb(125 183 246 / .08) 39px 40px);
  animation: ripple 18s linear infinite;
}
.login-art > * { position: relative; }
.login-art .monogram { width: 44px; height: 44px; border-radius: 12px; font-size: 1rem; }
.login-art h2 { color: #fff; font-size: 2.3rem; font-weight: 650; letter-spacing: -.035em; line-height: 1.1; max-width: 14ch; }
.login-art p { color: #a9c3e3; max-width: 42ch; font-size: .98rem; }
.login-points { display: grid; gap: .7rem; margin-top: 1.8rem; }
.login-points div { display: flex; gap: .7rem; align-items: center; color: #d5e4f6; font-size: .9rem; }
.login-points .bi { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgb(255 255 255 / .08); border: 1px solid rgb(255 255 255 / .1); color: #7db7f6; }
.login-pane { display: grid; place-items: center; padding: 2rem 16px; background: var(--bg-grad), var(--bg); }
.login-box { width: min(380px, 100%); }
.login-box h1 { font-size: 1.7rem; margin-bottom: .35rem; }
.login-box .field { margin-bottom: 1rem; }
.login-box .btn { width: 100%; height: 44px; font-size: .92rem; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 2.6rem; }
.pw-toggle { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; width: 32px; height: 32px; border-radius: 7px; }
.pw-toggle:hover { background: var(--surface-3); color: var(--ink); }

/* ---------- Keyframes ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes ripple { from { transform: scale(1); } to { transform: scale(1.18); } }
.stagger > * { animation: rise .5s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: .05s; } .stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .15s; } .stagger > *:nth-child(5) { animation-delay: .2s; }
.stagger > *:nth-child(n+6) { animation-delay: .25s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .doc-layout { grid-template-columns: 1fr; }
  .doc-side { position: static; }
  .search-trigger { min-width: 220px; }
}
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .3s var(--ease); box-shadow: none; width: var(--side-w) !important; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 60px rgb(0 0 0 / .4); }
  .rail .brand-text, .rail .nav-group-title, .rail .nav a span.label { display: initial; }
  .menu-toggle { display: inline-grid; }
  .collapse-btn { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 1.25rem 16px 3rem; }
  .topbar { padding: 0 16px; }
  .search-trigger { min-width: 0; width: 38px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .entity-switch select { min-width: 0; max-width: 160px; }
  .user-menu .user-name, .user-menu .bi-chevron-down { display: none; }
  .login-split { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health-legend { grid-template-columns: 1fr; }
  .page-head .actions { width: 100%; }
}
@media print {
  .sidebar, .topbar, .toasts { display: none; }
}
.doc-side > .mt, .doc-layout > div > .mt { margin-top: 0; }
.doc-lines td:nth-child(2) { min-width: 220px; font-weight: 500; color: var(--ink); }

/* Searchable dropdown (progressive enhancement of a native select) */
.combo { position: relative; }
.combo-native { position: absolute !important; opacity: 0; pointer-events: none; width: 1px !important; height: 1px !important; padding: 0 !important; border: 0 !important; bottom: 0; left: 0; }
.combo-input { padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; text-overflow: ellipsis; }
/* The list lives on <body> with fixed coordinates set by app.js, above every
   scrolling or clipping container. Above the sticky top bar (30), below dialogs. */
.combo-list { position: fixed; z-index: 75; max-height: 300px; overflow-y: auto; overscroll-behavior: contain; padding: .3rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); box-shadow: var(--shadow-pop); display: none; }
.combo-list.open { display: block; animation: pop .18s var(--ease); }
.combo-item { padding: .5rem .65rem; border-radius: 7px; cursor: pointer; font-size: .86rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-item.on { background: var(--accent-soft); color: var(--ink); }
.combo-item.selected { font-weight: 600; }
.combo-add { color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); margin-top: .25rem; border-radius: 0 0 7px 7px; }
.combo-empty { padding: .6rem .65rem; color: var(--muted); font-size: .84rem; }
.party-info { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .45rem; font-size: .78rem; color: var(--muted); min-height: 1.2em; }
.party-info .sep { width: 4px; height: 4px; border-radius: 999px; background: var(--line-strong); }
.party-info .due { color: var(--danger); font-weight: 600; }
.party-info .adv { color: var(--success); font-weight: 600; }

/* Layout guards: grid and flex children may shrink below their content's
   natural width (charts, long names), so nothing pushes the page sideways. */
.dash-grid > .col, .kpi-grid > *, .grid > *, .doc-layout > *, .form-grid > * { min-width: 0; }
.dash-grid > .col { grid-template-columns: minmax(0, 1fr); }
.chart { max-width: 100%; }
.chart-head > * { min-width: 0; }
@media (max-width: 1200px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .stepper { gap: 0; padding: .85rem 1rem; }
  .step { font-size: .74rem; gap: .35rem; }
  .step .knob { width: 22px; height: 22px; font-size: .7rem; }
  .step-line { min-width: 10px; margin: 0 .4rem; }
  .step.todo .step-label, .step.done .step-label { display: none; }
  .hello h1 { font-size: 1.4rem; }
  .kpi-value { font-size: 1.55rem; }
  .page-head h1 { font-size: 1.35rem; }
  .doc-title h1 { word-break: break-word; }
}
.list-rows .main-line, .list-rows .sub-line { display: block; }
.list-rows li a, .list-rows li > div { min-width: 0; }

/* Named column layouts (instead of inline styles) so they collapse on phones. */
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpi-grid.kpi-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.health-legend.legend-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.form-actions, .page-head .actions { flex-wrap: wrap; }
@media (max-width: 960px) {
  .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
  .health-legend.legend-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .kpi-grid.kpi-2 { grid-template-columns: minmax(0, 1fr); }
  .health-legend.legend-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 640px) {
  .login-credit { position: static; margin-top: 2rem; }
}

/* ---------------------------------------------------------------- Counter screens (Quick bill, Payment in) */
.pos-head { margin-bottom: 1rem; }
.pos-keys { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .8rem; }
.pos-keys kbd, .pos-save kbd, .pos-next kbd, .pos-hit-empty kbd {
  font-family: var(--mono); font-size: .7rem; background: var(--surface-3); border: 1px solid var(--line); border-radius: 5px; padding: .02rem .35rem; color: var(--text);
}
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.pos-main { display: grid; gap: 1rem; min-width: 0; }
.pos-card { padding: 1rem 1.1rem; }
.pos-label { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .74rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: .4rem; }
.pos-find { position: relative; display: flex; gap: .5rem; }
.pos-search { position: relative; flex: 1; min-width: 0; }
.pos-search > .bi { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.pos-search .input { padding-left: 2.4rem; height: 46px; font-size: 1rem; }
.pos .input.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; max-height: 360px; overflow: auto; padding: .3rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-pop);
}
.pos-hit { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .55rem .7rem; border-radius: var(--r-ctl); cursor: pointer; font-size: .9rem; }
.pos-hit.on, .pos-hit:hover { background: var(--accent-soft); }
.pos-hit-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 550; }
.pos-hit-side { flex: none; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.pos-hit-empty { padding: .7rem; color: var(--muted); font-size: .88rem; }
.pos-due { color: var(--danger); font-weight: 650; }
.pos-adv { color: var(--success); font-weight: 650; }
.pos-ok { color: var(--success); }
.pos-picked { display: flex; align-items: center; gap: .8rem; padding: .35rem 0; }
.pos-avatar { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 750; color: #fff; background: linear-gradient(140deg, #4b97ee, #1c5cab); font-size: 1.05rem; }
.pos-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pos-who strong { font-size: 1.05rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-bal { font-size: .9rem; white-space: nowrap; }
.pos-bal span { padding: .2rem .55rem; border-radius: 999px; background: var(--surface-3); }
.pos-note { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; margin-top: .55rem; font-size: .82rem; color: var(--muted); }
.pos-note .sep { width: 1px; height: 12px; background: var(--line); }
.pos-new { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: .5rem; align-items: center; margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--line); }
.pos-new[hidden], .pos-find[hidden], .pos-picked[hidden], .pos-note[hidden] { display: none; }
.pos-new-title { grid-column: 1 / -1; font-weight: 600; font-size: .88rem; color: var(--ink); }
.pos-new .errors { grid-column: 1 / -1; color: var(--danger); font-size: .82rem; }
.pos-entry { display: grid; grid-template-columns: minmax(0, 1fr) 100px 120px auto; gap: .6rem; align-items: end; }
.pos-entry .pos-item-find { flex-direction: column; gap: 0; }
.pos-entry > div > .input { height: 46px; font-size: 1rem; }
.pos-add .btn { height: 46px; padding-inline: 1.1rem; }
.pos-item-info { margin-top: .5rem; min-height: 1.2em; }
.pos-lines-card { padding: 0; overflow: hidden; }
.pos-lines td { vertical-align: middle; }
.pos-lines tr.flash td { animation: posflash 1s ease; }
@keyframes posflash { from { background: var(--accent-soft); } to { background: transparent; } }
.pos-cell { width: 84px; height: 34px; text-align: right; padding: 0 .5rem; font-variant-numeric: tabular-nums; }
.pos-cell[readonly] { background: var(--surface-3); color: var(--muted); }
.pos-del { width: 32px; height: 32px; }
.pos-empty { padding: 2.2rem 1rem; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.pos-empty[hidden] { display: none; }
.pos-empty .bi { font-size: 1.8rem; }
.pos-side { position: sticky; top: 76px; display: grid; gap: .6rem; }
.pos-summary { display: grid; gap: .35rem; }
.pos-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .9rem; font-variant-numeric: tabular-nums; }
.pos-date { width: auto; height: 34px; padding: 0 .5rem; }
.pos-total { display: flex; justify-content: space-between; align-items: baseline; margin: .45rem 0 .2rem; padding: .7rem .85rem; border-radius: var(--r-ctl); background: var(--accent-soft); color: var(--accent-strong); }
.pos-total strong { font-size: 1.9rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pos-modes { display: flex; flex-wrap: wrap; gap: .35rem; }
.pos-modes button {
  flex: 1 1 auto; padding: .45rem .55rem; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; font-size: .82rem; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.pos-modes button:hover { border-color: var(--line-strong); }
.pos-modes button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pos-received { height: 50px; font-size: 1.35rem; font-weight: 650; }
.pos-received:disabled { opacity: .55; }
.pos-pay-note { min-height: 1.3em; font-size: .86rem; color: var(--muted); }
.pos-pay-note.change { color: var(--warn); }
.pos-pay-note.change strong { font-size: 1.1rem; }
.pos-pay-note.credit { color: var(--danger); }
.pos-pay-note.paid { color: var(--success); }
.pos-pay-note.bad { color: var(--danger); font-weight: 600; }
.pos-check { display: flex; align-items: center; gap: .5rem; font-size: .86rem; cursor: pointer; }
.pos-check[hidden] { display: none; }
.pos-more summary { cursor: pointer; font-size: .82rem; color: var(--muted); padding: .3rem 0; }
.pos-more .input { margin-top: .4rem; }
.pos-error { padding: .6rem .75rem; border-radius: var(--r-ctl); background: var(--danger-soft); color: var(--danger); font-size: .86rem; }
.pos-error[hidden] { display: none; }
.pos-save { height: 52px; font-size: 1rem; margin-top: .4rem; justify-content: center; gap: .5rem; }
.pos-save kbd { background: rgb(255 255 255 / .18); border-color: rgb(255 255 255 / .3); color: inherit; }
.pos-save.busy { opacity: .7; pointer-events: none; }
.pos-last { text-align: center; }
.pos-print-frame { position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0; visibility: hidden; }
.pos-done {
  width: min(420px, calc(100vw - 32px)); padding: 1.6rem 1.5rem 1.3rem; text-align: center; border: 1px solid var(--line);
  border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
}
.pos-done::backdrop { background: rgb(8 15 30 / .45); backdrop-filter: blur(2px); }
.pos-done-icon { width: 56px; height: 56px; margin: 0 auto .7rem; border-radius: 999px; display: grid; place-items: center; font-size: 1.7rem; color: #fff; background: var(--success); }
.pos-done h2 { margin: 0 0 .25rem; font-size: 1.2rem; color: var(--ink); }
.pos-done p { margin: .2rem 0; }
.pos-done-change { margin: .7rem 0; padding: .6rem; border-radius: var(--r-ctl); background: var(--warn-soft); color: var(--warn); font-size: 1rem; }
.pos-done-change[hidden] { display: none; }
.pos-done-change strong { font-size: 1.4rem; }
.pos-done-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin: 1rem 0 .7rem; }
.pos-next { width: 100%; height: 48px; justify-content: center; gap: .5rem; }
.pos-next kbd { background: rgb(255 255 255 / .18); border-color: rgb(255 255 255 / .3); color: inherit; }
.topbar-bill { white-space: nowrap; }
@media (max-width: 1100px) { .pos { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 900px) {
  .pos { grid-template-columns: minmax(0, 1fr); }
  .pos-side { position: static; }
}
@media (max-width: 640px) {
  .pos-entry { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pos-entry .pos-item-find { grid-column: 1 / -1; }
  .pos-add { grid-column: 1 / -1; } .pos-add .btn { width: 100%; justify-content: center; }
  .pos-new { grid-template-columns: minmax(0, 1fr); }
  .pos-find { flex-wrap: wrap; } .pos-find > .btn { width: 100%; justify-content: center; }
  .pos-keys { display: none; }
  .pos-picked { flex-wrap: wrap; }
  .topbar-bill span { display: none; }
}
