/* Roaming Therapy finance dashboard — white-first handoff system, Roaming Therapy palette.
   Token names follow the style handoff (paper/cream/muted/soft-fill/ink/slate/gold→brand/deep/line). */
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-latin.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Lora"; src: url("/static/fonts/lora-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --paper: #ffffff;        /* page background */
  --cream: #fcf8f7;        /* RT site global cream (--e-global-color-1504cac) → cards, sidebar */
  --muted: #f6f0ee;        /* table header, zebra, hover (derived from cream) */
  --soft-fill: #e7f6f9;    /* active nav, icon chips (tint of RT teal) */
  --ink: #111111;          /* RT site text (#111111) */
  --slate: #475569;        /* RT site secondary text */
  --brand: #08a9c9;        /* RT primary teal (logo + --e-global-color-primary) → replaces handoff gold */
  --brand-hover: #0797b4;
  --deep: #06728a;         /* deep teal for accent TEXT on light (5.5:1) → replaces handoff deep gold */
  --accent: #f61867;       /* RT secondary pink (logo + --e-global-color-secondary); rare: wordmark, highlights */
  --navy: #324a6d;         /* RT site heading navy; third chart series */
  --line: #ebe3e0;         /* warm hairline */
  --ok: #0f7a55;  --ok-bg: #e7f5ef;
  --warn: #9a5b0b; --warn-bg: #fdf3e2;
  --bad: #c8134f; --bad-bg: #fde8ef;   /* deep RT pink for attention */
  --info: #06728a; --info-bg: #e7f6f9;
  --radius: 0.75rem;
  --shadow: 0 8px 28px rgb(17 40 56 / 6%);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-lead: "Lora", Georgia, serif;
}
* { box-sizing: border-box; border-color: var(--line); }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgb(8 169 201 / 40%); border-radius: 999px; }
::-webkit-scrollbar-track { background: var(--muted); }

/* shell */
.shell { display: flex; min-height: 100vh; max-width: 1600px; margin: 0 auto; }
.sidebar { position: sticky; top: 0; height: 100vh; width: 256px; flex-shrink: 0; background: var(--cream); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brandbox { padding: 24px 20px 16px; }
.brandbox img { width: 170px; display: block; }
.brandbox .eyebrow { margin-top: 10px; }
.nav { flex: 1; padding: 0 12px; display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--slate); font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--muted); color: var(--ink); }
.nav a.active { background: var(--soft-fill); color: var(--deep); font-weight: 600; box-shadow: inset 0 0 0 1px rgb(8 169 201 / 35%); }
.nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav .hint { margin-left: auto; font-size: 10px; letter-spacing: .04em; color: var(--slate); opacity: .8; }
.sidefoot { border-top: 1px solid var(--line); padding: 16px 20px; font-size: 11px; line-height: 20px; color: var(--slate); }
.sidefoot b { color: var(--ink); font-weight: 500; }
.sidefoot a { display: inline-flex; min-height: 44px; align-items: center; font-size: 12px; color: var(--slate); text-underline-offset: 2px; }
.sidefoot a:hover { color: var(--deep); text-decoration: underline; }
.main { flex: 1; min-width: 0; }
.topbar { display: none; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 12px 16px; }
.content { max-width: 1280px; margin: 0 auto; padding: 32px; display: flex; flex-direction: column; gap: 32px; }
@media (max-width: 1023px) {
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 288px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 16px 48px rgba(17,40,56,.12); }
  .sidebar.open { transform: none; }
  .backdrop { position: fixed; inset: 0; background: rgb(17 17 17 / 40%); z-index: 40; }
  .topbar { display: flex; }
  .content { padding: 24px 16px; gap: 24px; }
}

