/* MQS Tracker web app — one stylesheet, no framework.
   Tokens follow the marketing site's palette (ink / blue / green stripes). */

:root {
  --ink: #111418;
  --blue: #38579e;
  --green: #30ab61;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e1e6ee;
  --border-strong: #cdd5e1;
  --text: #111418;
  --text-2: #4d5869;
  --text-3: #6f7a8c;

  --accent: #38579e;
  --accent-hover: #2d4682;
  --accent-text: #ffffff;
  --accent-soft: #e8edf7;

  --good: #1f8a4c;   --good-soft: #e3f4ea;
  --bad: #c0392b;    --bad-soft: #fbe7e4;
  --warn: #9a6200;   --warn-soft: #fbf0d9;
  --info: #38579e;   --info-soft: #e8edf7;
  --neutral: #4d5869; --neutral-soft: #eef1f5;

  /* Chart series — distinguishable in both themes, brand-led. */
  --c1: #38579e; --c2: #30ab61; --c3: #e0a030; --c4: #c0504d; --c5: #7a5cc2; --c6: #2a9db0; --c7: #8a94a6;

  --sidebar-w: 252px;
  --topbar-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(17 20 24 / 5%), 0 4px 16px rgb(17 20 24 / 6%);
  --shadow-lg: 0 12px 40px rgb(17 20 24 / 18%);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eef1f6;
    --bg: #0d1014;
    --surface: #161b22;
    --surface-2: #1b212a;
    --border: #262e3a;
    --border-strong: #34404f;
    --text: #eef1f6;
    --text-2: #a9b3c3;
    --text-3: #808b9d;
    --accent: #7d9ad8;
    --accent-hover: #9bb2e4;
    --accent-text: #0d1014;
    --accent-soft: #1d2739;
    --good: #5cc88a;  --good-soft: #15291d;
    --bad: #f07b6c;   --bad-soft: #36191a;
    --warn: #e2b45c;  --warn-soft: #30270f;
    --info: #8eaae4;  --info-soft: #1d2739;
    --neutral: #a9b3c3; --neutral-soft: #222a35;
    --c1: #7d9ad8; --c2: #5cc88a; --c3: #e8b04a; --c4: #ee7d70; --c5: #a68ae6; --c6: #4fc3d6; --c7: #8a94a6;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
    --shadow-lg: 0 12px 40px rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ink: #eef1f6;
  --bg: #0d1014;
  --surface: #161b22;
  --surface-2: #1b212a;
  --border: #262e3a;
  --border-strong: #34404f;
  --text: #eef1f6;
  --text-2: #a9b3c3;
  --text-3: #808b9d;
  --accent: #7d9ad8;
  --accent-hover: #9bb2e4;
  --accent-text: #0d1014;
  --accent-soft: #1d2739;
  --good: #5cc88a;  --good-soft: #15291d;
  --bad: #f07b6c;   --bad-soft: #36191a;
  --warn: #e2b45c;  --warn-soft: #30270f;
  --info: #8eaae4;  --info-soft: #1d2739;
  --neutral: #a9b3c3; --neutral-soft: #222a35;
  --c1: #7d9ad8; --c2: #5cc88a; --c3: #e8b04a; --c4: #ee7d70; --c5: #a68ae6; --c6: #4fc3d6; --c7: #8a94a6;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 55%);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Boot / error ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 22px; color: var(--ink); }
.boot-mark { width: 64px; height: 52px; }
.boot-bar { width: 160px; height: 3px; background: var(--border); border-radius: 3px; overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: calc(var(--blazor-load-percentage, 10%)); background: var(--accent); transition: width .2s; }
#blazor-error-ui {
  display: none; position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 1000;
  background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad);
  padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
#blazor-error-ui .reload { margin-left: 8px; font-weight: 600; }
#blazor-error-ui .dismiss { float: right; background: none; border: 0; cursor: pointer; font-size: 1.2rem; line-height: 1; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--ink); font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand svg { width: 30px; height: 24px; }
.nav-group { margin-top: 14px; }
.nav-label { padding: 0 10px 6px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.nav-label::before { content: ""; width: 10px; height: 3px; border-radius: 2px; background: var(--stripe, var(--text-3)); }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550; font-size: .93rem;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.org-card { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.org-card .org-name { font-weight: 600; font-size: .88rem; line-height: 1.3; }
button.org-card { width: 100%; font: inherit; color: inherit; text-align: left; cursor: default; }
button.org-card.switchable { cursor: pointer; }
button.org-card.switchable:hover { border-color: var(--border-strong); }
button.org-card:disabled { opacity: 1; }
.org-menu { margin-bottom: 8px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); }
.org-menu .menu-item { gap: 10px; }
.org-menu .menu-item.current { background: var(--accent-soft); }
.org-menu .org-name { font-weight: 600; font-size: .88rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.icon-btn.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding: 0 64px 0 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 11px var(--font); color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; background: var(--surface-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.content { padding: 28px; max-width: 1360px; width: 100%; margin: 0 auto; }
.scrim { display: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid transparent; background: none; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }

.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem;
}
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; }
.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px;
}
.menu-panel .menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--text); text-align: left; }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }

/* Search results dropdown */
.search-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
}
.search-group { padding: 8px 10px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.search-hit { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.search-hit:hover, .search-hit.active { background: var(--surface-2); text-decoration: none; }
.search-hit .hit-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.search-hit .hit-main { min-width: 0; display: grid; }
.search-hit .hit-title { font-weight: 600; }
.search-hit .hit-sub { font-size: .82rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 16px 12px; color: var(--text-2); }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-bottom: 22px; }
.page-head .titles { min-width: 0; flex: 1 1 320px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .85rem; color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-2); }
.page-head .lede { color: var(--text-2); margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--text-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; height: 44px; }

.field { display: grid; gap: 6px; }
.field label { font-size: .85rem; font-weight: 600; color: var(--text-2); }
.input, .select {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); outline: none; width: 100%;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar .input { max-width: 320px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-weight: 600; font-size: .84rem; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.stack { display: grid; gap: 18px; align-content: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.card-head .sub { color: var(--text-3); font-size: .82rem; }
.card-head .end { margin-left: auto; }
.card-body { padding: 16px 18px 18px; }
.card-body.flush { padding: 8px 0 6px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 30px 0 14px; }

.kpi { padding: 18px; display: grid; gap: 6px; position: relative; overflow: hidden; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-size: .85rem; font-weight: 600; }
.kpi .kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--tone-soft, var(--accent-soft)); color: var(--tone, var(--accent)); }
.kpi .kpi-value { font-size: 1.85rem; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .kpi-value.text { font-size: 1.2rem; line-height: 1.3; padding: 6px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi .kpi-hint { font-size: .82rem; color: var(--text-3); }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone, var(--accent)); }
.tone-good { --tone: var(--good); --tone-soft: var(--good-soft); }
.tone-bad { --tone: var(--bad); --tone-soft: var(--bad-soft); }
.tone-warn { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.tone-info { --tone: var(--info); --tone-soft: var(--info-soft); }
.tone-neutral { --tone: var(--neutral); --tone-soft: var(--neutral-soft); }

/* Hero welcome band */
.welcome {
  position: relative; overflow: hidden; padding: 24px 26px; margin-bottom: 22px; border-radius: 16px;
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 70%);
  border: 1px solid var(--border);
}
.welcome h1 { font-size: 1.55rem; }
.welcome p { color: var(--text-2); margin-top: 6px; max-width: 60ch; }
.welcome .stripes { position: absolute; right: -10px; top: -20px; bottom: -20px; display: flex; gap: 14px; transform: skewX(-12deg); opacity: .14; pointer-events: none; }
.welcome .stripes i { width: 34px; display: block; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 650; white-space: nowrap;
  background: var(--tone-soft, var(--neutral-soft)); color: var(--tone, var(--neutral));
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; background: var(--neutral-soft); color: var(--text-2); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th {
  text-align: left; font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3);
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
table.data th.num { text-align: right; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.link { cursor: pointer; }
table.data tbody tr.link:hover td { background: var(--surface-2); }
table.data .primary-cell { font-weight: 650; color: var(--text); }
table.data .secondary { display: block; font-size: .82rem; color: var(--text-2); font-weight: 400; }
table.data tfoot td { font-weight: 700; background: var(--surface-2); }
.card > .table-wrap { border-radius: var(--radius); }

/* Compact list rows */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--border); }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; color: var(--text); }
a.row:hover { background: var(--surface-2); text-decoration: none; }
.row .row-main { min-width: 0; flex: 1; }
.row .row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .row-sub { font-size: .82rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .row-end { text-align: right; flex: none; }
.row-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--tone-soft, var(--accent-soft)); color: var(--tone, var(--accent)); }

