/* ==========================================================================
   Smartcomputerske business apps — design system
   One stylesheet for both sites; each site sets --accent on <html>.
   Layout: sidebar (desktop) -> icon rail (tablet) -> bottom tabs (phone).
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-var.260c81a4759b.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-var-italic.0a81fe197e0d.woff2") format("woff2");
  font-weight: 100 900; font-style: italic; font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --accent: #1565d8;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --surface-3: #f1f0ec;
  --hover: rgba(17, 17, 16, .045);
  --border: #e7e6e0;
  --border-strong: #d6d5ce;
  --text: #121211;
  --text-2: #52514e;
  --text-3: #85847e;
  --accent-ink: #ffffff;
  --accent-weak: color-mix(in oklab, var(--accent) 10%, var(--surface));
  --accent-line: color-mix(in oklab, var(--accent) 35%, var(--surface));
  --accent-text: color-mix(in oklab, var(--accent) 88%, black);
  --good: #0ca30c;  --good-text: #0b6b12; --good-weak: #e7f6e7;
  --warn: #f2a60c;  --warn-text: #8a5300; --warn-weak: #fdf3dc;
  --bad: #d03b3b;   --bad-text: #b02727;  --bad-weak: #fbe9e9;
  --violet: #4a3aa7; --violet-weak: #ecebf8;
  --shadow-sm: 0 1px 2px rgba(16, 16, 15, .05);
  --shadow: 0 1px 2px rgba(16, 16, 15, .05), 0 4px 16px rgba(16, 16, 15, .06);
  --shadow-lg: 0 10px 40px rgba(16, 16, 15, .16), 0 2px 8px rgba(16, 16, 15, .08);
  --ring: 0 0 0 3px color-mix(in oklab, var(--accent) 28%, transparent);
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px;
  --sidebar: 248px; --rail: 68px; --topbar: 58px; --tabbar: 64px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  /* chart tokens (dataviz reference palette) */
  --chart-surface: var(--surface);
  --grid: #ecebe5; --axis: #c3c2b7;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0d; --surface: #181817; --surface-2: #1e1e1c; --surface-3: #262624;
    --hover: rgba(255, 255, 255, .055);
    --border: #2b2b29; --border-strong: #3a3a37;
    --text: #f4f4f2; --text-2: #c3c2b7; --text-3: #8f8e88;
    --accent-weak: color-mix(in oklab, var(--accent) 20%, var(--surface));
    --accent-line: color-mix(in oklab, var(--accent) 50%, var(--surface));
    --accent-text: color-mix(in oklab, var(--accent) 55%, white);
    --good-text: #4cc94c; --good-weak: #12301a;
    --warn-text: #f5bd4f; --warn-weak: #33270e;
    --bad-text: #f07a7a; --bad-weak: #3a1717;
    --violet: #9085e9; --violet-weak: #24203f;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
    --grid: #2a2a28; --axis: #3d3d3a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0d; --surface: #181817; --surface-2: #1e1e1c; --surface-3: #262624;
  --hover: rgba(255, 255, 255, .055);
  --border: #2b2b29; --border-strong: #3a3a37;
  --text: #f4f4f2; --text-2: #c3c2b7; --text-3: #8f8e88;
  --accent-weak: color-mix(in oklab, var(--accent) 20%, var(--surface));
  --accent-line: color-mix(in oklab, var(--accent) 50%, var(--surface));
  --accent-text: color-mix(in oklab, var(--accent) 55%, white);
  --good-text: #4cc94c; --good-weak: #12301a;
  --warn-text: #f5bd4f; --warn-weak: #33270e;
  --bad-text: #f07a7a; --bad-weak: #3a1717;
  --violet: #9085e9; --violet-weak: #24203f;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
  --grid: #2a2a28; --axis: #3d3d3a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar) + 12px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 120ms; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 60ms; }
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.012em; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
p { margin: 0 0 .75em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
small, .small { font-size: 12.5px; }
/* references (batch IDs, SKUs) in Inter with fixed-width, slashed-zero figures: a system
   monospace falls back to Courier on Windows */
code, .mono { font-family: var(--font); font-feature-settings: "tnum", "zero", "cv11"; letter-spacing: .01em; }
pre, .code { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--text-3); }
.soft { color: var(--text-2); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.good { color: var(--good-text); } .bad { color: var(--bad-text); } .warn { color: var(--warn-text); }
.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; border-radius: 4px; }
::selection { background: color-mix(in oklab, var(--accent) 25%, transparent); }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon.sm { width: 15px; height: 15px; vertical-align: -2px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- app shell ---------- */
.app { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  display: flex; flex-direction: column; background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; min-height: var(--topbar); color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 65%, #000));
  color: #fff; font-weight: 750; font-size: 15px; letter-spacing: -.02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), var(--shadow-sm);
}
.brand-text { min-width: 0; line-height: 1.15; }
.brand-text b { display: block; font-size: 14.5px; font-weight: 680; letter-spacing: -.01em; }
.brand-text span { display: block; font-size: 11.5px; color: var(--text-3); }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; scrollbar-width: thin; }
.nav-section { margin-top: 14px; }
.nav-section-title { padding: 0 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 7px 10px; margin: 1px 0;
  border-radius: 8px; color: var(--text-2); font-weight: 500; font-size: 13.5px; position: relative;
}
.nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-weak); color: var(--accent-text); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a .icon { color: inherit; opacity: .9; }
.nav .count { margin-left: auto; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); }
.nav .count.warn { background: var(--warn-weak); color: var(--warn-text); }
.nav .count.bad { background: var(--bad-weak); color: var(--bad-text); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; color: var(--text); }
.me:hover { background: var(--hover); text-decoration: none; }
.me-text { min-width: 0; line-height: 1.2; }
.me-text b { display: block; font-weight: 600; font-size: 13px; }
.me-text span { display: block; font-size: 11.5px; color: var(--text-3); }

