/* Nexus 0.1.1 - IT management. Own look, not the Star South brand.
   "Midnight" theme: a dark ink sidebar, a calm light canvas (or full dark mode), indigo for actions,
   cyan / violet / amber as data accents, emerald for good, amber for warnings, rose for problems.
   Light and dark follow the computer's setting; the moon/sun button in the top bar overrides it. */

:root {
  --bg: #F4F6FB; --card: #FFFFFF; --soft: #F1F4F9; --soft2: #E9EDF5; --line: #E4E8F0;
  --ink: #0F172A; --ink2: #334155; --muted: #64748B; --faint: #94A3B8;
  --pri: #4F46E5; --pri-h: #4338CA; --pri-s: #EEF0FF; --pri-ink: #3730A3; --on-pri: #FFFFFF;
  --cyan: #0891B2; --cyan-s: #E0F5FA; --violet: #7C3AED; --violet-s: #F1EAFE; --amber: #D97706; --amber-s: #FEF3E2;
  --good: #059669; --good-s: #E3F6EE; --warn: #B45309; --warn-s: #FEF4E1; --bad: #E11D48; --bad-s: #FDE8EE;
  --side: #0B1020; --side2: #121933; --side-ink: #C7CEE4; --side-muted: #6F7A99; --side-line: #1C2442;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.05);
  --shadow-h: 0 16px 40px rgba(15,23,42,.16);
  --r: 16px; --r-s: 10px;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0E1A; --card: #111726; --soft: #161D30; --soft2: #1C2439; --line: #222B42;
    --ink: #E6E9F2; --ink2: #C3C9DA; --muted: #8A94AE; --faint: #5E6884;
    --pri: #818CF8; --pri-h: #A5B4FC; --pri-s: #1E2147; --pri-ink: #C7D0FF; --on-pri: #0A0E1A;
    --cyan: #22D3EE; --cyan-s: #0E2A33; --violet: #A78BFA; --violet-s: #231A3D; --amber: #FBBF24; --amber-s: #2E2410;
    --good: #34D399; --good-s: #0F2A22; --warn: #FBBF24; --warn-s: #2E2410; --bad: #FB7185; --bad-s: #33141E;
    --side: #070A14; --side2: #10162A; --side-line: #1A2136;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-h: 0 16px 40px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0E1A; --card: #111726; --soft: #161D30; --soft2: #1C2439; --line: #222B42;
  --ink: #E6E9F2; --ink2: #C3C9DA; --muted: #8A94AE; --faint: #5E6884;
  --pri: #818CF8; --pri-h: #A5B4FC; --pri-s: #1E2147; --pri-ink: #C7D0FF; --on-pri: #0A0E1A;
  --cyan: #22D3EE; --cyan-s: #0E2A33; --violet: #A78BFA; --violet-s: #231A3D; --amber: #FBBF24; --amber-s: #2E2410;
  --good: #34D399; --good-s: #0F2A22; --warn: #FBBF24; --warn-s: #2E2410; --bad: #FB7185; --bad-s: #33141E;
  --side: #070A14; --side2: #10162A; --side-line: #1A2136;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-h: 0 16px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; color: var(--muted); margin: 0 0 4px; }

/* ---- sign-in ---- */
.solo { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, rgba(79,70,229,.25), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(8,145,178,.22), transparent 60%), var(--side); }
.solo-card { background: var(--card); border-radius: 20px; padding: 36px; max-width: 440px; width: 100%; box-shadow: var(--shadow-h); }
.solo-card .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; margin-bottom: 26px; color: var(--ink); }
.solo-card .logo img { width: 36px; height: 36px; }
.solo-card h1 { font-weight: 700; font-size: 26px; letter-spacing: -.02em; margin: 6px 0 10px; }
.solo-card p { color: var(--muted); line-height: 1.55; }
.solo-card .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 8px; }

