:root {
  color-scheme: light;
  --bg: #f7f6fb; --surface: #ffffff; --surface-2: #f1eefa; --line: #e8e5f2; --axis: #cfcbdf;
  --text: #17141f; --text-2: #5d5870; --text-3: #6f6a82;
  --accent: #7c3aed; --accent-strong: #6d28d9; --on-accent: #ffffff; --accent-soft: #efe9fd; --track: #e9e1fb;
  --good: #0ca30c; --warning: #fab219; --critical: #d03b3b;
  --radius: 18px; --shadow: 0 1px 2px rgba(23, 20, 31, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #100e16; --surface: #17151f; --surface-2: #211d2d; --line: #2a2638; --axis: #3b3650;
    --text: #f3f1f8; --text-2: #b8b3c9; --text-3: #a39db8;
    --accent: #8b5cf6; --accent-strong: #a78bfa; --on-accent: #ffffff; --accent-soft: #261f3d; --track: #2c2545;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
h2 { font-size: 15px; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
input, select { font-size: 16px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 96px); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; min-height: 40px; }
.month { display: flex; align-items: center; gap: 2px; min-width: 0; }
.month strong { font-weight: 600; white-space: nowrap; padding: 0 4px; }
.icon-btn { width: 40px; height: 40px; border: 0; background: none; border-radius: 12px; display: grid; place-items: center; cursor: pointer; color: var(--text-2); flex: none; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn:disabled { opacity: .3; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }

.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 11px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 550; color: var(--text-2); cursor: pointer; min-height: 30px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.seg.wide { display: flex; } .seg.wide button { flex: 1; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.muted { color: var(--text-2); } .small { font-size: 13px; } .tiny { font-size: 12px; color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

.quick { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 6px 6px 6px 14px; }
.quick:focus-within { border-color: var(--accent); }
.quick input { flex: 1; min-width: 0; border: 0; background: none; outline: 0; padding: 8px 0; }
.quick input::placeholder, .field input::placeholder { color: var(--text-3); }
.send { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; cursor: pointer; flex: none; }

.hero-label { font-size: 13px; color: var(--text-2); }
.hero-value { font-size: 34px; font-weight: 680; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; margin: 2px 0 12px; }
.pockets { display: grid; gap: 2px; }
.pocket { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.pocket .name { font-weight: 500; } .pocket .value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.stat .v { font-size: 21px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px; font-size: 14px; width: 100%; text-align: left; }
button.notice { cursor: pointer; }
.dot-i { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); white-space: nowrap; }

.meter-row { padding: 11px 0; border-top: 1px solid var(--line); }
.meter-row:first-child { border-top: 0; padding-top: 0; }
.meter-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; align-items: baseline; }
.meter-top span:first-child { font-weight: 500; }
.meter { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
.meter i.warn { background: var(--warning); } .meter i.over { background: var(--critical); } .meter i.none { width: 0; min-width: 0; }
.meter-foot { display: flex; justify-content: space-between; margin-top: 6px; gap: 8px; }

.chart { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.chart text { font: 11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .peak { fill: var(--text); font-weight: 600; }
.chart .grid { stroke: var(--line); stroke-width: 1; } .chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .bar { fill: var(--accent); } .chart .hit { fill: transparent; cursor: pointer; }
.chart .bar.dim { opacity: .45; }
.tip { position: fixed; z-index: 60; background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 9px; font-size: 12px; pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
details.table { margin-top: 10px; font-size: 13px; color: var(--text-2); }
details.table summary { cursor: pointer; padding: 4px 0; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
td, th { padding: 5px 0; border-top: 1px solid var(--line); text-align: left; font-weight: 400; }
td:last-child, th:last-child { text-align: right; }

.mov { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 11px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.mov:first-child { border-top: 0; }
.mov .title-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.mov .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mov .pill { flex: none; }
.mov .left { min-width: 0; } .mov .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.day { font-size: 12px; font-weight: 600; color: var(--text-3); margin: 14px 2px 6px; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 550; margin-left: 4px; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.filters input { grid-column: 1 / -1; }
.input, .field input, .field select, .filters input, .filters select { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: 0; appearance: none; -webkit-appearance: none; }
.field input:focus, .field select:focus, .input:focus { border-color: var(--accent); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 13px; padding: 12px 16px; font-weight: 600; background: var(--accent); color: var(--on-accent); cursor: pointer; text-decoration: none; min-height: 46px; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--accent-soft); color: var(--accent-strong); }
.btn.quiet { background: none; color: var(--text-2); font-weight: 500; }
.btn.danger { background: none; color: var(--critical); font-weight: 550; }
.btn:disabled { opacity: .5; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.err { color: var(--critical); font-size: 14px; margin: 0 0 10px; }

.plan-row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.plan-row:first-of-type { border-top: 0; }
.plan-row input { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); text-align: right; outline: 0; }
.plan-row input:focus { border-color: var(--accent); }

.goal { padding: 12px 0; border-top: 1px solid var(--line); }
.goal:first-of-type { border-top: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.kv:first-of-type { border-top: 0; }
.code { font: 13px ui-monospace, Menlo, monospace; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; word-break: break-all; margin: 8px 0; user-select: all; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.tabs nav { display: flex; width: 100%; max-width: 560px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 7px; font-size: 11px; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; min-height: 52px; }
.tabs button.on { color: var(--accent-strong); font-weight: 600; }
.fab { position: fixed; right: max(16px, calc(50vw - 264px)); bottom: calc(env(safe-area-inset-bottom) + 68px); width: 52px; height: 52px; border-radius: 17px; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 18px rgba(124, 58, 237, .35); z-index: 21; }

.scrim { position: fixed; inset: 0; background: rgba(10, 8, 16, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.hint { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.hint a { color: var(--accent-strong); font-weight: 600; }

.toasts { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 132px); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: 13px; font-size: 14px; max-width: 528px; display: flex; gap: 12px; align-items: center; pointer-events: auto; white-space: pre-line; }
.toast button { border: 0; background: none; color: inherit; font-weight: 700; cursor: pointer; padding: 2px 0; white-space: nowrap; }

.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 20px; max-width: 400px; margin: 0 auto; }
.brand { width: 52px; height: 52px; border-radius: 16px; margin-bottom: 18px; display: block; }
.auth h1 { margin-bottom: 4px; } .auth p.muted { margin-bottom: 22px; }
.or { text-align: center; font-size: 13px; color: var(--text-3); margin: 12px 0; }
.empty { padding: 26px 8px; text-align: center; color: var(--text-2); font-size: 14px; }
