/* ROOWEE dashboard.
 *
 * A data UI: scanned and operated, not read top to bottom. The frame is a
 * solid brand bar, a white sidebar, and white cards on a soft grey plane; each
 * screen opens with a row of figures, one of them in brand green — the number
 * that screen exists to answer — and the rest as its context.
 *
 * Two palettes, kept apart on purpose. Brand green marks *what this is*: the
 * headline tile, the active nav item, a good figure. The status set — good,
 * warning, serious, critical — marks *what state a thing is in* and is never
 * borrowed for decoration, so a red number always means something is wrong.
 */

:root {
  color-scheme: light;

  --brand:        #0e8f6a;   /* the bar, the hero tile, the active item */
  --brand-deep:   #0b7657;
  --brand-wash:   #e6f4ef;   /* active nav, soft highlights */
  --brand-ink:    #0a6b4f;   /* green as text on white */

  --action:       #2f80ed;   /* the one button colour that means "do this" */
  --action-wash:  #e8f1fd;

  --plane:        #f4f6f8;   /* the page */
  --surface:      #ffffff;   /* cards */
  --sunk:         #f7f9fb;   /* table heads, quiet wells */
  --ink:          #1f2a37;
  --ink-2:        #46546a;
  --muted:        #7a8794;
  --line:         #e6eaef;
  --grid:         #e6eaef;
  --shadow:       0 1px 2px rgba(31,42,55,.04), 0 8px 24px -16px rgba(31,42,55,.18);

  /* Status — reserved. Each ships with a label or icon; hue never carries
     meaning alone. */
  --good:         #0e8f6a;
  --warning:      #e0a63c;
  --serious:      #e06b3a;
  --critical:     #d64545;

  --radius: 12px;
  --radius-sm: 8px;
  --gap: 18px;
  --side-w: 236px;
  --top-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand-wash: #143b30;
    --brand-ink:  #6fcfae;
    --action-wash:#17324f;
    --plane:      #0f1419;
    --surface:    #171d24;
    --sunk:       #131920;
    --ink:        #e7ecf1;
    --ink-2:      #b4bfcb;
    --muted:      #7f8b98;
    --line:       #253040;
    --grid:       #253040;
    --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-wash: #143b30;
  --brand-ink:  #6fcfae;
  --action-wash:#17324f;
  --plane:      #0f1419;
  --surface:    #171d24;
  --sunk:       #131920;
  --ink:        #e7ecf1;
  --ink-2:      #b4bfcb;
  --muted:      #7f8b98;
  --line:       #253040;
  --grid:       #253040;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.5 "Rubik", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -0.01em; }

/* ── the frame ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px 0 18px;
  background: var(--brand); color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand-name { font-size: 19px; font-weight: 500; letter-spacing: -0.01em; }
.brand-name b { font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user { font-size: 13px; opacity: .9; }
.topbar button.primary {
  background: #fff; color: var(--brand-ink); border-color: #fff;
}
.topbar button.primary:hover { background: #f1faf6; }
.topbar button.ghost {
  background: transparent; color: #fff; border-color: rgba(255,255,255,.35);
  padding: 6px 8px; display: inline-grid; place-items: center;
}
.topbar button.ghost:hover { background: rgba(255,255,255,.12); }

.frame {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--top-h));
}
.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 12px 24px;
  display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: var(--top-h);
  height: calc(100vh - var(--top-h));
  overflow-y: auto;
}
.side-scope {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 14px; border-bottom: 1px solid var(--line);
}
.side-scope-mark {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--brand); color: #fff; display: grid; place-items: center;
}
.side-scope-text { font-weight: 600; font-size: 15px; line-height: 1.25; }
.side-foot { margin-top: auto; font-size: 12px; padding: 0 10px; }

.main {
  min-width: 0;
  padding: 24px 28px 96px;
  max-width: 1440px;
}

/* ── navigation ────────────────────────────────────────────────────────── */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 500;
}
.nav-item svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.nav-item:hover { background: var(--sunk); color: var(--ink); }
.nav-item.on { background: var(--brand-wash); color: var(--brand-ink); }
.nav-item.on svg { color: var(--brand-ink); }
.nav-item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* ── screen head + stat row ────────────────────────────────────────────── */
.screen-head { display: flex; align-items: baseline; gap: 14px; margin: 0 0 16px; }
.screen-title {
  font-size: 24px; font-weight: 500; margin: 0; color: var(--ink);
  position: relative; padding-right: 16px;
}
.screen-title::after {
  /* the reference's hairline running off the title */
  content: ""; position: absolute; left: 100%; top: 58%; width: 60vw; max-width: 900px;
  height: 1px; background: var(--line);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 14px 16px; text-align: center;
  display: grid; gap: 4px; align-content: start;
  min-height: 150px;
}
.stat-icon {
  width: 34px; height: 34px; margin: 0 auto 4px; color: var(--ink-2);
}
.stat-icon svg { width: 100%; height: 100%; }
.stat-label { font-size: 15px; color: var(--ink-2); line-height: 1.25; }
.stat-value {
  font-size: 26px; font-weight: 500; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.1;
}
.stat-note { font-size: 12px; color: var(--muted); }
.stat.hero {
  background: var(--brand); color: #fff; box-shadow: none;
  justify-items: center; align-content: center;
}
.stat.hero .stat-value { color: #fff; font-size: 38px; font-weight: 600; }
.stat.hero .stat-label { color: #fff; opacity: .92; font-size: 16px; }
.stat.hero .stat-note  { color: #fff; opacity: .78; }
.stat.serious .stat-value  { color: var(--serious); }
.stat.critical .stat-value { color: var(--critical); }
.stat.good .stat-value     { color: var(--brand-ink); }
a.stat { text-decoration: none; }
a.stat:hover { box-shadow: 0 1px 2px rgba(31,42,55,.06), 0 12px 28px -14px rgba(31,42,55,.28); }

/* ── controls ──────────────────────────────────────────────────────────── */
button, select, input[type="text"], input[type="search"], input[type="date"] {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 12px;
}
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--action); outline-offset: 2px;
}
button.primary {
  background: var(--action); color: #fff; border-color: var(--action); font-weight: 500;
}
button.primary:hover { background: #2a73d6; border-color: #2a73d6; }
button.small { padding: 4px 10px; font-size: 13px; }
button.small.primary { background: var(--action-wash); color: var(--action); border-color: var(--action-wash); }
button.small.primary:hover { background: #d9e8fb; }

/* ── sections + cards ──────────────────────────────────────────────────── */
section { margin-top: 30px; }
section > h2, .chart-head h2 {
  font-size: 17px; font-weight: 500; margin: 0 0 4px; color: var(--brand-ink);
}
section > .caption, .caption { color: var(--muted); font-size: 13px; margin: 0 0 14px; max-width: 78ch; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.table-scroll { overflow-x: auto; padding: 6px; }

/* ── today: the action list under the stat row ─────────────────────────── */
.today-lead { display: none; }   /* carried by the hero tile now */
.today-sub  { display: none; }
.today-clear { color: var(--brand-ink); font-size: 15px; margin: 0; }

.act {
  display: grid; grid-template-columns: minmax(84px, auto) 1fr; gap: 14px;
  align-items: baseline;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--line); border-radius: var(--radius);
  padding: 12px 15px; margin-bottom: 8px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
a.act:hover { border-color: var(--muted); border-left-color: var(--muted); }
.act.urgent { border-left-color: var(--serious); }
.act-amt { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 17px; white-space: nowrap; }
.act.urgent .act-amt { color: var(--serious); }
.act-body { display: block; min-width: 0; }
.act-body b { display: block; font-weight: 500; font-size: 15px; }
.act-body .muted { display: block; font-size: 13px; margin-top: 1px; }

/* ── chart ─────────────────────────────────────────────────────────────── */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.chart-scroll { overflow-x: auto; margin-top: 12px; }
svg.chart { display: block; min-width: 640px; }
svg.chart text { font: 11px "Rubik", ui-sans-serif, -apple-system, sans-serif; }
.tick { fill: var(--muted); }
.bar-label { fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axis { stroke: var(--grid); stroke-width: 1; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 40; opacity: 0;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px; min-width: 150px;
  box-shadow: 0 6px 24px -12px rgba(0,0,0,.35);
  transition: opacity .1s;
}
.tooltip .t-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 14px; }
.tooltip .t-row span:last-child { font-variant-numeric: tabular-nums; }

/* ── tables ────────────────────────────────────────────────────────────── */
table { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 560px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; white-space: nowrap;
  background: var(--sunk);
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
thead th:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--sunk); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td b { font-weight: 500; }

/* fill bar: used against cap, inside the ledger row */
.fill { position: relative; height: 7px; border-radius: 4px; background: var(--grid); min-width: 90px; }
.fill > i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--good); }
.fill.none > i { background: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 100px; white-space: nowrap;
  border: 1px solid currentColor; background: color-mix(in srgb, currentColor 10%, transparent);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip.on_track   { color: var(--good); }
.chip.at_risk    { color: var(--serious); }
.chip.unenrolled { color: var(--muted); }
.chip.forfeited  { color: var(--critical); }
.chip.drained    { color: var(--good); }   /* fully used is success */
.chip.closed     { color: var(--muted); }

.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 22px; text-align: center; }
.err {
  border: 1px solid var(--critical); color: var(--critical); background: var(--surface);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px;
}
.net-pos { color: var(--brand-ink); }
.net-neg { color: var(--critical); }
.sr-only, .visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ── rotation grid ─────────────────────────────────────────────────────── */
.uplift {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line);
}
.uplift .big {
  font-size: 26px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--brand-ink);
}
.uplift .why { color: var(--ink-2); font-size: 14px; }