/* ---- shell: dark sidebar ---- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--side) 248px, transparent 248px); }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--side); color: var(--side-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 1px; scrollbar-width: thin; scrollbar-color: var(--side-line) transparent; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.side .brand:hover { text-decoration: none; }
.side .brand img { width: 30px; height: 30px; }
.side .brand small { display: block; font-size: 11px; font-weight: 500; color: var(--side-muted); letter-spacing: 0; }
.side .group { margin: 16px 10px 6px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--side-muted); font-weight: 600; }
.side a.nav { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--side-ink); font-size: 13.5px; }
.side a.nav:hover { background: var(--side2); color: #fff; text-decoration: none; }
.side a.nav .lbl { flex: 1; }
.side a.nav svg.i { width: 17px; height: 17px; color: var(--side-muted); }
.side a.nav .n { font-size: 11px; color: var(--side-muted); background: var(--side2); border-radius: 20px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.side a.nav[aria-current="page"] { background: linear-gradient(90deg, rgba(99,102,241,.28), rgba(99,102,241,.08)); color: #fff; }
.side a.nav[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #818CF8; }
.side a.nav[aria-current="page"] svg.i { color: #A5B4FC; }
.side a.nav[aria-current="page"] .n { background: rgba(129,140,248,.25); color: #E0E7FF; }
.side .spacer { flex: 1; min-height: 16px; }
.side .me { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--side-line); padding: 14px 8px 2px; font-size: 12px; color: var(--side-muted); }
.side .me b { display: block; color: #fff; font-size: 13px; font-weight: 600; }
.side .me a { color: var(--side-ink); text-decoration: underline; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; color: #fff; background: linear-gradient(135deg, #6366F1, #06B6D4); flex: none; }

/* ---- main column and top bar ---- */
.shell .main { margin: 0; padding: 0 32px 60px; max-width: 1480px; width: 100%; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: 12px; padding: 14px 0; margin-bottom: 10px; background: var(--bg); }
.topbar .spacer { flex: 1; }
.topsearch { position: relative; flex: 1; max-width: 560px; }
.topsearch svg.i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.topsearch input { width: 100%; padding: 10px 44px 10px 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 13.5px; box-shadow: var(--shadow); }
.topsearch input::placeholder { color: var(--faint); }
.topsearch input:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 4px var(--pri-s); }
.topsearch kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px; background: var(--soft); }
.iconbtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink2); cursor: pointer; box-shadow: var(--shadow); }
.iconbtn:hover { color: var(--pri); border-color: var(--pri); }
.results { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-h); padding: 6px; max-height: 420px; overflow-y: auto; }
.results a { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-size: 13.5px; }
.results a:hover, .results a.on { background: var(--pri-s); text-decoration: none; }
.results a small { color: var(--muted); font-size: 12px; }
.results .k { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--pri); font-weight: 700; min-width: 64px; }
.results p { margin: 8px 10px; font-size: 13px; color: var(--muted); }