/* type */
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--deep); margin: 0; }
h1.title { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; margin: 8px 0 0; line-height: 1.15; }
.lead { font-family: var(--font-lead); color: var(--slate); font-size: 16px; line-height: 1.7; max-width: 48rem; margin: 8px 0 0; }
h2.sec { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.meta { font-size: 12px; color: var(--slate); }
@media (max-width: 767px) { h1.title { font-size: 30px; } .lead { font-size: 14px; } }

/* surfaces */
.card { background: var(--cream); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 20px; }
.card > * + * { margin-top: 12px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-kpi { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.grid-2 > * { min-width: 0; }
@media (max-width: 1023px) { .grid-2 { grid-template-columns: 1fr; } }

/* KPI tile */
.kpi { position: relative; overflow: hidden; background: var(--cream); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 16px; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--brand); }
.kpi.ok::before { background: var(--ok); } .kpi.warn::before { background: var(--warn); } .kpi.bad::before { background: var(--bad); }
.kpi .label { padding-right: 44px; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--deep); }
.kpi .value { margin-top: 8px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .hint { margin-top: 4px; font-size: 12px; color: var(--slate); line-height: 1.5; }
.kpi .dot { position: absolute; right: 16px; top: 16px; width: 36px; height: 36px; border-radius: 999px; display: flex; align-items: center; justify-content: center; background: var(--soft-fill); color: var(--deep); }
.kpi.ok .dot { background: var(--ok-bg); color: var(--ok); } .kpi.warn .dot { background: var(--warn-bg); color: var(--warn); } .kpi.bad .dot { background: var(--bad-bg); color: var(--bad); }
.kpi .dot svg { width: 16px; height: 16px; }

/* filters */
.filters { position: sticky; top: 0; z-index: 20; background: rgb(255 255 255 / 96%); border-bottom: 1px solid var(--line); padding: 12px 32px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 1023px) { .filters { padding: 12px 16px; position: static; } }
.pill { border: 0; background: transparent; border-radius: 999px; padding: 6px 12px; min-height: 32px; font-size: 12px; font-weight: 500; color: var(--slate); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; transition: background .15s; }
.pill:hover { background: var(--muted); }
.pill.active { background: rgb(8 169 201 / 15%); color: var(--deep); box-shadow: inset 0 0 0 1px rgb(8 169 201 / 40%); }
.field { border: 1px solid var(--line); background: var(--cream); border-radius: 999px; padding: 6px 12px; font-size: 12px; min-height: 32px; outline: none; }
.field:focus { box-shadow: 0 0 0 2px rgb(8 169 201 / 30%); border-color: var(--brand); }
.spacer { flex: 1; }
.updated { font-size: 12px; color: var(--slate); display: flex; align-items: center; gap: 6px; }
.dropdown { position: relative; }
.dropdown .menu { position: absolute; top: 38px; left: 0; z-index: 60; background: var(--cream); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 48px rgba(17,40,56,.12); padding: 8px; width: 280px; max-height: 360px; overflow: auto; }
.dropdown .menu label { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 13px; }
.dropdown .menu label:hover { background: var(--muted); }
.dropdown .menu .sub { color: var(--slate); font-size: 11px; margin-left: auto; }
input[type=checkbox] { accent-color: var(--brand); width: 16px; height: 16px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 12px 20px; border-radius: 999px; border: 0; background: var(--brand); color: var(--ink); font-weight: 700; font-size: 15px; cursor: pointer; transition: background .2s, box-shadow .2s; }
.btn:hover { background: var(--brand-hover); box-shadow: 0 8px 24px rgb(6 114 138 / 18%); }
.btn:disabled { opacity: .7; cursor: not-allowed; }

/* tables */
.tablewrap { background: var(--cream); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.tablewrap .scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead tr { background: var(--muted); border-bottom: 1px solid var(--line); }
th { text-align: left; padding: 12px 14px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--deep); white-space: nowrap; }
td { white-space: nowrap; padding: 10px 14px; border-bottom: 1px solid rgb(235 227 224 / 70%); vertical-align: top; color: rgb(17 17 17 / 90%); }
tbody tr:nth-child(even) { background: rgb(246 240 238 / 50%); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; background: var(--muted); }
.empty { padding: 40px 16px; text-align: center; color: var(--slate); font-size: 14px; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad, .chip.missing { background: var(--bad-bg); color: var(--bad); } .chip.info, .chip.neutral { background: var(--muted); color: var(--slate); box-shadow: inset 0 0 0 1px var(--line); }
.chip.stale, .chip.degraded { background: var(--warn-bg); color: var(--warn); } .chip.error { background: var(--bad-bg); color: var(--bad); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.callout { display: flex; gap: 12px; background: var(--cream); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow), inset 0 0 0 1px rgb(8 169 201 / 30%); font-size: 12px; color: var(--slate); line-height: 1.6; }
.callout b { color: var(--ink); font-size: 14px; display: block; margin-bottom: 2px; }
.callout.warn { box-shadow: var(--shadow), inset 0 0 0 1px rgb(154 91 11 / 30%); }
.bar { height: 8px; border-radius: 999px; background: var(--muted); overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.ok > span { background: var(--ok); } .bar.warn > span { background: var(--warn); } .bar.bad > span { background: var(--bad); }
.chartbox { position: relative; height: 280px; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.health-row { display: flex; align-items: center; gap: 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.loading { opacity: .55; transition: opacity .2s; }

/* login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 20px; background: var(--paper); }
.login-card { width: 100%; max-width: 420px; background: var(--cream); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.login-card img { width: 200px; display: block; margin: 0 auto; }
.login-card h1 { margin: 24px 0 0; text-align: center; font-size: 28px; letter-spacing: -0.02em; }
.login-card h1 span { color: var(--deep); }
.login-card p.tag { text-align: center; color: var(--slate); font-family: var(--font-lead); font-size: 15px; margin: 8px 0 0; }
.login-card form { margin-top: 40px; display: flex; flex-direction: column; gap: 24px; }
.login-card label { display: block; font-size: 14px; font-weight: 500; }
.login-card input { margin-top: 8px; width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 10px 14px; font-size: 15px; outline: none; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgb(8 169 201 / 20%); }
.login-card .err { border-radius: 12px; background: var(--bad-bg); color: var(--bad); padding: 8px 12px; font-size: 14px; }
.login-card .foot { margin-top: 40px; text-align: center; font-size: 12px; color: var(--slate); }

/* mapping notice (state / therapy-type filters) */
.mapnote { max-width: 1280px; margin: 12px auto 0; padding: 0 32px; font-size: 12px; color: var(--slate); }
.mapnote details { background: var(--cream); border-radius: 12px; padding: 8px 14px; box-shadow: inset 0 0 0 1px rgb(154 91 11 / 30%); }
.mapnote summary { cursor: pointer; color: var(--warn); font-weight: 600; }
.mapnote ul { margin: 6px 0 2px; padding-left: 18px; line-height: 1.7; }
.mapnote code { background: var(--muted); border-radius: 6px; padding: 1px 5px; }
@media (max-width: 1023px) { .mapnote { padding: 0 16px; } }
tr.provisional td { color: var(--slate); font-style: italic; }