.main { margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar);
  display: flex; align-items: center; gap: 10px; padding: 0 24px;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent; transition: border-color .15s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-title { display: none; font-weight: 640; font-size: 15px; min-width: 0; }
.search-trigger {
  flex: 0 1 440px; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-3);
  font: inherit; cursor: pointer; box-shadow: var(--shadow-sm); text-align: left;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-trigger span { flex: 1; }
kbd, .kbd { font: 600 11px/1 var(--font); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); }
.topbar-spacer { flex: 1; }
.topbar .btn-icon { position: relative; }
.pip { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; border: 2px solid var(--bg); box-sizing: content-box; }

.content { padding: 20px 28px 48px; width: 100%; max-width: 1480px; margin: 0 auto; flex: 1; }
.content.narrow { max-width: 920px; }
.content.medium { max-width: 1180px; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin: 4px 0 20px; }
.page-head-main { flex: 1 1 320px; min-width: 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-3); }
.crumbs a:hover { color: var(--text); }
.crumbs .icon { width: 13px; height: 13px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-sub { color: var(--text-2); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.page-sub .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  --b: var(--border); display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--b);
  background: var(--surface); color: var(--text); font: 550 13.5px/1 var(--font);
  cursor: pointer; white-space: nowrap; text-decoration: none !important; user-select: none;
  box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: 0 1px 2px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 88%, black); border-color: transparent; }
