/* Layout: command centre — white ledger rail on the left, bright working surface on the right, assistant slides over from the right edge.
   Light theme only, on purpose: the team asked for a bright look. Brand accent is --brand (admins can change it in Settings). */
:root {
  color-scheme: light;
  --brand: #1B6BF2;
  --paper: #F4F7FC;
  --surface: #FFFFFF;
  --surface-2: #F8FAFE;
  --ink: #102038;
  --ink-2: #4A5A73;
  --ink-3: #8393AB;
  --line: #DFE6F1;
  --line-2: #EDF1F8;
  --signal: var(--brand);
  --signal-ink: #FFFFFF;
  --signal-soft: color-mix(in srgb, var(--brand) 11%, white);
  --owe: #E0452B;
  --owe-soft: #FFECE7;
  --warn: #C27400;
  --warn-soft: #FFF4DB;
  --credit: #0A9F86;
  --credit-soft: #DDF7F1;
  --ok: #16A34A;
  --ok-soft: #E3F8EA;
  --violet: #7C4DFF;
  --violet-soft: #F0EAFF;
  --shadow: 0 1px 2px rgba(16, 32, 56, .05), 0 6px 20px rgba(27, 107, 242, .07);
  --shadow-lg: 0 24px 64px rgba(16, 32, 56, .16);
  --scrim: rgba(16, 32, 56, .28);
  --f-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --f-body: "Work Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 10px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: var(--f-mono); font-size: 12.5px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.owe { color: var(--owe); } .credit { color: var(--credit); } .ok { color: var(--ok); } .warn { color: var(--warn); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100%; }
.rail { position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px 24px; display: flex; flex-direction: column; gap: 18px; }
.brand { display: grid; gap: 10px; padding: 0 6px 4px; }
.brand .logo { display: block; max-width: 168px; max-height: 64px; width: auto; height: auto; object-fit: contain; }
.logo-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 700; }
.brand-t { display: grid; gap: 2px; }
.brand-t b { font-family: var(--f-display); font-weight: 400; font-size: 24px; line-height: 1.05; letter-spacing: -.01em; }
.brand-t span { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.month-pick { display: grid; gap: 6px; padding: 0 4px; }
.month-pick label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding-left: 4px; }
.month-pick select { width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; }
.nav { display: grid; gap: 2px; }
.nav h6 { margin: 10px 10px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.nav button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 500; transition: background .15s, color .15s; position: relative; }
.nav button:hover { background: var(--line-2); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--signal-soft); color: var(--brand); font-weight: 600; }
.nav button[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--signal); }
.nav svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nav .count.hot { background: var(--warn-soft); color: var(--warn); }
.nav .count.red { background: var(--owe-soft); color: var(--owe); }
.rail-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 6px; font-size: 12px; color: var(--ink-3); }
.who { display: flex; align-items: center; gap: 8px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: #fff; background: var(--signal); flex: none; background-size: cover; }
.sync { display: inline-flex; align-items: center; gap: 6px; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.sync.live i { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.sync.busy i { background: var(--warn); animation: pulse 1s infinite; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.crumb { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.crumb h1 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 30px; line-height: 1.05; letter-spacing: -.01em; }
.crumb .m { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.topbar .spacer { flex: 1; }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; opacity: 0; transition: opacity .2s; }
.progress.on { opacity: 1; }
.progress::after { content: ""; position: absolute; top: 0; bottom: 0; width: 30%; background: var(--signal); animation: slide 1.1s var(--ease) infinite; }
.view { padding: 24px 28px 64px; display: grid; gap: 20px; align-content: start; }
.view.enter { animation: viewIn .38s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { left: -30%; } to { left: 100%; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer; transition: transform .12s, background .15s, border-color .15s, box-shadow .15s; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn.primary:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--signal) 35%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); color: var(--ink); }
.btn.danger { color: var(--owe); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .55; cursor: default; pointer-events: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn .spin, .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; flex: none; }
.input, select.input, textarea.input { padding: 8px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); width: 100%; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--line-2); flex-wrap: wrap; }
.seg button { all: unset; cursor: pointer; padding: 5px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); transition: background .15s, color .15s; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .input[type="search"] { max-width: 280px; }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.panel-h h2, .panel-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-h p { margin: 0; color: var(--ink-2); font-size: 13px; }
.panel-b { padding: 16px 18px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.lede { font-family: var(--f-display); font-size: 40px; line-height: 1.02; margin: 4px 0 6px; letter-spacing: -.015em; text-wrap: balance; font-weight: 400; }
.lede em { font-style: italic; color: var(--brand); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 20px; align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.kpi { padding: 16px 18px; border-right: 1px solid var(--line-2); display: grid; gap: 4px; min-width: 0; cursor: default; }
.kpi:last-child { border-right: 0; }
.kpi.link { cursor: pointer; transition: background .15s; }
.kpi.link:hover { background: var(--surface-2); }
.kpis .kpi:nth-child(1) { background: linear-gradient(180deg, var(--signal-soft), var(--surface) 70%); }
.kpis .kpi:nth-child(2) { background: linear-gradient(180deg, var(--ok-soft), var(--surface) 70%); }
.kpis .kpi:nth-child(3) { background: linear-gradient(180deg, var(--owe-soft), var(--surface) 70%); }
.kpis .kpi:nth-child(4) { background: linear-gradient(180deg, var(--credit-soft), var(--surface) 70%); }
.kpis .kpi:nth-child(5) { background: linear-gradient(180deg, var(--violet-soft), var(--surface) 70%); }
.kpi .v { font-family: var(--f-display); font-size: 31px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .s { font-size: 12px; color: var(--ink-2); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.t th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: default; user-select: none; }
.t th.sortable { cursor: pointer; }
.t th.sortable:hover { color: var(--ink); }
.t th .arr { opacity: .7; margin-left: 3px; }
.t th.num { text-align: right; }
.t td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tbody tr { transition: background .12s; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover { background: var(--surface-2); }
.t tbody tr:last-child td { border-bottom: 0; }
.t tfoot td { padding: 11px 14px; border-top: 1px solid var(--line); font-weight: 600; background: var(--surface-2); }
.t .name { font-weight: 500; }
.t .sub { font-size: 12px; color: var(--ink-3); }
.t td.stripe-owe { box-shadow: inset 3px 0 0 var(--owe); }
.t td.stripe-credit { box-shadow: inset 3px 0 0 var(--credit); }
.t td.stripe-warn { box-shadow: inset 3px 0 0 var(--warn); }
.t td.stripe-ok { box-shadow: inset 3px 0 0 var(--ok); }
.t input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--signal); }
.strike { text-decoration: line-through; color: var(--ink-3); font-size: 12px; margin-right: 6px; }
.more { padding: 12px; text-align: center; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.chip.owe { background: var(--owe-soft); color: var(--owe); }
.chip.credit { background: var(--credit-soft); color: var(--credit); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.signal { background: var(--signal-soft); color: var(--signal); }
.chip i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
button.chip { border: 0; cursor: pointer; }
button.chip:hover { filter: brightness(.96); }

/* ---------- task list ---------- */
.tasks { display: grid; }
.task { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 18px; border-bottom: 1px solid var(--line-2); }
.task:last-child { border-bottom: 0; }
.task .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.task .ic.warn { background: var(--warn-soft); color: var(--warn); }
.task .ic.owe { background: var(--owe-soft); color: var(--owe); }
.task .ic.ok { background: var(--ok-soft); color: var(--ok); }
.task .ic.info { background: var(--signal-soft); color: var(--signal); }
.task b { font-weight: 600; }
.task p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13px; cursor: pointer; }
.bar .track { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; background: var(--owe); transform-origin: left; animation: grow .6s var(--ease) both; }
.bar .fill.credit { background: var(--credit); }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- upload ---------- */
.drops { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.drop { position: relative; align-content: start; border: 1.5px dashed var(--line); border-radius: 14px; background: var(--surface); padding: 26px 22px; display: grid; gap: 10px; justify-items: start; transition: border-color .2s, background .2s, transform .2s; }
.drop.over { border-color: var(--signal); background: var(--signal-soft); transform: scale(1.01); }
.drop.done { border-style: solid; border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.drop h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 24px; }
.drop p { margin: 0; color: var(--ink-2); font-size: 13px; max-width: 46ch; }
.drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop .stat { display: flex; flex-wrap: wrap; gap: 6px; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 12px; font-weight: 600; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--ink); font-size: 13px; }
.notice.info { background: var(--signal-soft); }
.notice.bad { background: var(--owe-soft); }
.notice.good { background: var(--ok-soft); }

/* ---------- drawer / modal ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 60; box-shadow: var(--shadow-lg); transform: translateX(104%); transition: transform .34s var(--ease); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.drawer.on { transform: none; }
.drawer-h { display: flex; align-items: flex-start; gap: 10px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-2); }
.drawer-h h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 28px; line-height: 1.05; }
.drawer-b { flex: 1; overflow-y: auto; padding: 18px 20px 28px; display: grid; gap: 18px; align-content: start; }
.x { margin-left: auto; }
.mini-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line-2); border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); }
.mini-kpis div { background: var(--surface); padding: 10px 12px; display: grid; gap: 2px; }
.mini-kpis small { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.mini-kpis b { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.closing { display: grid; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.closing .big { font-family: var(--f-display); font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .input { flex: 1; min-width: 120px; }
.list { display: grid; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.list > div { display: grid; grid-template-columns: 82px minmax(0, 1fr) auto; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line-2); font-size: 13px; align-items: center; }
.list > div:last-child { border-bottom: 0; }
.modal { position: fixed; left: 50%; top: 50%; z-index: 70; width: min(440px, calc(100vw - 32px)); transform: translate(-50%, -46%) scale(.97); opacity: 0; pointer-events: none; transition: transform .22s var(--ease), opacity .22s; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 20px; display: grid; gap: 14px; }
.modal.on { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal h3 { margin: 0; font-size: 17px; }
.modal p { margin: 0; color: var(--ink-2); }

/* ---------- assistant ---------- */
.ai { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 40; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); transform: translateX(104%); transition: transform .34s var(--ease); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.ai.on { transform: none; }
.ai-h { padding: 16px 18px 12px; border-bottom: 1px solid var(--line-2); display: grid; gap: 10px; }
.ai-h .top { display: flex; align-items: center; gap: 10px; }
.ai-h h2 { margin: 0; font-family: var(--f-display); font-size: 26px; font-weight: 400; line-height: 1; }
.ai-h .ctx { font-size: 12px; color: var(--ink-3); }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.sugg button { all: unset; cursor: pointer; font-size: 12.5px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink-2); transition: border-color .15s, color .15s, background .15s; }
.sugg button:hover { border-color: var(--signal); color: var(--signal); background: var(--signal-soft); }
.ai-log { flex: 1; overflow-y: auto; padding: 16px 18px; display: grid; gap: 14px; align-content: start; }
.msg { animation: pop .28s var(--ease) both; max-width: 100%; min-width: 0; }
.msg.user { justify-self: end; background: var(--signal); color: var(--signal-ink); padding: 9px 13px; border-radius: 14px 14px 4px 14px; max-width: 85%; }
.msg.bot { font-size: 13.5px; line-height: 1.55; }
.msg.bot p { margin: 0 0 8px; } .msg.bot p:last-child { margin: 0; }
.msg.bot ul, .msg.bot ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.bot code { font-family: var(--f-mono); font-size: 12px; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.thinking { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-3); font-size: 13px; }
.dots { display: inline-flex; gap: 3px; } .dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite; } .dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
.acts { display: grid; gap: 8px; margin-top: 10px; }
.act { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); animation: pop .3s var(--ease) both; }
.act small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.act.done { opacity: .6; }
.ai-f { border-top: 1px solid var(--line-2); padding: 12px 14px; display: grid; gap: 8px; }
.ai-f form { display: flex; gap: 8px; align-items: flex-end; }
.ai-f textarea { resize: none; min-height: 42px; max-height: 140px; }
.fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 30; box-shadow: var(--shadow-lg); border-radius: 99px; padding: 11px 18px; }