/* Detail key/values */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px 22px; }
.fact .fact-label { font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.fact .fact-value { margin-top: 3px; font-weight: 600; overflow-wrap: anywhere; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; cursor: pointer; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { margin-left: 6px; font-size: .75rem; background: var(--neutral-soft); color: var(--text-2); border-radius: 999px; padding: 1px 7px; }

/* ---------- Timeline (unit story) ---------- */
.timeline { list-style: none; margin: 0; padding: 4px 0 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline li { position: relative; display: grid; grid-template-columns: 36px 1fr; gap: 14px; padding-bottom: 20px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--tone-soft, var(--accent-soft)); color: var(--tone, var(--accent)); border: 3px solid var(--surface); position: relative; z-index: 1; }
.timeline .when { font-size: .8rem; color: var(--text-3); }
.timeline .what { font-weight: 650; margin-top: 1px; }
.timeline .detail { font-size: .88rem; color: var(--text-2); margin-top: 2px; }
/* Change history drawer: field-by-field changes under each timeline entry. */
.history .changes { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: 4px 12px; margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .86rem; }
.history .changes dt { color: var(--text-3); }
.history .changes dd { margin: 0; min-width: 0; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.history .changes dd svg { color: var(--text-3); flex: none; }
.history .changes .was { color: var(--text-3); text-decoration: line-through; }

/* ---------- Meters ---------- */
.meter { height: 8px; background: var(--neutral-soft); border-radius: 999px; overflow: hidden; display: flex; }
.meter span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .bar { transition: opacity .15s; }
.chart .bar:hover { opacity: .8; }
.donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 26px; }
.donut { width: 168px; height: 168px; flex: none; }
.donut .donut-total { font-size: 26px; font-weight: 750; fill: var(--text); }
.donut .donut-label { font-size: 11px; fill: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.donut-legend { display: grid; gap: 8px; flex: 1; min-width: 180px; }
.donut-legend .item { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; font-size: .88rem; }
.donut-legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.hbars { display: grid; gap: 12px; }
.hbar .hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: .88rem; margin-bottom: 5px; }
.hbar .hbar-top a, .hbar .hbar-top span:first-child { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: var(--fill, var(--accent)); }

/* ---------- States ---------- */
.empty { padding: 36px 20px; text-align: center; color: var(--text-2); display: grid; justify-items: center; gap: 10px; }
.empty .empty-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--neutral-soft); color: var(--text-3); }
.empty strong { color: var(--text); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--tone-soft); color: var(--tone); border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent); margin-bottom: 18px; }
.alert .alert-body { color: var(--text); }
.skeleton { border-radius: 6px; background: linear-gradient(90deg, var(--neutral-soft), var(--surface-2), var(--neutral-soft)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-line { height: 12px; margin: 10px 18px; }
.sk-block { height: 160px; margin: 16px 18px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: .88rem; color: var(--text-2); }

/* ---------- Sign-in ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); }
.auth-art {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: #111418; color: #eef1f6;
}
.auth-art .brand { color: #eef1f6; padding: 0; }
.auth-art h2 { font-size: clamp(1.7rem, 3vw, 2.5rem); line-height: 1.15; max-width: 16ch; font-weight: 750; letter-spacing: -0.02em; }
.auth-art p { color: #a9b3c3; max-width: 46ch; margin-top: 14px; font-size: 1.02rem; }
.auth-art .pillars { display: grid; gap: 10px; margin-top: 30px; max-width: 420px; }
.auth-art .pillar { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: rgb(255 255 255 / 5%); border: 1px solid rgb(255 255 255 / 8%); }
.auth-art .pillar b { display: block; }
.auth-art .pillar span { color: #a9b3c3; font-size: .88rem; }
.auth-art .pillar i { width: 6px; align-self: stretch; border-radius: 3px; }
.auth-art .bg-stripes { position: absolute; right: -60px; top: -40px; bottom: -40px; display: flex; gap: 26px; transform: skewX(-12deg); opacity: .18; }
.auth-art .bg-stripes i { width: 70px; display: block; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.auth-form h1 { font-size: 1.6rem; }
.password-input { position: relative; }
.password-input .input { padding-right: 44px; }
.password-input .icon-btn { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.btn.block + .btn.block { margin-top: -6px; }
.auth-foot { font-size: .88rem; color: var(--text-2); text-align: center; }

a.report-card { color: var(--text); transition: border-color .15s, transform .15s; }
a.report-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }

/* ---------- Order stepper ---------- */
.stepper { list-style: none; margin: 0; padding: 16px 18px; display: flex; gap: 8px; overflow-x: auto; }
.step { flex: 1; min-width: 96px; display: flex; align-items: center; gap: 10px; position: relative; color: var(--text-3); font-weight: 600; font-size: .88rem; }
.step:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--border); min-width: 12px; }
.step.done:not(:last-child)::after { background: var(--good); }
.step-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .8rem; border: 2px solid var(--border-strong); background: var(--surface); }
.step.done .step-dot { background: var(--good); border-color: var(--good); color: #fff; }
.step.current { color: var(--text); }
.step.current .step-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step-label { white-space: nowrap; }

/* ---------- Editing: drawer, dialog, forms, toasts ---------- */
.drawer-scrim { position: fixed; inset: 0; z-index: 80; background: rgb(10 14 20 / 45%); animation: fade .15s ease; }
.drawer {
  position: fixed; z-index: 90; top: 0; right: 0; bottom: 0; width: min(520px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: slide-in .2s ease;
}
.drawer form, .drawer .drawer-frame { height: 100%; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 1.2rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; display: grid; gap: 16px; align-content: start; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.dialog {
  position: fixed; z-index: 90; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(440px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 22px;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.field .hint { font-size: .8rem; color: var(--text-3); }
.field .required::after { content: " *"; color: var(--bad); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 550; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--neutral-soft); gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: .86rem; color: var(--text-2); cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 12%); }
.segmented button.on.good { color: var(--good); }
.segmented button.on.bad { color: var(--bad); }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.input-prefix > .input { padding-left: 26px; }

.btn.sm { height: 32px; padding: 0 10px; font-size: .84rem; border-radius: 8px; }
.btn.danger { color: var(--bad); }
.btn.ghost.danger:hover { background: var(--bad-soft); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-solid:hover { filter: brightness(.92); }
.row-actions { display: flex; gap: 4px; flex: none; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-soft); border-color: transparent; }

.toasts { position: fixed; z-index: 100; left: calc(var(--sidebar-w) + 20px); bottom: 20px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--tone); box-shadow: var(--shadow-lg);
  color: var(--text); animation: slide-in .2s ease;
}
.toast > svg { color: var(--tone); }
.toast span { flex: 1; font-weight: 550; font-size: .92rem; }

/* ---------- Billing: subscription gate and plans ---------- */
.gate { display: grid; place-items: start center; padding: 24px 0 40px; }
.gate-card { width: min(560px, 100%); padding: 30px; display: grid; gap: 14px; }
.gate-card h1 { font-size: 1.5rem; }
.gate-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plan {
  position: relative; display: grid; gap: 2px; text-align: left; padding: 16px; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
}
.plan:hover { border-color: var(--border-strong); }
.plan.on { border-color: var(--accent); background: var(--accent-soft); }
.plan-name { font-weight: 700; font-size: .9rem; color: var(--text-2); }
.plan-price { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
.plan-price-pending { color: var(--text-3); }
.plan-unit { font-size: .82rem; color: var(--text-2); }
.plan-note { font-size: .8rem; color: var(--text-3); margin-top: 6px; }
.plan-badge { position: absolute; top: 12px; right: 12px; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--good-soft); color: var(--good); }
.plan-includes { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 8px; font-size: .9rem; color: var(--text-2); }
.plan-includes li { display: flex; gap: 8px; align-items: flex-start; }
.plan-includes svg { color: var(--good); margin-top: 3px; }
.billing-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid.side { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: min(var(--sidebar-w), 84vw);
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 40%); }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 40px; }
  .search kbd { display: none; }
  .search input { padding-right: 12px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 24px; }
  .auth-art .pillars, .auth-art .art-foot, .auth-art p { display: none; }
  .auth-art { padding: 20px 24px 22px; gap: 14px; }
  .auth-art h2 { font-size: 1.3rem; max-width: 24ch; }
  .auth-form { place-items: start center; padding-top: 28px; }
}

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .kpi .kpi-value { font-size: 1.55rem; }
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 14px; }
  .welcome { padding: 20px 18px; }
  .page-actions { width: 100%; }
  .toolbar .input { max-width: none; }
  .drawer { width: 100vw; border-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .toasts { left: 16px; right: 16px; top: 12px; bottom: auto; width: auto; }
  .step { min-width: auto; flex: 0 1 auto; }
  .step.current { flex: 1 1 auto; }
  .step-dot { width: 24px; height: 24px; }
  table.data.stackable td.chev { display: none; }
  .step:not(.current) .step-label { display: none; }

  /* Tables collapse into labelled cards. */
  table.data.stackable thead { display: none; }
  table.data.stackable, table.data.stackable tbody, table.data.stackable tr, table.data.stackable td { display: block; width: 100%; }
  table.data.stackable tr { padding: 10px 16px; border-bottom: 1px solid var(--border); }
  table.data.stackable tr:last-child { border-bottom: 0; }
  table.data.stackable td { border: 0; padding: 3px 0; text-align: left; display: flex; justify-content: space-between; gap: 12px; }
  table.data.stackable td[data-label]::before { content: attr(data-label); color: var(--text-3); font-size: .8rem; font-weight: 600; }
  table.data.stackable td.primary-cell { display: block; font-size: 1rem; padding-bottom: 4px; }
  table.data.stackable td.primary-cell::before { display: none; }
  table.data.stackable tfoot { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.row a.row-main { color: var(--text); }
.row a.row-main:hover { text-decoration: none; }
.row a.row-main:hover .row-title { color: var(--accent); }