.btn-danger { color: var(--bad-text); }
.btn-danger:hover { background: var(--bad-weak); border-color: color-mix(in oklab, var(--bad) 40%, var(--surface)); }
.btn-danger.solid { background: var(--bad); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 11px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }
.btn .icon { width: 16px; height: 16px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 9px 0 0 9px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 9px 9px 0; }
.btn-group .btn.on { background: var(--accent-weak); color: var(--accent-text); border-color: var(--accent-line); z-index: 1; }
.htmx-request .btn-spin, .btn.htmx-request { opacity: .7; pointer-events: none; }

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 0; min-height: 48px; flex-wrap: wrap; }
.card-head.ruled { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-title { font-size: 14.5px; font-weight: 640; display: flex; align-items: center; gap: 8px; }
.card-head .sub { color: var(--text-3); font-size: 12.5px; }
.card-head .tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 14px 18px 18px; }
.card-body.flush { padding: 0; }
.card-body.tight { padding: 10px 18px 14px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card + .card, .stack > * + * { margin-top: 16px; }
.grid > .card + .card, .grid > * + .card, .grid > .card + * { margin-top: 0; }
.stack-sm > * + * { margin-top: 8px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid-main-wide { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.span-2 { grid-column: span 2; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* ---------- stat tiles ---------- */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px 12px; box-shadow: var(--shadow-sm); min-width: 0; position: relative; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
a.stat:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow); }
.stat-label { font-size: 12.5px; color: var(--text-2); font-weight: 520; display: flex; align-items: center; gap: 6px; }
.stat-label .icon { width: 15px; height: 15px; color: var(--text-3); }
.stat-value { font-size: 24px; font-weight: 660; letter-spacing: -0.02em; line-height: 1.2; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value small { font-size: 13px; font-weight: 560; color: var(--text-3); letter-spacing: 0; margin-right: 3px; }
.stat-foot { font-size: 12px; color: var(--text-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-height: 18px; }
.delta { font-weight: 620; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--good-text); } .delta.down { color: var(--bad-text); } .delta.flat { color: var(--text-3); }
.delta.up.inverse { color: var(--bad-text); } .delta.down.inverse { color: var(--good-text); }
.stat .spark { position: absolute; right: 12px; bottom: 12px; width: 76px; height: 26px; }
.hero-figure { font-size: 44px; font-weight: 680; letter-spacing: -0.03em; line-height: 1.05; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 560; white-space: nowrap; background: var(--surface-3); color: var(--text-2); line-height: 1; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge-good { background: var(--good-weak); color: var(--good-text); }
.badge-warn { background: var(--warn-weak); color: var(--warn-text); }
.badge-bad { background: var(--bad-weak); color: var(--bad-text); }
.badge-info, .badge-accent { background: var(--accent-weak); color: var(--accent-text); }
.badge-violet { background: var(--violet-weak); color: var(--violet); }
.badge-mute { background: var(--surface-3); color: var(--text-2); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 7px; border: 1px solid var(--border); font-size: 12px; color: var(--text-2); background: var(--surface); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-weight: 580; font-size: 12px; color: var(--text-2); padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--hover); }
.table tr[data-href] { cursor: pointer; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.min, .table th.min { width: 1%; white-space: nowrap; }
.table tfoot td { font-weight: 640; background: var(--surface-2); border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table .cell-main { font-weight: 560; color: var(--text); }
.table .cell-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.table a.cell-main:hover { text-decoration: underline; }
.table.compact td { padding: 7px 12px; } .table.compact th { padding: 7px 12px; }
.table input.input, .table select.input { height: 32px; font-size: 13px; }
.card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: 18px; }
.card > .table-wrap .table th:last-child, .card > .table-wrap .table td:last-child { padding-right: 18px; }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--r-lg); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--r-lg); }
.th-sort { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.th-sort:hover { color: var(--text); text-decoration: none; }
.sort-ind { width: 13px; height: 13px; }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
th.sticky-col { z-index: 2; background: var(--surface-2); }

/* ---------- forms ---------- */
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .wide { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.8px; font-weight: 570; color: var(--text-2); display: flex; gap: 6px; align-items: baseline; }
.field .req { color: var(--bad-text); }
.help { font-size: 12px; color: var(--text-3); line-height: 1.4; }
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--bad-text); font-size: 12.5px; font-weight: 520; }
.field.has-error .input { border-color: var(--bad); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--text); font: 14px var(--font); min-width: 0;
  transition: border-color .12s, box-shadow .12s; box-shadow: inset 0 1px 1px rgba(0,0,0,.03);
}
.field textarea, textarea.input { height: auto; min-height: 84px; padding: 9px 11px; line-height: 1.45; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
select.input, .field select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2385847e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
select[multiple] { height: auto; min-height: 120px; padding: 6px; background-image: none; }
.field input[type=file] { font: 13px var(--font); color: var(--text-2); }
.field input[type=file]::file-selector-button { font: 550 13px var(--font); height: 32px; padding: 0 12px; margin-right: 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); cursor: pointer; }
.input[readonly], .field input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-3); font-size: 13px; font-weight: 550; white-space: nowrap; }
.input-group .addon:first-child { border-radius: 9px 0 0 9px; border-right: 0; }
.input-group .addon:last-child { border-radius: 0 9px 9px 0; border-left: 0; }
.input-group .input:not(:first-child), .input-group input:not(:first-child) { border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }
.input-group .input:not(:last-child), .input-group input:not(:last-child) { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-weight: 500; color: var(--text); font-size: 13.5px; }
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check .help { display: block; margin-top: 2px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 36px; height: 21px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(15px); }
.form-section { padding: 18px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section-head { margin-bottom: 14px; }
.form-section-head h3 { font-size: 14px; }
.form-section-head p { color: var(--text-3); font-size: 12.5px; margin: 2px 0 0; }
.form-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.form-errors { background: var(--bad-weak); color: var(--bad-text); border-radius: 10px; padding: 10px 14px; font-weight: 520; margin-bottom: 14px; }
.radio-cards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.radio-cards label { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-weight: 550; background: var(--surface); }
.radio-cards label:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); box-shadow: var(--ring); }
.radio-cards input { accent-color: var(--accent); }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; margin: 16px -1px -1px; padding: 12px 18px; background: color-mix(in oklab, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--border); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- filters toolbar ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { height: 36px; width: auto; }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar .search .icon { position: absolute; left: 11px; top: 9px; color: var(--text-3); }
.toolbar .search .input { width: 100%; padding-left: 35px; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-3); gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg a, .seg button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 8px; color: var(--text-2); font: 550 13px var(--font); white-space: nowrap; border: 0; background: none; cursor: pointer; }
.seg a:hover, .seg button:hover { color: var(--text); text-decoration: none; }
.seg .on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg .n { font-size: 11.5px; color: var(--text-3); font-weight: 600; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; color: var(--text-2); font-weight: 550; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs .n { font-size: 11.5px; padding: 1px 6px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-weight: 600; }

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 9px 14px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv.wide { grid-template-columns: minmax(140px, 45%) 1fr; }
.kv .total { font-weight: 650; border-top: 1px solid var(--border); padding-top: 9px; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--border); min-width: 0; }
.list > li:last-child { border-bottom: 0; }
.list > li > .grow { flex: 1; min-width: 0; }
.list a.row-link { color: inherit; display: contents; }
.list-title { font-weight: 560; }
.list-sub { color: var(--text-3); font-size: 12.5px; }
.list .end { margin-left: auto; text-align: right; white-space: nowrap; }
.list.hover > li:hover { background: var(--hover); }