.rot { overflow-x: auto; }
.rot-grid { display: grid; gap: 3px; min-width: 700px; font-size: 11px; font-variant-numeric: tabular-nums; }
.rot-grid .hd {
  color: var(--muted); font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; text-align: center; padding-bottom: 4px;
}
.rot-grid .rl {
  display: flex; align-items: center; padding-right: 10px;
  font-size: 13px; white-space: nowrap; color: var(--ink);
}
.rot-cell {
  border-radius: 6px; padding: 7px 2px; text-align: center;
  font-weight: 600; font-size: 10px; letter-spacing: .02em;
  border: 1px solid transparent;
  display: flex; gap: 2px; justify-content: center; align-items: stretch;
}
/* Card identity, not status: which of the household's cards pays. */
.rot-cell.c0, .rot-part.c0 { background: color-mix(in srgb, #2f80ed 16%, transparent); color: #2565bd; border-color: #2f80ed; }
.rot-cell.c1, .rot-part.c1 { background: color-mix(in srgb, #e06b3a 16%, transparent); color: #b8542a; border-color: #e06b3a; }
.rot-cell.c2, .rot-part.c2 { background: color-mix(in srgb, #0e8f6a 16%, transparent); color: #0a6b4f; border-color: #0e8f6a; }
.rot-cell.c3, .rot-part.c3 { background: color-mix(in srgb, #6a4fc9 16%, transparent); color: #5a3fb3; border-color: #6a4fc9; }
.rot-cell.none, .rot-part.none { background: var(--sunk); color: var(--muted); }
.rot-cell.split { background: var(--sunk); }
.rot-part {
  flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  font-style: normal; border-radius: 4px; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center;
}
.rot-cell:not(.split) .rot-part { background: none; border-color: transparent; color: inherit; }

.explain {
  font-size: 15px; line-height: 1.55; color: var(--ink);
  margin: 0 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.badge {
  display: inline-block; margin-left: 8px; padding: 2px 8px;
  border: 1px solid var(--line); border-radius: 100px;
  font-size: 11px; color: var(--muted); vertical-align: middle; cursor: help;
}

/* ── card identity ─────────────────────────────────────────────────────── */
.face {
  display: inline-grid; gap: 1px; padding: 9px 13px; min-width: 168px;
  border-radius: 8px; border: 1px solid transparent; background: var(--sunk);
  box-shadow: inset 0 -14px 24px -18px rgba(0,0,0,.35);
}
.face-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.face-meta { font-size: 12px; opacity: .85; font-variant-numeric: tabular-nums; }
.face-platinum       { background: #6d7178; border-color: #8b9099; color: #fff; }
.face-gold           { background: #8a6d1f; border-color: #b08d2a; color: #fff; }
.face-delta          { background: #2b2f38; border-color: #454b57; color: #e8ecf2; }
.face-sapphire       { background: #17335c; border-color: #2a4d7f; color: #e8eef7; }
.face-sapphire-light { background: #2c5183; border-color: #3f6ba6; color: #eef3fa; }
.face-bonvoy         { background: #1f3a52; border-color: #33566f; color: #e6eef4; }
.face-elite          { background: #7a1f2b; border-color: #a13040; color: #fdeef0; }
.face-generic        { background: var(--sunk); border-color: var(--line); color: var(--ink); box-shadow: none; }

/* ── household ─────────────────────────────────────────────────────────── */
.people { display: flex; flex-wrap: wrap; gap: 10px; }
.person {
  display: grid; gap: 1px; padding: 10px 14px; min-width: 150px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sunk);
}
.person b { font-weight: 500; }
.person .muted { font-size: 12px; }
.person.add { display: flex; align-items: center; gap: 6px; background: none; }
.person form.invite { display: flex; gap: 6px; margin-top: 8px; }
.person form.invite input { width: 170px; padding: 5px 8px; font-size: 13px; }
.person.add input { width: 140px; padding: 6px 9px; font-size: 14px; }
select.holder, select.pick { font-size: 13px; padding: 5px 9px; max-width: 230px; }
select.pick { margin-right: 6px; }

/* ── spend ─────────────────────────────────────────────────────────────── */
#spend-form input { padding: 9px 12px; }
.spend-best {
  display: grid; grid-template-columns: minmax(90px,auto) 1fr; gap: 14px; align-items: baseline;
  margin-top: 14px; padding: 14px 16px;
  background: var(--brand-wash); border: 1px solid transparent;
  border-left: 3px solid var(--brand); border-radius: var(--radius-sm);
}
.spend-best b { display: block; font-size: 17px; font-weight: 500; }
.spend-best .muted { display: block; font-size: 13px; margin-top: 3px; color: var(--ink-2); }
.spend-amt { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 17px; color: var(--brand-ink); white-space: nowrap; }
.spend-alt { display: grid; grid-template-columns: minmax(90px,auto) 1fr; gap: 14px; align-items: baseline; padding: 8px 16px; font-size: 14px; }
.spend-alt .spend-amt { color: var(--muted); font-size: 15px; }
.spend-alt .muted { display: block; font-size: 12px; }
.spend-none { margin: 14px 0 0; font-size: 15px; color: var(--ink-2); }
.spend-none b { display: block; color: var(--ink); font-weight: 500; }

/* ── responsive ────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .frame { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }
  .side-scope { display: none; }
  .side-foot { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 8px 12px; }
  .main { padding: 18px 16px 72px; }
  .screen-title::after { display: none; }
  .topbar-user { display: none; }
}
@media (max-width: 520px) {
  .act, .spend-best, .spend-alt { grid-template-columns: 1fr; gap: 2px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* A fold for things that are done but may need correcting. */
details.fold { border-top: 1px solid var(--line); }
details.fold > summary {
  cursor: pointer; padding: 10px 12px; font-size: 13px; color: var(--muted);
  list-style: none;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸ "; }
details.fold[open] > summary::before { content: "▾ "; }

/* Personal / Business / All. A radio group drawn as a pill. */
.seg {
  display: inline-flex; padding: 3px; border-radius: 999px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28);
}
.seg button {
  border: 0; background: transparent; color: #fff; font: inherit; font-size: 13px;
  padding: 4px 12px; border-radius: 999px; cursor: pointer; opacity: .85;
}
.seg button:hover { opacity: 1; }
.seg button[aria-checked="true"] {
  background: #fff; color: var(--brand-ink); opacity: 1; font-weight: 500;
}
.seg button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.face-tag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px;
  font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
  background: rgba(0,0,0,.18); color: inherit; vertical-align: middle;
}
@media (max-width: 720px) { .seg button { padding: 4px 9px; } }
