/* Tells UI — Vestra-style visual language, written from scratch. */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #ffffff; --sidebar: #f8f8f8; --card: #ffffff; --head: #f7f7f8;
  --text: #020617; --secondary: #475569; --muted: #64748b; --faint: #94a3b8;
  --line: rgba(0,0,0,.05); --card-border: rgba(24,24,27,.07); --row: rgba(24,24,27,.04);
  --hover: #f1f5f9; --nav-active: #eff6ff; --nav-fg: #2563eb; --nav-border: rgba(37,99,235,.18);
  --cta: #2563eb; --cta-hover: #1d4ed8; --cta-fg: #fff;
  --input: #fcfcfc; --input-border: rgba(24,24,27,.08); --icon-bg: #f8fafc; --muted-bg: #f1f5f9;
  --shadow: 0 0 0 1px rgba(0,0,0,.04); --shadow-pop: 0 8px 24px rgba(0,0,0,.05);
  --series-1: #2a78d6; --series-prior: #898781; --grid: #e9e8e3; --axis: #c3c2b7; --axis-ink: #898781;
  --good: #0ca30c; --good-ink: #006300; --good-soft: rgba(0,179,106,.10);
  --warn: #fab219; --warn-ink: #8a5a00; --warn-soft: #fff8e6;
  --bad: #d03b3b; --bad-ink: #b42323; --bad-soft: #fef2f2;
  --info: #2563eb; --info-ink: #1d4ed8; --info-soft: #eff6ff;
  --lose-soft: rgba(241,77,110,.10);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121212; --sidebar: #191919; --card: #141414; --head: #101010;
    --text: #fafafa; --secondary: #a1a1aa; --muted: #a1a1aa; --faint: #71717a;
    --line: rgba(255,255,255,.05); --card-border: rgba(255,255,255,.06); --row: rgba(255,255,255,.04);
    --hover: rgba(255,255,255,.05); --nav-active: rgba(255,255,255,.08); --nav-fg: #fafafa; --nav-border: rgba(255,255,255,.06);
    --cta: #3b82f6; --cta-hover: #2563eb;
    --input: #141414; --input-border: rgba(255,255,255,.07); --icon-bg: #1e1e1e; --muted-bg: #1e1e1e;
    --shadow: 0 0 0 1px rgba(255,255,255,.04); --shadow-pop: 0 8px 30px rgba(0,0,0,.35);
    --series-1: #3987e5; --series-prior: #6f6e69; --grid: #262624; --axis: #383835; --axis-ink: #898781;
    --good-ink: #2fbf4a; --good-soft: rgba(12,163,12,.14);
    --warn-ink: #fab219; --warn-soft: rgba(250,178,25,.10);
    --bad-ink: #f06c6c; --bad-soft: rgba(239,68,68,.12);
    --info-ink: #7fb2ff; --info-soft: rgba(59,130,246,.12);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212; --sidebar: #191919; --card: #141414; --head: #101010;
  --text: #fafafa; --secondary: #a1a1aa; --muted: #a1a1aa; --faint: #71717a;
  --line: rgba(255,255,255,.05); --card-border: rgba(255,255,255,.06); --row: rgba(255,255,255,.04);
  --hover: rgba(255,255,255,.05); --nav-active: rgba(255,255,255,.08); --nav-fg: #fafafa; --nav-border: rgba(255,255,255,.06);
  --cta: #3b82f6; --cta-hover: #2563eb;
  --input: #141414; --input-border: rgba(255,255,255,.07); --icon-bg: #1e1e1e; --muted-bg: #1e1e1e;
  --shadow: 0 0 0 1px rgba(255,255,255,.04); --shadow-pop: 0 8px 30px rgba(0,0,0,.35);
  --series-1: #3987e5; --series-prior: #6f6e69; --grid: #262624; --axis: #383835; --axis-ink: #898781;
  --good-ink: #2fbf4a; --good-soft: rgba(12,163,12,.14);
  --warn-ink: #fab219; --warn-soft: rgba(250,178,25,.10);
  --bad-ink: #f06c6c; --bad-soft: rgba(239,68,68,.12);
  --info-ink: #7fb2ff; --info-soft: rgba(59,130,246,.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100dvh; }
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 16px; gap: 6px; position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 16px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--cta); color: #fff; display: grid; place-items: center; }
.brand b { display: block; font-size: 15px; font-weight: 600; }
.brand small { color: var(--muted); font-size: 12px; }
.nav-group { margin-top: 10px; }
.nav-title { font-size: 12px; font-weight: 600; color: var(--secondary); padding: 6px 10px; text-transform: none; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: var(--secondary); font-weight: 500; border: 1px solid transparent;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--nav-active); color: var(--nav-fg); border-color: var(--nav-border); }
.nav svg { width: 16px; height: 16px; flex: none; }
.sidebar-foot { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-size: 12px; color: var(--muted); }
.sidebar-foot b { color: var(--text); font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 28px;
  border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5;
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--secondary); font-weight: 500; min-width: 0; }
.crumbs .here { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs svg { width: 14px; height: 14px; color: var(--faint); }
.topbar .spacer { flex: 1; }
.search { position: relative; width: min(360px, 40vw); }
.search input {
  width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--input-border); background: var(--input);
  color: var(--text); padding: 0 12px 0 36px; font: inherit;
}
.search input::placeholder { color: var(--faint); }
.search svg { position: absolute; left: 11px; top: 11px; width: 16px; height: 16px; color: var(--faint); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--input-border); background: var(--card);
  display: grid; place-items: center; color: var(--text);
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 17px; height: 17px; }
.content { padding: 24px 28px 48px; display: grid; gap: 18px; max-width: 1440px; width: 100%; }