/* rank bars (top-N lists): HTML bars, one series colour */
.ranks { list-style: none; margin: 0; padding: 0; }
.ranks li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding: 8px 0; }
.ranks .r-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 520; }
.ranks .r-val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.ranks .r-bar { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.ranks .r-bar i { display: block; height: 100%; border-radius: 99px; background: var(--s1); }
.ranks .r-sub { grid-column: 1 / -1; font-size: 12px; color: var(--text-3); margin-top: -2px; }

/* meter */
.meter { height: 8px; border-radius: 99px; background: var(--accent-weak); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.meter.good > i { background: var(--good); } .meter.warn > i { background: var(--warn); } .meter.bad > i { background: var(--bad); }

/* avatar */
.avatar { --h: 210; width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-size: 12px; font-weight: 650; color: hsl(var(--h) 45% 32%); background: hsl(var(--h) 60% 90%); letter-spacing: .01em; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
:root[data-theme="dark"] .avatar { color: hsl(var(--h) 60% 82%); background: hsl(var(--h) 30% 24%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: hsl(var(--h) 60% 82%); background: hsl(var(--h) 30% 24%); } }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* ---------- pipeline (status steps) ---------- */
.pipeline { display: flex; gap: 0; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: thin; }
.pipeline .step { flex: 1 0 92px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; position: relative; font-size: 11.5px; color: var(--text-3); padding: 0 2px; }
.pipeline .step::before { content: ""; position: absolute; top: 10px; left: calc(-50% + 13px); right: calc(50% + 13px); height: 2px; background: var(--border-strong); }
.pipeline .step:first-child::before { display: none; }
.pipeline .bullet { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border-strong); z-index: 1; }
.pipeline .bullet .icon { width: 12px; height: 12px; stroke-width: 3; }
.pipeline .done { color: var(--text-2); }
.pipeline .done .bullet { background: var(--accent); border-color: var(--accent); color: #fff; }
.pipeline .done::before, .pipeline .current::before { background: var(--accent); }
.pipeline .current { color: var(--text); font-weight: 620; }
.pipeline .current .bullet { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-weak); }
.pipeline .current .bullet::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.pipeline .when { font-size: 11px; color: var(--text-3); font-weight: 450; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .t-dot { position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline .t-dot.accent { border-color: var(--accent); background: var(--accent-weak); }
.timeline .t-dot.good { border-color: var(--good); background: var(--good-weak); }
.timeline .t-dot.warn { border-color: var(--warn); background: var(--warn-weak); }
.timeline .t-dot.bad { border-color: var(--bad); background: var(--bad-weak); }
.timeline .t-title { font-weight: 560; }
.timeline .t-meta { font-size: 12px; color: var(--text-3); }
.timeline .t-body { margin-top: 4px; font-size: 13px; color: var(--text-2); }
.changes { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.changes li { padding: 2px 0 !important; }
.changes li::before { display: none; }
.changes .from { color: var(--bad-text); text-decoration: line-through; text-decoration-color: color-mix(in oklab, var(--bad) 50%, transparent); }
.changes .to { color: var(--good-text); }

/* ---------- callouts, empty states ---------- */
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--accent-weak); color: var(--text); font-size: 13.5px; align-items: flex-start; }
.callout > .icon { color: var(--accent-text); margin-top: 1px; }
.callout.warn { background: var(--warn-weak); } .callout.warn > .icon { color: var(--warn-text); }
.callout.bad { background: var(--bad-weak); } .callout.bad > .icon { color: var(--bad-text); }
.callout.good { background: var(--good-weak); } .callout.good > .icon { color: var(--good-text); }
.callout.mute { background: var(--surface-3); } .callout.mute > .icon { color: var(--text-3); }
.callout b { font-weight: 620; }
.callout .grow { flex: 1; min-width: 0; }
.callout p:last-child { margin-bottom: 0; }
.empty { text-align: center; padding: 44px 20px; color: var(--text-2); }
.empty .empty-icon { width: 48px; height: 48px; border-radius: 14px; display: inline-grid; place-items: center; background: var(--accent-weak); color: var(--accent-text); margin-bottom: 12px; }
.empty h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.empty p { max-width: 440px; margin: 0 auto 14px; color: var(--text-3); }

/* ---------- menus (details/summary, no JS needed) ---------- */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.menu-panel.left { right: auto; left: 0; }
.menu-panel.up { top: auto; bottom: calc(100% + 6px); }
.menu-panel a, .menu-panel button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font: 500 13.5px var(--font); border: 0; background: none; cursor: pointer; text-align: left; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--hover); text-decoration: none; }
.menu-panel .icon { color: var(--text-3); }
.menu-panel .danger, .menu-panel .danger .icon { color: var(--bad-text); }
.menu-panel hr { margin: 6px 0; }
.menu-panel .menu-head { padding: 8px 10px 6px; font-size: 12px; color: var(--text-3); }

/* ---------- dialogs ---------- */
dialog { border: 0; padding: 0; color: var(--text); background: transparent; max-width: 100vw; max-height: 100dvh; }
dialog::backdrop { background: rgba(10, 10, 9, .45); backdrop-filter: blur(2px); }
.modal { width: min(560px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--border); }
.modal.wide { width: min(820px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; font-size: 16px; }
.modal-body { padding: 18px 20px; max-height: min(70dvh, 720px); overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); flex-wrap: wrap; }
dialog[open] .modal { animation: pop .14s ease-out; }
@keyframes pop { from { transform: translateY(6px) scale(.985); opacity: 0; } }

/* ---------- command palette ---------- */
.cmdk { width: min(640px, calc(100vw - 24px)); margin-top: 10vh; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.cmdk-dialog { margin: 0 auto; inset: 0 0 auto 0; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.cmdk-input .icon { color: var(--text-3); }
.cmdk-input input { flex: 1; height: 54px; border: 0; outline: none; background: transparent; color: var(--text); font: 16px var(--font); }
.cmdk-list { max-height: min(60dvh, 460px); overflow-y: auto; padding: 6px; }
.cmdk-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; color: var(--text); cursor: pointer; }
.cmdk-item:hover { text-decoration: none; }
.cmdk-item .ci-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-2); flex: none; }
.cmdk-item .ci-text { min-width: 0; flex: 1; }
.cmdk-item .ci-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .ci-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item[aria-selected="true"] { background: var(--accent-weak); }
.cmdk-item[aria-selected="true"] .ci-icon { background: var(--accent); color: #fff; }
.cmdk-foot { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); background: var(--surface-2); }
.cmdk-empty { padding: 28px; text-align: center; color: var(--text-3); }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-weight: 520; animation: toast-in .18s ease-out; }
.toast .icon { margin-top: 1px; }
.toast.success .icon { color: #6fdc6f; } .toast.error .icon { color: #ff8a8a; } .toast.warning .icon { color: #ffc95c; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 0; }
.toast.hide { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); flex-wrap: wrap; }
.pager .btn-group .btn { height: 30px; }