/* ---- page parts ---- */
.crumbs { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); margin: 0 0 10px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--pri); }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head h1 { font-weight: 700; font-size: clamp(22px, 2.4vw, 28px); letter-spacing: -.02em; line-height: 1.15; margin: 0; }
.head p { margin: 6px 0 0; color: var(--muted); max-width: 80ch; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 15px; font-weight: 650; margin: 0 0 4px; letter-spacing: -.005em; display: flex; align-items: center; gap: 8px; }
.card .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head .sub { margin: 4px 0 0; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.note { padding: 11px 14px; border-radius: var(--r-s); background: var(--pri-s); color: var(--pri-ink); margin: 0 0 16px; line-height: 1.5; }
.note.warn { background: var(--warn-s); color: var(--warn); }
.note.bad { background: var(--bad-s); color: var(--bad); }
.cols2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cols-dash { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.cols2 > .card, .cols3 > .card, .cols-dash > .card { margin-bottom: 0; }
.cols2, .cols3, .cols-dash { margin-bottom: 16px; }
.card .cols2 { margin-bottom: 0; gap: 28px; }

/* ---- KPI tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); overflow: hidden; }
.tile .top { display: flex; justify-content: space-between; align-items: center; }
.tile .t { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tile .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--pri-s); color: var(--pri); }
.tile .v { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.tile .s { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.tile .s b { font-weight: 600; }
.tile .s .bad { color: var(--bad); } .tile .s .good { color: var(--good); }
.tile .meter { margin-top: 12px; }
.tile.a2 .ico { background: var(--cyan-s); color: var(--cyan); }
.tile.a3 .ico { background: var(--violet-s); color: var(--violet); }
.tile.a4 .ico { background: var(--amber-s); color: var(--amber); }
.tile-v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.tile-v small { display: block; font-size: 12px; font-weight: 500; letter-spacing: 0; }

/* ---- meters and bars ---- */
.meter { height: 8px; border-radius: 8px; background: var(--soft2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--pri), var(--violet)); }
.meter.full i { background: linear-gradient(90deg, var(--amber), var(--bad)); }
.meter.cy i { background: linear-gradient(90deg, var(--cyan), var(--pri)); }
.hbar { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 76px; gap: 12px; align-items: center; font-size: 13px; padding: 5px 0; }
.hbar > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink2); }
.hbar .track { background: var(--soft2); border-radius: 6px; height: 8px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--pri)); border-radius: 6px; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.chart { position: relative; margin: 6px 0 18px; }
.chart .grid { position: absolute; inset: 0 0 22px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart .grid span { border-top: 1px dashed var(--line); }
.vbars { position: relative; display: flex; align-items: flex-end; gap: 8px; height: 180px; }
.vbars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.vbars .b i { display: block; width: 100%; max-width: 44px; background: linear-gradient(180deg, var(--pri), color-mix(in srgb, var(--pri) 55%, transparent)); border-radius: 6px 6px 2px 2px; min-height: 2px; transition: filter .15s; }
.vbars .b:hover i { filter: brightness(1.15); }
.vbars .b.now i { background: linear-gradient(180deg, var(--cyan), color-mix(in srgb, var(--cyan) 50%, transparent)); }
.vbars .b small { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

/* donut (colours set from code) */
.donut-wrap { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.donut { position: relative; width: 150px; height: 150px; border-radius: 50%; flex: none; background: var(--soft2); }
.donut::after { content: ""; position: absolute; inset: 20px; border-radius: 50%; background: var(--card); }
.donut .mid { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; }
.donut .mid b { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.donut .mid small { color: var(--muted); font-size: 11.5px; }
.legend { flex: 1; min-width: 160px; list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.legend li:last-child { border-bottom: 0; }
.legend li span:nth-child(2) { flex: 1; color: var(--ink2); }
.legend li b { font-variant-numeric: tabular-nums; font-weight: 600; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ---- needs attention ---- */
.att { display: flex; align-items: center; gap: 12px; padding: 10px 8px; margin: 0 -8px; border-radius: 9px; font-size: 13.5px; cursor: pointer; }
.att:hover { background: var(--soft); }
.att .sev { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; box-shadow: 0 0 0 4px var(--soft2); }
.att.bad .sev { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-s); }
.att.warn .sev { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-s); }
.att.zero .sev { background: var(--good); box-shadow: 0 0 0 4px var(--good-s); }
.att > span:nth-child(2) { flex: 1; color: var(--ink2); }
.att b { min-width: 30px; text-align: center; font-weight: 700; font-size: 12.5px; padding: 2px 8px; border-radius: 20px; background: var(--soft2); color: var(--ink2); font-variant-numeric: tabular-nums; }
.att.bad b { background: var(--bad-s); color: var(--bad); }
.att.warn b { background: var(--amber-s); color: var(--warn); }
.att.zero b { background: transparent; color: var(--faint); }
.att .chev { color: var(--faint); width: 15px; height: 15px; }
.att-list { margin: 0 0 8px 20px; padding: 4px 0 4px 12px; list-style: none; font-size: 13px; border-left: 2px solid var(--line); }
.att-list li { padding: 3px 0; }

/* renewals */
.ren { display: flex; align-items: center; gap: 14px; padding: 11px 8px; margin: 0 -8px; border-radius: 10px; cursor: pointer; }
.ren:hover { background: var(--soft); }
.ren .date { width: 48px; flex: none; text-align: center; border-radius: 10px; background: var(--soft2); padding: 5px 0; line-height: 1.1; }
.ren .date b { display: block; font-size: 17px; font-weight: 700; }
.ren .date small { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ren.soon .date { background: var(--amber-s); color: var(--warn); } .ren.soon .date small { color: var(--warn); }
.ren.late .date { background: var(--bad-s); color: var(--bad); } .ren.late .date small { color: var(--bad); }
.ren .what { flex: 1; min-width: 0; }
.ren .what b { display: block; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ren .what small { color: var(--muted); font-size: 12px; }
.ren .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; font-size: 13px; }

/* ---- buttons and fields ---- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-size: 13.5px; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn.primary { background: var(--pri); color: var(--on-pri); border-color: var(--pri); box-shadow: 0 1px 2px rgba(79,70,229,.3); }
.btn.primary:hover { background: var(--pri-h); border-color: var(--pri-h); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-s); border-color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .45; cursor: default; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; color: var(--ink2); font-weight: 600; }
.input, .select, textarea.input { padding: 9px 12px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--card); font-size: 13.5px; }
.input:focus, .select:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 4px var(--pri-s); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label, label.checks { display: flex; gap: 6px; align-items: center; }
input[type=checkbox] { accent-color: var(--pri); width: 15px; height: 15px; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.formgrid .wide { grid-column: 1 / -1; }
.field small.hint { color: var(--muted); font-size: 11.5px; }
.req { color: var(--bad); }
.errors { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--r-s); background: var(--bad-s); color: var(--bad); font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input, .filters .select { min-width: 170px; }
.picker { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-s); padding: 6px; margin-top: 10px; }
.picker label { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 7px; font-size: 13.5px; }
.picker label:hover { background: var(--soft); }
.picker small { color: var(--muted); }
.picker .eyebrow { margin: 10px 8px 4px; }

/* ---- pills and tags ---- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--soft2); color: var(--ink2); white-space: nowrap; text-transform: capitalize; }
.pill.open, .pill.up, .pill.approved { background: var(--good-s); color: var(--good); }
.pill.submitted { background: var(--amber-s); color: var(--warn); }
.pill.returned, .pill.down { background: var(--bad-s); color: var(--bad); }
.pill.unit-open { background: var(--pri-s); color: var(--pri-ink); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 20px; background: var(--soft2); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.card h2 .tag { margin-left: 0; }

/* ---- tables ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--soft); }
.tbl th:first-child { border-top-left-radius: 8px; } .tbl th:last-child { border-top-right-radius: 8px; }
.tbl td.nw { white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.link { cursor: pointer; }
.tbl tr.link:hover td { background: var(--pri-s); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td .meter { min-width: 90px; margin-top: 6px; height: 6px; }
.tbl-wrap { overflow-x: auto; }
.neg { color: var(--bad); }
.good { color: var(--good); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ok-line { color: var(--good); font-weight: 500; }
.warn-line { color: var(--warn); font-weight: 500; }
.foot-line { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.foot-line b { color: var(--ink); }

/* ---- detail pages ---- */
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 28px; }
.fields .f { min-width: 0; }
.fields .f span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.fields .f div { font-size: 14px; overflow-wrap: anywhere; white-space: pre-wrap; }
.fields .f.wide { grid-column: 1 / -1; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; }
.steps .done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.steps .txt { flex: 1; }
.steps .txt small { display: block; color: var(--muted); font-size: 12px; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.files li:last-child { border-bottom: 0; }
.alloc { font-size: 12.5px; color: var(--muted); }
.list { list-style: none; padding: 0; margin: 0; max-height: 50vh; overflow-y: auto; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }

/* ---- dialogs and toast ---- */
dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(540px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: var(--shadow-h); }
dialog::backdrop { background: rgba(7,10,20,.55); backdrop-filter: blur(2px); }
dialog.wide { width: min(780px, calc(100vw - 32px)); }
.dlg { padding: 24px 26px; }
.dlg h2 { font-weight: 700; font-size: 19px; letter-spacing: -.01em; margin: 0 0 8px; }
.dlg p { color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.dlg .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.dlg ul { margin: 0 0 10px; padding-left: 18px; max-height: 260px; overflow-y: auto; }
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: var(--side); color: #fff; padding: 11px 18px; border-radius: 12px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); box-shadow: var(--shadow-h); }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 1200px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-dash { grid-template-columns: 1fr; } }
@media (max-width: 1100px) { .fields, .cols3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 12px; }
  .side .brand { width: 100%; padding-bottom: 8px; }
  .side .group, .side .spacer, .side .me { display: none; }
  .side a.nav .lbl, .side a.nav .n { display: none; }
  .side a.nav[aria-current="page"]::before { display: none; }
  .shell .main { padding: 0 16px 50px; }
  .cols2, .fields, .formgrid { grid-template-columns: 1fr; }
  .topsearch kbd { display: none; }
  .topbar .spacer { display: none; }
  .topsearch { min-width: 0; }
}
@media (max-width: 520px) { .tiles { gap: 10px; } .tile { padding: 14px; } .tile .v { font-size: 24px; } .tile .ico { width: 30px; height: 30px; } }
@media print { .side, .topbar, .tools { display: none !important; } .shell { display: block; } .card, .tile { box-shadow: none; } }

/* ---- 0.2: + New, access note, register health, insights ---- */
.newmenu { position: relative; }
.newmenu .btn.primary { height: 40px; }
.newlist { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 240px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-h); padding: 6px; }
.newlist button, .newlist a { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; color: var(--ink); font-size: 13.5px; cursor: pointer; text-align: left; }
.newlist button:hover, .newlist a:hover { background: var(--pri-s); text-decoration: none; }
.newlist button[disabled] { opacity: .45; cursor: default; }
.newlist svg.i { color: var(--muted); width: 16px; height: 16px; }
.newlist a { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; border-radius: 0 0 8px 8px; }
.note.access { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.note.access > div { flex: 1; min-width: 240px; }
.card.health { display: flex; gap: 28px; align-items: flex-start; }
.card.health .hc-body { flex: 1; min-width: 0; }
.ring { position: relative; width: 120px; height: 120px; border-radius: 50%; flex: none; background: var(--soft2); }
.ring::after { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--card); }
.ring .mid { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; }
.ring .mid b { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.ring .mid small { color: var(--muted); font-size: 11.5px; }
.card.health.big .ring { width: 150px; height: 150px; }
.card.health.big .ring::after { inset: 15px; }
.hc-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px 70px; gap: 14px; align-items: center; padding: 8px 8px; margin: 0 -8px; border-radius: 8px; color: var(--ink2); font-size: 13px; }
.hc-row:hover { background: var(--soft); text-decoration: none; }
.hc-row b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.hc-row.na { opacity: .6; }
.vbars .b.prev i { opacity: .38; }
.tile-v.left { text-align: left; margin: 4px 0 12px; }
.card .eyebrow { margin-top: 14px; }
.card .eyebrow:first-child { margin-top: 0; }
@media (max-width: 900px) { .card.health { flex-direction: column; align-items: center; } .card.health .hc-body { width: 100%; } .hc-row { grid-template-columns: minmax(0, 1fr) 90px 56px; } .newmenu .btn.primary { padding: 8px 10px; } }
.pill.nocap { text-transform: none; }
.vbars .b.late i { background: linear-gradient(180deg, var(--bad), color-mix(in srgb, var(--bad) 45%, transparent)); }

/* ---- 0.3: joiners and leavers, budget ---- */
a.plain { color: inherit; } a.plain:hover { color: var(--pri); text-decoration: none; }
.pre { white-space: pre-wrap; }
.mcard { display: flex; gap: 12px; align-items: center; padding: 10px 8px; margin: 0 -8px; border-radius: 10px; color: var(--ink); }
.mcard:hover { background: var(--soft); text-decoration: none; }
.mcard .mk { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--cyan-s); color: var(--cyan); flex: none; }
.mcard.leave .mk { background: var(--violet-s); color: var(--violet); }
.mcard .mb { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mcard .mb b { font-weight: 600; font-size: 13.5px; }
.mcard .mb small { color: var(--muted); font-size: 12px; }
.mcard .mb .meter { height: 5px; margin-top: 3px; max-width: 320px; }
.mcard .mp { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter.big { height: 10px; margin: 2px 0 10px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .txt { flex: 1; min-width: 0; }
.checklist .txt small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.checklist li.done .txt { color: var(--muted); }
.checklist li.done .txt > :first-child { text-decoration: none; }
.tick { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; flex: none; padding: 0; color: #fff; }
.tick:hover:not([disabled]) { border-color: var(--pri); }
.tick svg.i { width: 15px; height: 15px; stroke-width: 2.6; }
.checklist li.done .tick { background: var(--good); border-color: var(--good); }
.tick[disabled] { cursor: default; }
.addstep { display: flex; gap: 8px; margin-top: 14px; }
.addstep .input { flex: 1; }
.legend-line { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin: -6px 0 4px; }
.legend-line .lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg.bu, .pairs .pr i.bu { background: var(--soft2); box-shadow: inset 0 0 0 1px var(--faint); }
.lg.ac, .pairs .pr i.ac { background: linear-gradient(180deg, var(--pri), color-mix(in srgb, var(--pri) 60%, transparent)); }
.lg.over, .pairs .pr i.ac.over { background: linear-gradient(180deg, var(--bad), color-mix(in srgb, var(--bad) 55%, transparent)); }
.vbars.pairs .b .pr { display: flex; align-items: flex-end; gap: 3px; width: 100%; max-width: 48px; height: 100%; }
.vbars.pairs .b .pr i { flex: 1; min-height: 2px; border-radius: 4px 4px 1px 1px; }
.vbars.pairs .b.cur small { color: var(--pri); font-weight: 700; }
.bgrid th, .bgrid td { padding: 6px 4px; }
.bgrid td:first-child, .bgrid th:first-child { padding-left: 12px; min-width: 150px; position: sticky; left: 0; background: var(--card); z-index: 1; }
.bgrid th:first-child { background: var(--soft); }
.bgrid td.m { padding: 3px 2px; }
.bgrid th.curcol { color: var(--pri); }
.bgrid input.cell { width: 100%; min-width: 64px; border: 1px solid transparent; background: transparent; text-align: right; padding: 6px; border-radius: 7px; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.bgrid input.cell:hover { border-color: var(--line); }
.bgrid input.cell:focus { outline: none; border-color: var(--pri); background: var(--card); box-shadow: 0 0 0 3px var(--pri-s); }
.bgrid input.cell.changed { background: var(--amber-s); }
.bgrid input.cell.bad { background: var(--bad-s); color: var(--bad); }
.bgrid tr.total td { font-weight: 700; border-top: 2px solid var(--line); background: var(--soft); }
.rowtools { margin-top: 2px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--pri); font-size: 11.5px; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.dirty { font-size: 12.5px; color: var(--warn); font-weight: 700; }

/* ---- 0.4: read a document ---- */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 44px 20px; border: 2px dashed var(--line); border-radius: var(--r); background: var(--card); color: var(--muted); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.drop svg.i { width: 30px; height: 30px; color: var(--pri); }
.drop b { color: var(--ink); font-size: 15px; }
.drop:hover, .drop.over { border-color: var(--pri); background: var(--pri-s); }
.formgrid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.input.slim, .select.slim { padding: 6px 8px; font-size: 12.5px; width: 100%; min-width: 150px; }
.rlines td { vertical-align: top; }
.rlines td small { display: block; margin-top: 3px; }
.tbl tr.skip td { opacity: .45; }
@media (max-width: 1100px) { .formgrid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- 0.4: easier forms ---- */
.fgroup { border: 0; padding: 0; margin: 0 0 6px; min-width: 0; }
.fgroup legend, details.fgroup > summary { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--pri); padding: 10px 0 8px; margin: 0; width: 100%; border-top: 1px solid var(--line); }
.fgroup:first-of-type legend { border-top: 0; padding-top: 2px; }
details.fgroup > summary { cursor: pointer; list-style: none; color: var(--muted); }
details.fgroup > summary::before { content: "+ "; } details.fgroup[open] > summary::before { content: "− "; }
.segpick { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--soft); border-radius: 11px; padding: 3px; }
.segpick label { position: relative; }
.segpick input { position: absolute; opacity: 0; pointer-events: none; }
.segpick span { display: block; padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--ink2); cursor: pointer; }
.segpick input:checked + span { background: var(--card); color: var(--pri); font-weight: 600; box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.06); }
.segpick input:focus-visible + span { outline: 2px solid var(--pri); }
.switchbox { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; }
.switchbox input { appearance: none; width: 38px; height: 22px; border-radius: 22px; background: var(--soft2); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switchbox input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switchbox input:checked { background: var(--pri); } .switchbox input:checked::after { transform: translateX(16px); }
.switchbox span { font-size: 13px; color: var(--ink2); }
.linkrow { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.field .linkbtn { align-self: flex-start; }
dialog .formgrid .field { margin-bottom: 12px; }
.select.narrow { width: auto; min-width: 190px; max-width: 280px; }
.kv .select.narrow { flex: none; }
.card .checks { margin-top: 10px; font-size: 13px; color: var(--ink2); }