/* ---------- cards & tiles ---------- */
.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-wide { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: 16px; padding: 18px 20px;
  box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card-head .sub { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.ico {
  width: 28px; height: 28px; border-radius: 8px; background: var(--icon-bg); border: 1px solid var(--card-border);
  display: grid; place-items: center; color: var(--text); flex: none;
}
.ico svg { width: 15px; height: 15px; }
.tile .label { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 13px; }
.tile .value { font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin: 18px 0 4px; }
.tile .note { color: var(--muted); font-size: 12.5px; }
.hero { font-size: 40px; font-weight: 600; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }

/* ---------- chips, pills, status ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  background: var(--muted-bg); color: var(--secondary); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.chip.blue { background: var(--info-soft); color: var(--info-ink); }
.chip svg { width: 12px; height: 12px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.pill.up { background: var(--good-soft); color: var(--good-ink); }
.pill.down { background: var(--lose-soft); color: var(--bad-ink); }
.pill svg { width: 11px; height: 11px; }
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--card-border); }
.insight + .insight { margin-top: 10px; }
.insight .tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.insight .tag svg { width: 14px; height: 14px; }
.insight.good { background: var(--good-soft); } .insight.good .tag { color: var(--good-ink); }
.insight.warn { background: var(--warn-soft); } .insight.warn .tag { color: var(--warn-ink); }
.insight.bad { background: var(--bad-soft); } .insight.bad .tag { color: var(--bad-ink); }
.insight.info { background: var(--info-soft); } .insight.info .tag { color: var(--info-ink); }

/* ---------- forms ---------- */
.analyze { display: flex; gap: 10px; flex-wrap: wrap; }
.analyze input[type=text] {
  flex: 1 1 320px; height: 44px; border-radius: 12px; border: 1px solid var(--input-border); background: var(--input);
  color: var(--text); padding: 0 14px; font: inherit;
}
.analyze input[type=number] { width: 120px; height: 44px; border-radius: 12px; border: 1px solid var(--input-border); background: var(--input); color: var(--text); padding: 0 12px; font: inherit; }
.btn {
  height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid rgba(255,255,255,.18); background: var(--cta); color: var(--cta-fg);
  font: inherit; font-weight: 600; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.32); display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--cta-hover); }
.btn.ghost { background: var(--card); color: var(--text); border-color: var(--input-border); box-shadow: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: 13px; }
table.data th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 9px 10px; background: var(--head); white-space: nowrap;
}
table.data th:first-child { border-radius: 10px 0 0 10px; } table.data th:last-child { border-radius: 0 10px 10px 0; }
table.data td { padding: 10px; background: var(--row); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td:first-child { border-radius: 10px 0 0 10px; } table.data td:last-child { border-radius: 0 10px 10px 0; }
table.data tr:hover td { background: var(--hover); }
table.data .num { text-align: right; }
.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 8px; flex: none; }
.who b { font-weight: 600; display: block; }
.who small { color: var(--faint); font-size: 11px; }

/* allocation bar (Vestra-style) */
.alloc { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.alloc .track { flex: 1; height: 6px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; }
.alloc .fill { height: 100%; border-radius: 99px; background: var(--series-1); }
.alloc span { width: 46px; text-align: right; color: var(--secondary); font-size: 12px; font-variant-numeric: tabular-nums; }

/* meter (rate traits) */
.meter { height: 6px; border-radius: 99px; background: var(--info-soft); position: relative; margin: 12px 0 6px; }
.meter .fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--series-1); }
.meter .ci { position: absolute; top: -3px; height: 12px; border-left: 1px solid var(--axis-ink); border-right: 1px solid var(--axis-ink); }

/* ---------- charts ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--axis-ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .val { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-prior); }
.chart .col:hover .s1, .chart .col:hover .s2 { opacity: .78; }
.chart .hit { fill: transparent; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--secondary); font-size: 12.5px; margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .k1 { background: var(--series-1); } .legend .k2 { background: var(--series-prior); }
details.tableview { margin-top: 10px; color: var(--secondary); font-size: 12.5px; }
details.tableview summary { cursor: pointer; }
details.tableview table { margin-top: 8px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
details.tableview td, details.tableview th { padding: 4px 12px 4px 0; text-align: left; }

/* ---------- traits & evidence ---------- */
.trait h3 { margin: 0; font-size: 14px; font-weight: 600; }
.trait .big { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 10px; }
.trait p { margin: 6px 0 0; color: var(--secondary); font-size: 13px; }
.evidence { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.evidence li { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; color: var(--secondary); }
.evidence a { color: var(--info-ink); font-weight: 500; white-space: nowrap; }
.evidence a:hover { text-decoration: underline; }
.progress { height: 8px; border-radius: 99px; background: var(--info-soft); overflow: hidden; margin: 14px 0 8px; }
.progress .fill { height: 100%; background: var(--series-1); border-radius: 99px; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* ---------- login ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--sidebar); }
.auth-card { width: min(400px, 100%); display: grid; gap: 12px; padding: 28px; box-shadow: var(--shadow-pop); }
.auth-card h1 { margin: 6px 0 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.auth-card p { margin: 0; }
.auth-card label { font-size: 13px; font-weight: 500; color: var(--secondary); margin-top: 4px; }
.auth-card input[type=password] {
  height: 44px; border-radius: 12px; border: 1px solid var(--input-border); background: var(--input);
  color: var(--text); padding: 0 14px; font: inherit;
}
.auth-card input[type=password]:focus { outline: 2px solid var(--cta); outline-offset: 1px; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 4px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-wide, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
  .sidebar .nav-group, .sidebar-foot { display: none; }
  .brand { border: 0; margin: 0; padding: 0; }
  .topbar { padding: 0 16px; } .search { display: none; }
  .content { padding: 16px; } .g4, .g2 { grid-template-columns: 1fr; }
}