/* ---------- skeleton / empty ---------- */
.sk { border-radius: 8px; background: linear-gradient(90deg, var(--line-2) 0, var(--line) 40%, var(--line-2) 80%); background-size: 800px 100%; animation: shimmer 1.3s linear infinite; }
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 48px 20px; }
.empty h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 28px; }
.empty p { margin: 0; color: var(--ink-2); max-width: 48ch; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .25s var(--ease) both; display: flex; gap: 10px; align-items: center; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--owe); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }

/* ---------- statement ---------- */
.stmt-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.picker { max-height: 72vh; overflow-y: auto; }
.picker button { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 9px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; transition: background .12s; }
.picker button:hover { background: var(--surface-2); }
.picker button[aria-current="true"] { background: var(--signal-soft); }
.picker small { grid-column: 1; color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stmt { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.stmt-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; padding: 26px 28px 22px; border-bottom: 1px solid var(--line-2); }
.stmt-head h2 { margin: 2px 0 4px; font-family: var(--f-display); font-weight: 400; font-size: 34px; line-height: 1.05; }
.stmt-due { text-align: right; display: grid; gap: 4px; align-content: start; }
.stmt-due .big { font-family: var(--f-display); font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.stmt-body { padding: 8px 14px 22px; }
.stmt-month td { font-weight: 500; }
.stmt-detail td { background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); padding: 6px 14px; border-bottom: 0; }
.stmt-detail:last-of-type td { padding-bottom: 12px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: column; padding: 14px 16px 10px; border-right: 0; border-bottom: 1px solid var(--line); gap: 10px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .nav h6 { display: none; }
  .nav button { flex: none; }
  .nav button[aria-current="page"]::before { display: none; }
  .rail-foot { display: none; }
  .brand { padding: 0; }
  .month-pick { padding: 0; grid-template-columns: auto 1fr; align-items: center; }
  .topbar { padding: 12px 16px; }
  .crumb h1 { font-size: 24px; }
  .view { padding: 18px 16px 90px; }
  .lede { font-size: 32px; }
  .stmt-layout { grid-template-columns: minmax(0, 1fr); }
  .picker { max-height: 260px; }
  .mini-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stmt-head { grid-template-columns: minmax(0, 1fr); padding: 20px; }
  .stmt-due { text-align: left; }
  .kpi { border-bottom: 1px solid var(--line-2); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- account / sign-out ---------- */
.who b { display: block; color: var(--ink); font-weight: 600; font-size: 13px; }
.who small { display: block; font-size: 11.5px; color: var(--ink-3); }
.signout { justify-content: flex-start; padding-left: 4px; }
.expired { position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 100; display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); border-radius: 12px; padding: 12px 14px 12px 18px; max-width: calc(100vw - 32px); flex-wrap: wrap; }

/* ---------- status legend ---------- */
.legend summary { cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: center; padding: 12px 18px; font-weight: 600; color: var(--brand); }
.legend summary::-webkit-details-marker { display: none; }
.legend summary svg, .status-help svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; flex: none; }
.legend[open] summary { border-bottom: 1px solid var(--line-2); }
.legend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: 0; }
.legend-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); align-items: start; }
.legend-row p { margin: 0 0 4px; font-size: 13px; color: var(--ink-2); }
.effect { font-size: 11.5px; font-weight: 600; letter-spacing: .02em; color: var(--ink-3); }
.effect.zero { color: var(--ok); }
.legend-foot { margin: 0; padding: 10px 18px 14px; font-size: 12.5px; }
.status-help { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--signal-soft); color: var(--ink-2); font-size: 12.5px; }
.status-help svg { color: var(--brand); margin-top: 1px; }
.status-help.zero { background: var(--ok-soft); }
.status-help.zero svg { color: var(--ok); }
.chip .cost { font-weight: 600; }
.linkbox { display: grid; gap: 8px; border-top: 1px solid var(--line-2); background: var(--ok-soft); border-radius: 0 0 12px 12px; }

/* ---------- sign-in ---------- */
.auth { min-height: 100%; display: grid; place-items: center; align-content: center; gap: 14px; padding: 32px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--signal-soft), transparent 70%), var(--paper); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 30px 28px; display: grid; gap: 14px; animation: pop .35s var(--ease) both; }
.auth-logo { max-width: 190px; max-height: 84px; object-fit: contain; }
.auth-card h1 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 34px; line-height: 1.05; }
.auth-card p { margin: 0; }
.auth-form { display: grid; gap: 12px; }
.auth-form .btn.primary { padding: 11px 14px; }
.auth-foot { margin: 0; font-size: 12px; color: var(--ink-3); }
.small { font-size: 12.5px; }
.btn.google { background: var(--surface); border-color: var(--line); padding: 10px 14px; font-weight: 600; }
.btn.google svg { width: 18px; height: 18px; stroke: none; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
@media (max-width: 900px) { .legend-row { grid-template-columns: minmax(0, 1fr); gap: 6px; } .brand .logo { max-height: 40px; } }