/* ---------- charts ---------- */
.chart { margin: 0; position: relative; min-width: 0; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .c-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .c-axis { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .c-tick { fill: var(--text-3); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .c-label { fill: var(--text-2); font: 600 11px var(--font); }
.chart .c-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .c-area { opacity: .1; }
.chart .c-bar { transition: opacity .1s; }
.chart .c-hit { fill: transparent; cursor: crosshair; }
.chart .c-cross { stroke: var(--text-3); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.chart .c-dot { stroke: var(--chart-surface); stroke-width: 2; pointer-events: none; }
.chart:has(.c-bar:hover) .c-bar:not(:hover) { opacity: .55; }
.chart-tip { position: absolute; z-index: 10; pointer-events: none; min-width: 140px; padding: 9px 11px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 12.5px; transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap; }
.chart-tip .tt-title { color: var(--text-3); font-size: 11.5px; margin-bottom: 4px; }
.chart-tip .tt-row { display: flex; align-items: center; gap: 8px; }
.chart-tip .tt-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.chart-tip .tt-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-tip .tt-name { color: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 3px; width: 14px; border-radius: 2px; }
.chart-table { display: none; }
.chart.show-table .chart-table { display: block; margin-top: 10px; }
.chart.show-table svg { display: none; }

/* ---------- auth pages ---------- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; color: #fff;
  background: radial-gradient(1200px 600px at 0% 0%, color-mix(in oklab, var(--accent) 70%, #fff) 0%, transparent 60%),
              linear-gradient(150deg, var(--accent) 0%, color-mix(in oklab, var(--accent) 45%, #050510) 100%); }
.auth-side::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent); pointer-events: none; }
.auth-side h2 { font-size: 30px; line-height: 1.15; font-weight: 680; letter-spacing: -.025em; max-width: 460px; }
.auth-side p { opacity: .85; max-width: 440px; font-size: 15px; }
.auth-points { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; position: relative; z-index: 1; }
.auth-points li { display: flex; gap: 12px; align-items: center; font-weight: 520; }
.auth-points .icon { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgba(255,255,255,.14); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--surface); }
.auth-card { width: min(400px, 100%); }
.auth-card .logo { height: 34px; margin-bottom: 28px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card .lead { color: var(--text-2); margin-bottom: 24px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .input, .auth-card .field input { height: 44px; font-size: 15px; }
.auth-foot { margin-top: 22px; font-size: 12.5px; color: var(--text-3); text-align: center; }
.otp-input { letter-spacing: .5em; text-align: center; font-size: 22px !important; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- mobile chrome ---------- */
.tabbar, .fab, .topbar-back { display: none; }
.sheet .modal { border-radius: 20px 20px 0 0; }

/* ---------- print ---------- */
@media print {
  .sidebar, .topbar, .tabbar, .fab, .page-actions, .toolbar, .no-print { display: none !important; }
  .main { margin: 0; } .content { padding: 0; max-width: none; }
  body { background: #fff; } .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-main-wide { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1100px) {
  /* icon rail */
  .sidebar { width: var(--rail); }
  .brand { justify-content: center; padding: 12px 0; }
  .brand-text, .nav-section-title, .nav a span, .nav .count, .me-text { display: none; }
  .nav { padding: 4px 10px; }
  .nav a { justify-content: center; padding: 10px; }
  .nav a.active::before { left: -10px; }
  .nav-section { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
  .nav-section:first-child { border-top: 0; }
  .me { justify-content: center; }
  .main { margin-left: var(--rail); }
  .grid-main, .grid-main-wide { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 12px; gap: 6px; height: 54px; background: color-mix(in oklab, var(--surface) 88%, transparent); border-bottom-color: var(--border); }
  .topbar-title { display: block; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-back { display: inline-flex; }
  .search-trigger { flex: 0 0 36px; width: 36px; padding: 0; justify-content: center; box-shadow: none; }
  .search-trigger span, .search-trigger kbd, .topbar-spacer, .hide-sm { display: none !important; }
  .content { padding: 14px 16px 32px; }
  .page-head { margin: 2px 0 14px; gap: 12px; }
  .page-head h1 { font-size: 20px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .page-actions .btn-primary.has-fab { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .form-grid .wide { grid-column: 1 / -1; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 13px 10px; }
  .stat-value { font-size: 19px; }
  .stat .spark { display: none; }
  .card-head { padding: 12px 14px 0; }
  .card-body { padding: 12px 14px 14px; }
  .card-foot { padding: 10px 14px; }
  .card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: 14px; }
  .input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select { height: 44px; font-size: 16px; }
  .btn { height: 40px; }
  .btn-sm { height: 34px; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .toolbar > .input, .toolbar > select { flex: 1 1 140px; }
  .kv, .kv.wide { grid-template-columns: minmax(100px, 42%) 1fr; }
  .list > li { padding: 11px 14px; }
  /* tables that turn into cards */
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--border); position: relative; }
  .table.stack tbody tr:last-child { border-bottom: 0; }
  .table.stack td { border: 0; padding: 2px 0 !important; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--text-3); font-size: 13px; text-align: left; flex: none; }
  .table.stack td.lead { display: block; text-align: left; padding-bottom: 6px !important; }
  .table.stack td.lead::before { display: none; }
  .table.stack td.hide-sm, .table.stack td:empty { display: none; }
  .table.stack tfoot { display: block; }
  .table.stack tfoot tr { display: flex; justify-content: space-between; background: var(--surface-2); }
  .table.stack tfoot td { width: auto; background: none; border: 0; }
  .table.stack tbody tr:hover td { background: none; }
  /* bottom tabs */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in oklab, var(--surface) 94%, transparent); backdrop-filter: saturate(1.5) blur(14px); -webkit-backdrop-filter: saturate(1.5) blur(14px); border-top: 1px solid var(--border); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); font: 600 10.5px var(--font); border: 0; background: none; text-decoration: none; position: relative; cursor: pointer; padding: 0 2px; min-width: 0; }
  .tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar .icon { width: 23px; height: 23px; stroke-width: 1.8; }
  .tabbar .active { color: var(--accent-text); }
  .tabbar .active .icon { stroke-width: 2.2; }
  .fab { display: grid; place-items: center; position: fixed; z-index: 44; right: 16px; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 17px; background: var(--accent); color: #fff; box-shadow: 0 6px 20px color-mix(in oklab, var(--accent) 45%, transparent), var(--shadow); }
  .fab .icon { width: 24px; height: 24px; stroke-width: 2.4; }
  .fab:hover { text-decoration: none; }
  dialog.sheet { margin: auto 0 0; width: 100%; max-width: 100%; }
  .sheet .modal { width: 100%; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  dialog.sheet[open] .modal { animation: sheet-up .2s ease-out; }
  .toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); max-width: none; }
  .cmdk { margin-top: 8px; }
  .modal-body { max-height: 70dvh; }
  .hero-figure { font-size: 34px; }
  .pipeline .step { flex-basis: 78px; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 761px) { .show-sm { display: none !important; } }
@media (max-width: 340px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
}

/* more-sheet nav (mobile) */
.sheet-nav a { display: flex; align-items: center; gap: 12px; padding: 12px 6px; color: var(--text); font-weight: 540; border-bottom: 1px solid var(--border); }
.sheet-nav a:last-child { border-bottom: 0; }
.sheet-nav a.active { color: var(--accent-text); }
.sheet-nav .nav-section-title { padding: 14px 6px 4px; }
.sheet-grip { width: 40px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 8px auto 0; }

/* htmx swap feedback: keep the frame, dim while loading */
.htmx-request.dim-on-load, .htmx-request .dim-on-load { opacity: .55; transition: opacity .15s .1s; }
.loading-bar { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--accent); z-index: 200; opacity: 0; transition: width .4s ease, opacity .3s; }
.loading-bar.on { opacity: 1; width: 70%; transition: width 2s cubic-bezier(.1,.7,.3,1); }
.loading-bar.done { width: 100%; opacity: 0; transition: width .15s, opacity .4s .15s; }

/* ---------- kanban board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; }
.board-col { background: var(--surface-3); border-radius: var(--r-lg); padding: 10px; min-height: 200px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 8px; }
.board-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 6px; }
.board-head .n { font-size: 12px; color: var(--text-3); font-weight: 600; }
.board-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; color: var(--text-2); box-shadow: var(--shadow-sm); font-size: 13px; transition: border-color .12s, box-shadow .12s, transform .08s; }
.board-card:hover { text-decoration: none; border-color: var(--accent-line); box-shadow: var(--shadow); }
.board-empty { color: var(--text-3); font-size: 12.5px; text-align: center; padding: 18px 0; }
@media (max-width: 760px) { .board { grid-auto-columns: 82%; } }

/* ---------- stacked share bar (landed cost breakdown) ---------- */
.stackbar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.stackbar i { display: block; height: 100%; min-width: 3px; }
.seg-1 { background: var(--s1); } .seg-2 { background: var(--s2); } .seg-3 { background: var(--s3); }
.seg-4 { background: var(--s4); } .seg-5 { background: var(--s5); } .seg-6 { background: var(--s6); }
.seg-7 { background: var(--s7); } .seg-8 { background: var(--s8); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.lines-table td { padding: 8px 8px; vertical-align: top; }
.lines-table td:first-child { padding-left: 18px; }
.lines-table .input { height: 36px; }
.lines-table .input.num { text-align: right; }
.lines-table tfoot td { background: var(--surface-2); }
@media (max-width: 760px) {
  .lines-table thead { display: none; }
  .lines-table, .lines-table tbody, .lines-table tr, .lines-table td { display: block; width: 100%; }
  .lines-table tr[data-formset-row] { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); position: relative; }
  .lines-table tr[data-formset-row] td { padding: 0 !important; border: 0; }
  .lines-table tr[data-formset-row] td:first-child { grid-column: 1 / -1; padding-right: 40px !important; }
  .lines-table tr[data-formset-row] td.min { position: absolute; top: 12px; right: 10px; width: auto; }
  .lines-table tr[data-formset-row] td.line-total { grid-column: 1 / -1; text-align: right; }
  .lines-table tr[data-formset-row] td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 560; color: var(--text-3); margin-bottom: 3px; }
  .lines-table tr[data-formset-row] td.line-total[data-label]::before { display: inline; margin-right: 8px; }
  .lines-table tfoot tr { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
  .lines-table tfoot #sum-qty { display: none; }
  .lines-table tfoot td { border: 0; padding: 0 !important; width: auto; }
  .lines-table tfoot td:empty { display: none; }
}
.exp-group + .exp-group { border-top: 1px solid var(--border); }
.exp-group-head { display: flex; justify-content: space-between; padding: 12px 18px 4px; font-size: 12.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.exp-group .list > li { padding-top: 9px; padding-bottom: 9px; }

/* ---------- simulator ---------- */
.sim { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sim-out { position: sticky; top: calc(var(--topbar) + 12px); }
.sim-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.sim-card.best { border-color: var(--good); box-shadow: 0 0 0 3px var(--good-weak); }
.sim-scen:not([data-scen="a"]):has(.switch input:not(:checked)) .card-body { display: none; }
@media (max-width: 1100px) { .sim { grid-template-columns: minmax(0, 1fr); } .sim-out { position: static; } }
.att-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.att-ic.bad { background: var(--bad-weak); color: var(--bad-text); }
.att-ic.warn { background: var(--warn-weak); color: var(--warn-text); }
.att-ic.good { background: var(--good-weak); color: var(--good-text); }
a.r-name { color: var(--text); }
.cc { display: inline-block; font: 650 10px/1 var(--mono); letter-spacing: .04em; padding: 3px 4px 2px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); vertical-align: 1px; margin-right: 2px; }
.stat:has(.spark) .stat-foot { padding-right: 82px; }

/* ---------- org chart (indented tree: readable on any width) ---------- */
.org-node { position: relative; }
.org-card { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 4px 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.org-card:hover { border-color: var(--accent-line); text-decoration: none; }
.org-children { margin-left: 22px; padding-left: 18px; border-left: 2px solid var(--border); }
.revealed { background: var(--warn-weak); padding: 1px 6px; border-radius: 5px; }

/* ---------- month calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-h { padding: 8px; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-align: center; border-bottom: 1px solid var(--border); }
.cal-d { min-height: 104px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-d:nth-child(7n) { border-right: 0; }
.cal-d.out { background: var(--surface-2); } .cal-d.out .cal-n { color: var(--text-3); }
.cal-d.wk { background: color-mix(in oklab, var(--surface-3) 45%, var(--surface)); }
.cal-d.hol { background: var(--warn-weak); }
.cal-n { font-size: 12px; font-weight: 600; color: var(--text-2); }
.cal-d.today .cal-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; }
.cal-hol { font-size: 10.5px; color: var(--warn-text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-p { display: block; font-size: 11px; font-weight: 550; padding: 2px 6px; border-radius: 5px; color: var(--text); background: color-mix(in oklab, var(--c) 18%, var(--surface)); border-left: 3px solid var(--c); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-p:hover { text-decoration: none; filter: brightness(.97); }
.cal-p.pending { background: transparent; border: 1px dashed var(--c); border-left-width: 3px; border-left-style: solid; }
.cal-more { font-size: 10.5px; color: var(--text-3); }
@media (max-width: 760px) { .cal-d { min-height: 64px; padding: 4px; } .cal-p { font-size: 0; height: 6px; padding: 0; border-left-width: 0; background: var(--c); } .cal-hol { font-size: 0; height: 4px; background: var(--warn); border-radius: 2px; } .cal-more { font-size: 9.5px; } }
.att-table .input { height: 34px; max-width: 130px; }
.att-table select.input { max-width: 170px; }
@media (max-width: 760px) { .att-table .input, .att-table select.input { max-width: none; width: 60%; } }
.clock-now { font-size: 40px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.clock-card .btn-lg { height: 52px; font-size: 16px; }

/* ---------- bulk import ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps > li { margin: 0 !important; }
.steps h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.step-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--accent-weak); color: var(--accent-text); font-size: 12.5px; font-weight: 650; }
.dropzone { display: grid; justify-items: center; gap: 4px; padding: 28px 16px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2);
  transition: border-color .12s, background .12s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-weak); }
.dropzone.has-file { border-style: solid; border-color: var(--accent-line); }
.dropzone .icon { color: var(--text-3); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { box-shadow: var(--ring); }
.cols-help summary { cursor: pointer; color: var(--accent-text); }
.import-card { color: inherit; display: flex; flex-direction: column; }
.import-card:hover { text-decoration: none; border-color: var(--border-strong); }
.import-card .card-body { flex: 1; }
.import-card .card-foot { gap: 6px; }
.import-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r); flex: none;
  background: var(--accent-weak); color: var(--accent-text); }
ul.problems, ul.row-warn { margin: 0; padding: 0; list-style: none; }
ul.problems li { color: var(--bad-text); }
ul.problems li + li, ul.row-warn li + li { margin-top: 2px; }
ul.row-warn li { color: var(--warn-text); display: flex; gap: 4px; align-items: flex-start; }
.stat-value.bad-text { color: var(--bad-text); }

/* ---------- ready for use ---------- */
.ready-list > li { align-items: flex-start; scroll-margin-top: calc(var(--topbar) + 16px); }
.ready-list > li:target { background: var(--accent-weak); }
.ready-ic { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none; margin-top: 1px; }
.ready-ic.good { background: var(--good-weak); color: var(--good-text); }
.ready-ic.warn { background: var(--warn-weak); color: var(--warn-text); }
.ready-ic.todo { background: var(--bad-weak); color: var(--bad-text); }
.ready-ic.mute { background: var(--surface-3); color: var(--text-3); }
.ready-list .is-done .list-title { color: var(--text-2); }
.ready-todo { color: var(--text-2); }
.ready-extra { margin: 4px 0 0; padding-left: 18px; color: var(--text-2); }
.ready-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ready-confirm { padding: 12px; min-width: 260px; display: grid; gap: 4px; }
@media (max-width: 640px) {
  .ready-list > li { flex-wrap: wrap; }
  .ready-actions { width: 100%; justify-content: flex-start; padding-left: 34px; }
}
.ready-banner { display: flex; gap: 14px; align-items: center; padding: 14px 18px; color: inherit; }
.ready-banner:hover { text-decoration: none; border-color: var(--accent-line); }
.ready-banner .grow { flex: 1; min-width: 0; }
.ready-banner .meter { height: 6px; max-width: 360px; }
.job-actions { border: 1px solid var(--border); border-radius: var(--r-lg); }
@media (max-width: 760px) {
  /* above the bottom tab bar, not behind it */
  .sticky-actions { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); }
  .table.stack td.block { display: block; text-align: left; }
  .table.stack td.block::before { display: block; margin-bottom: 2px; }
  .job-actions .spacer { display: none; }
  .job-actions > form:last-child, .job-actions > .btn-primary { order: -1; width: 100%; }
  .job-actions > form:last-child .btn { width: 100%; justify-content: center; }
}
