/* OG Finance. Dark by default (OG colors), light follows the system. System fonts only. */
:root {
  --bg: #0f1013;
  --surface: #16181d;
  --surface2: #1c1f26;
  --line: #2a2e37;
  --text: #eef0e8;
  --muted: #9aa0ad;
  --faint: #6b7180;
  --accent: #eef0e8;        /* primary buttons: off-white on dark, like the icon */
  --accent-ink: #16181d;
  --link: #9cc3ff;
  --pos: #5cc29a;           /* money in (text) */
  --neg: #eef0e8;           /* money out: plain ink, not alarm red */
  /* chart series, validated (dataviz validator) on #1c1f26 */
  --inc: #2fa89a;
  --out: #d9773a;
  --line-series: #8fb3ff;
  /* status */
  --good: #5cc29a;
  --warn: #e7b84a;
  --bad: #ef6b6b;
  --info: #8fb3ff;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --tabs-h: 64px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f3ef; --surface: #ffffff; --surface2: #f6f6f2; --line: #e1e1da; --text: #16181d; --muted: #5d6270; --faint: #8a8f9a;
    --accent: #16181d; --accent-ink: #eef0e8; --link: #1f5fbf; --pos: #0f7a5c; --neg: #16181d;
    --inc: #0f8c7b; --out: #c4581c; --line-series: #2d63c8;
    --good: #0f7a5c; --warn: #9a6a00; --bad: #c43838; --info: #2d63c8;
    --shadow: 0 10px 40px rgba(0, 0, 0, .15);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .4em; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .7em; }
h3 { font-size: .95rem; margin: 1em 0 .5em; }
p { margin: .4em 0 .8em; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.ic { width: 20px; height: 20px; flex: none; vertical-align: -4px; }

/* ---------------------------------------------------------------- layout */
.side { display: none; }
main { display: block; padding: 16px 16px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; outline: none; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .7rem; padding: 4px 0; border-radius: 10px; }
.tabs a .ic { width: 22px; height: 22px; }
.tabs a.on { color: var(--text); }
.tabs a.on .ic { stroke-width: 2.4; }
.tabs a:hover { text-decoration: none; }
/* top-left mark: icon only, links to the overview (phone: own row; desktop: top of the sidebar) */
.brand { display: inline-flex; border-radius: 10px; }
.brand:hover { text-decoration: none; }
.brand img { display: block; border-radius: 9px; }
.top { display: flex; padding: calc(12px + env(safe-area-inset-top)) 16px 0; max-width: 1180px; margin: 0 auto; }
.top .brand img { width: 36px; height: 36px; }
body.signed-out .tabs, body.signed-out .side, body.signed-out .top, body.signed-out main { display: none; }

@media (min-width: 900px) {
  .tabs { display: none; }
  .side {
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: 232px; padding: 18px 12px;
    background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto;
  }
  main { margin-left: 232px; padding: 28px 36px 48px; }
  .top { display: none; }
  .side .brand { padding: 4px 8px 18px; }
  .side nav { display: flex; flex-direction: column; gap: 2px; }
  .side nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--muted); }
  .side nav a:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
  .side nav a.on { background: var(--surface2); color: var(--text); font-weight: 600; }
  .side-foot { margin-top: auto; padding: 12px 8px 0; display: flex; flex-direction: column; gap: 8px; }
  .who { display: flex; align-items: center; gap: 10px; color: var(--muted); }
  .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--text); font-weight: 700; font-size: .8rem; }
}
@media (min-width: 900px) and (max-width: 1100px) { main { padding: 24px; } }

.page { max-width: 1100px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; flex: 1; }
.page-head > div { flex: 1; }
.cols { display: grid; gap: 16px; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 1000px) { .cols { grid-template-columns: 1fr 1fr; align-items: start; } }

/* ---------------------------------------------------------------- cards and rows */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; min-width: 0; }
.cols .card { margin-bottom: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card-head.wrap { flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.card-head h2, .card-head h3 { margin-bottom: .6em; }
.card-head.wrap h2 { margin: 0; }
.eyebrow { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.big { font-size: 2.1rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }

.hero { display: flex; align-items: stretch; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.hero-main { flex: 1; min-width: 0; }
.hero .big { font-size: 2.5rem; margin: 2px 0 8px; }
.split2 { display: flex; gap: 20px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.hero-side { align-self: flex-start; display: flex; align-items: center; gap: 2px; font-size: .9rem; }

.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat .lbl { color: var(--muted); font-size: .8rem; }
.stat .val { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.stat .val.small { font-size: .95rem; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; width: 100%; color: var(--text); text-align: left; min-height: 48px; }
button.row, a.row { background: none; border: 0; border-radius: 10px; font: inherit; cursor: pointer; }
button.row:hover, a.row:hover { background: var(--surface2); text-decoration: none; }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .t { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { color: var(--muted); font-size: .82rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rows.compact .row { min-height: 0; padding: 6px 2px; }
.amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.amt.pos { color: var(--pos); }
.amt.neg { color: var(--neg); }
.grp + .grp { margin-top: 12px; }
.grp-head { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; padding: 4px 2px; }
.grp-head.big { text-transform: none; letter-spacing: 0; font-size: 1rem; color: var(--text); font-weight: 650; align-items: baseline; }
.grp-head.big h2 { margin: 0 0 .3em; }
.menu .row { padding: 14px 4px; }

.cat { display: inline-flex; align-items: center; gap: 4px; }
.cat.none { color: var(--warn); }
.cat.suggest { color: var(--info); }
.cat .ic, .tag .ic { width: 14px; height: 14px; vertical-align: -2px; }
.cat.transfer { color: var(--faint); }
.acct::before { content: "·"; margin-right: 8px; color: var(--faint); }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: .75rem; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.warn-text { color: var(--warn); }

.date-badge { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; line-height: 1.05; background: var(--surface2); }
.date-badge b { font-size: 1.05rem; }
.date-badge small { font-size: .65rem; color: var(--muted); text-transform: uppercase; }
.date-badge.overdue { border-color: var(--bad); }
.date-badge.overdue b { color: var(--bad); }
.date-badge.due { border-color: var(--warn); }
.date-badge.paid { opacity: .6; }

.todos { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.todo { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); }
.todo span { flex: 1; }
.todo > .ic:first-child { color: var(--info); }
.todo.warn > .ic:first-child { color: var(--warn); }
.todo:hover { text-decoration: none; background: var(--surface2); }

/* ---------------------------------------------------------------- controls */
button, .button {
  font: inherit; color: var(--text); background: var(--surface2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; min-height: 40px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.button:hover { text-decoration: none; }
button:hover:not(:disabled), .button:hover { border-color: var(--faint); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
button.danger { color: var(--bad); }
button.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
button.wide { width: 100%; margin-top: 10px; }
button.link { background: none; border: 0; color: var(--link); padding: 6px 0; min-height: 0; }
.icon-btn { padding: 8px; min-width: 40px; background: none; border-color: transparent; }
.icon-btn.on { color: var(--info); }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
.actions.left { justify-content: flex-start; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  width: 100%; min-height: 42px; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--link); outline: none; }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--text); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field .lbl { font-size: .82rem; color: var(--muted); }
.field .hint { font-size: .78rem; color: var(--faint); }
label.check { display: flex; align-items: center; gap: 8px; flex-direction: row; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 .span2, .grid2 > .actions, .grid2 > h3 { grid-column: 1 / -1; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border-radius: 999px; min-height: 34px; padding: 5px 12px; font-size: .85rem; background: var(--surface); color: var(--muted); }
.chip.on { color: var(--text); border-color: var(--faint); }
.chip.warn { color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); align-self: flex-start; font-size: .75rem; min-height: 0; padding: 2px 8px; }
.chip .ic { width: 14px; height: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 34px; padding: 4px 12px; font-size: .85rem; background: none; color: var(--muted); }
.seg button.on { background: var(--surface2); color: var(--text); font-weight: 600; }

.searchbar { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 2px 4px 2px 12px; margin-bottom: 10px; }
.searchbar input { border: 0; background: none; padding-left: 4px; }
.searchbar > .ic { color: var(--muted); }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + span { background: color-mix(in srgb, var(--good) 45%, var(--line)); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--text); }
.switch input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }

.note { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); margin: 8px 0; font-size: .9rem; }
.note.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--bad); }
.note.info { border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.note.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; border: 1px dashed var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--text); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.back { display: inline-flex; align-items: center; gap: 2px; margin-bottom: 8px; font-size: .9rem; }
details.more { margin-top: 10px; }
details.more > summary { cursor: pointer; color: var(--muted); font-size: .88rem; padding: 6px 0; }
.bullets { padding-left: 1.2em; margin: 0; }
.bullets li { margin: .4em 0; }
.count { display: inline-block; margin-left: 8px; font-size: .8rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-weight: 500; }

/* ---------------------------------------------------------------- transactions */
.day { margin-bottom: 4px; }
.day-head { position: sticky; top: 0; z-index: 2; background: var(--bg); color: var(--muted); font-size: .8rem; font-weight: 600; padding: 8px 2px 4px; }
.txlist .rows { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 8px; }
.row.tx { padding: 10px 6px; }
.bulk { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; margin-bottom: 10px; border: 1px solid color-mix(in srgb, var(--info) 40%, transparent); border-radius: 12px; flex-wrap: wrap; }
.bulk > span { display: flex; align-items: center; gap: 8px; }

.tx-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tx-payee { font-size: 1.25rem; font-weight: 700; }
.tx-amt { font-size: 1.35rem; }
.suggestion { margin: 12px 0; padding: 12px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--info) 45%, transparent); background: color-mix(in srgb, var(--info) 8%, var(--surface)); }
.sg-top { display: flex; gap: 10px; align-items: flex-start; }
.sg-top > .ic { color: var(--info); margin-top: 2px; }
.suggestion .actions { margin-top: 8px; }
.catrow { margin-top: 12px; }
.splits, .split-edit, .receipts-box, .linked { margin-top: 12px; }
.split-line { display: grid; grid-template-columns: 1.3fr 1fr auto; gap: 6px; margin-bottom: 8px; align-items: center; }
.split-line input:nth-of-type(2) { grid-column: 1 / 3; }
.split-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.remain .ok { color: var(--good); display: inline-flex; gap: 4px; align-items: center; }
.remain .bad { color: var(--warn); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { width: 72px; height: 96px; padding: 0; overflow: hidden; border-radius: 8px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------------- receipts */
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.rcard { flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; text-align: left; border-radius: 12px; background: var(--surface); }
.rimg { aspect-ratio: 3 / 4; background: var(--surface2); display: grid; place-items: center; overflow: hidden; }
.rimg img { width: 100%; height: 100%; object-fit: cover; }
.ph { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.rmeta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.rmeta .t { font-weight: 600; }
.rmeta .s { color: var(--muted); font-size: .8rem; }
.receipt-view { display: grid; gap: 16px; }
.receipt-view img { width: 100%; max-height: 60vh; object-fit: contain; background: var(--surface2); border-radius: 10px; }
.receipt-view .pdf { display: flex; gap: 8px; align-items: center; padding: 20px; border: 1px dashed var(--line); border-radius: 10px; justify-content: center; }
@media (min-width: 760px) { .receipt-view { grid-template-columns: 1fr 1fr; align-items: start; } }

/* ---------------------------------------------------------------- budgets / rules / bills */
.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.budgets { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
@media (min-width: 900px) { .budgets { grid-template-columns: 1fr 1fr; } }
.budgets li { display: flex; flex-direction: column; gap: 4px; }
.budgets li > a { align-self: flex-end; padding: 0 4px; }
.budget { flex-direction: column; align-items: stretch; gap: 8px; padding: 14px; background: var(--surface); border-radius: 12px; text-align: left; }
.brow { padding: 8px 0; }
.brow-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-variant-numeric: tabular-nums; }
.brow-top .t { font-weight: 600; }
.progress { display: block; height: 8px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--line); overflow: hidden; margin-top: 4px; }
.progress .fill { display: block; height: 100%; border-radius: 999px; background: var(--good); }
.progress .fill.ahead { background: var(--warn); }
.progress .fill.over { background: var(--bad); }
.status { display: inline-flex; align-items: center; gap: 4px; }
.status .ic { width: 14px; height: 14px; }
.status.over { color: var(--bad); }
.status.ahead { color: var(--warn); }
.status.ok { color: var(--muted); }
.catpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.catpick fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0; padding: 6px 10px 8px; }
.catpick legend { color: var(--muted); font-size: .78rem; padding: 0 4px; }
.catpick label { padding: 3px 0; font-size: .9rem; }

.rules { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.rule { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px 4px 4px; }
.rule.off .rule-main { opacity: .55; }
.rule-main { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; background: none; border: 0; text-align: left; gap: 2px; }
.rule-main .t { font-weight: 600; }
.rule-main .s { font-size: .82rem; color: var(--text); opacity: .85; }
.rule-main .s.muted { color: var(--muted); }
.preview { margin-top: 8px; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cw { text-align: center; font-size: .72rem; color: var(--faint); padding-bottom: 2px; }
.cd { aspect-ratio: 1; min-height: 40px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .85rem; color: var(--muted); padding: 0; border: 1px solid transparent; background: none; }
.cd.empty { visibility: hidden; }
.cd.has { color: var(--text); background: var(--surface2); border-color: var(--line); font-weight: 600; }
.cd.today { border-color: var(--text); }
.dots { display: flex; gap: 3px; height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.paid, .key-dot.paid::before { background: var(--good); }
.dot.due, .key-dot.due::before { background: var(--warn); }
.dot.overdue, .key-dot.overdue::before { background: var(--bad); }
.dot.upcoming, .key-dot.upcoming::before { background: var(--muted); }
.key-dot { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--muted); margin: 0 6px; }
.key-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }

/* ---------------------------------------------------------------- charts */
.chart { margin: 8px 0 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--faint); stroke-width: 1; }
.chart .axis { fill: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .bar.inc { fill: var(--inc); }
.chart .bar.out { fill: var(--out); }
.chart .line { fill: none; stroke: var(--line-series); stroke-width: 2; stroke-linejoin: round; }
.chart .area { fill: var(--line-series); opacity: .1; }
.chart .dot { fill: var(--line-series); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--faint); stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; cursor: crosshair; }
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend.center { justify-content: center; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.key.inc::before { background: var(--inc); }
.key.out::before { background: var(--out); }
.chart-tip { position: fixed; z-index: 60; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: .8rem; box-shadow: var(--shadow); opacity: 0; transition: opacity .1s; font-variant-numeric: tabular-nums; }
.chart-tip.on { opacity: 1; }
.chart-tip .t { font-weight: 650; }
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "k v" "track track" "s s"; gap: 3px 8px; padding: 6px 4px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; min-height: 0; }
button.hbar:hover { background: var(--surface2); }
.hbar .k { grid-area: k; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .v { grid-area: v; font-variant-numeric: tabular-nums; font-weight: 600; }
.hbar .track { grid-area: track; height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; display: block; }
.hbar .fill { display: block; height: 100%; background: var(--out); border-radius: 0 4px 4px 0; }
.hbar .s { grid-area: s; font-size: .75rem; color: var(--muted); }
.spark { width: 80px; height: 24px; }
.spark path { fill: none; stroke: var(--line-series); stroke-width: 1.5; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.num { text-align: right; }

/* ---------------------------------------------------------------- sheet / dialog */
.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; }
.sheet-back.in { opacity: 1; }
.sheet {
  background: var(--surface); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  border: 1px solid var(--line); border-bottom: 0; padding: 0 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(30px); transition: transform .2s; overscroll-behavior: contain;
}
.sheet-back.in .sheet { transform: none; }
.sheet-head { position: sticky; top: 0; background: var(--surface); display: flex; align-items: center; justify-content: space-between; padding: 14px 0 8px; z-index: 1; }
.sheet-head h2 { margin: 0; }
@media (min-width: 700px) {
  .sheet-back { align-items: center; padding: 24px; }
  .sheet { max-width: 560px; border-radius: 18px; border-bottom: 1px solid var(--line); max-height: 88vh; padding-bottom: 20px; }
  .sheet.wide { max-width: 820px; }
}
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; z-index: 70;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 550; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.in { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 28px; left: calc(50% + 116px); } }

/* ---------------------------------------------------------------- sign-in */
.login { position: fixed; inset: 0; overflow-y: auto; background: var(--bg); z-index: 30; }
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; text-align: center; }
.login-card form { text-align: left; margin-top: 12px; }
.login-card h1 { margin-bottom: .2em; }
.login-icon { border-radius: 16px; margin-bottom: 10px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: .8rem; margin: 14px 0 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-card .note { text-align: left; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media (forced-colors: active) { .progress .fill, .chart .bar, .hbar .fill, .dot { forced-color-adjust: none; } }
