:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #1a2540;
  --line: #26324d;
  --text: #e6ebf5;
  --muted: #8b97b0;
  --accent: #2dd4bf;
  --accent-ink: #062b27;
  --warn: #f5b942;
  --bad: #f2667a;
  --good: #4ade80;
  --s-net: #60a5fa;
  --s-limit: #2dd4bf;
  --s-used: #f5b942;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5fa; --panel: #ffffff; --panel-2: #eef1f7; --line: #dde2ec;
    --text: #131a2a; --muted: #5d6880; --accent: #0f9d8c; --accent-ink: #ffffff;
    --s-net: #2563eb; --s-limit: #0f9d8c; --s-used: #c98a0c;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1rem; margin: 1.4rem 0 .6rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.panel h2 { margin-top: 0; color: var(--text); }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: .85rem; margin: .4rem 0 .8rem; }
.msg { color: var(--bad); min-height: 1.2em; margin: 0; font-size: .9rem; }

button, .button {
  font: inherit; border: 0; border-radius: 10px; padding: .6rem 1rem; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; gap: .35rem;
}
button.ghost, .button.ghost { background: var(--panel-2); color: var(--text); font-weight: 500; }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
button.icon { padding: .4rem .7rem; font-size: 1.1rem; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; width: 100%; padding: .55rem .7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); flex: 1; }
label.check { flex-direction: row; align-items: center; gap: .45rem; flex: 0 0 auto; }
label.check input { width: auto; }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.gate .panel { width: min(420px, 100%); display: flex; flex-direction: column; gap: .9rem; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(.8rem + env(safe-area-inset-top)) 1rem .8rem; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
main { max-width: 960px; margin: 0 auto; padding: 1rem 1rem calc(6rem + env(safe-area-inset-bottom)); }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: center;
  background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; max-width: 160px; background: none; color: var(--muted); border-radius: 0; flex-direction: column;
  gap: .1rem; padding: .55rem .2rem; font-size: .75rem; font-weight: 500;
}
.tabs button span { font-size: 1.15rem; line-height: 1; }
.tabs button[aria-current="page"] { color: var(--accent); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.kpi .label { color: var(--muted); font-size: .8rem; }
.kpi .value { font-size: 1.2rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: .8rem; }
.kpi.neg .value, .neg { color: var(--bad); }

.list { display: flex; flex-direction: column; gap: .6rem; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem .95rem; }
.item.archived { opacity: .6; }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.item-head strong { font-size: 1rem; }
.badge { font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .3rem .8rem; margin: .7rem 0 .2rem; }
.facts div { display: flex; flex-direction: column; }
.facts dt { color: var(--muted); font-size: .75rem; }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.notes { color: var(--muted); font-size: .85rem; margin: .5rem 0 0; white-space: pre-wrap; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.actions.end { justify-content: flex-end; }
.actions button, .actions .button { padding: .45rem .8rem; font-size: .88rem; }

.bar { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin-top: .55rem; }
.bar .fill { height: 100%; border-radius: 999px; background: var(--good); }
.bar .fill.mid { background: var(--warn); }
.bar .fill.hi { background: var(--bad); }
.util-line { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: .3rem; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem; margin-bottom: 1rem; }
.toolbar label { flex: 0 1 180px; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; flex: 1 1 100%; }
.chips button { background: var(--panel-2); color: var(--muted); font-weight: 500; padding: .35rem .8rem; border-radius: 999px; font-size: .85rem; }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.offer h3 { margin: 0; font-size: 1rem; }
.offer ul { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--text); font-size: .9rem; }
.offer .meta { color: var(--muted); font-size: .78rem; margin-top: .6rem; }
.offer .figure { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.offer .better { color: var(--good); font-size: .8rem; margin-top: .3rem; }

.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-wrap .grid { stroke: var(--line); stroke-width: 1; }
.chart-wrap .axis { fill: var(--muted); font-size: 11px; }
.chart-wrap .line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.s-net { stroke: var(--s-net); background: var(--s-net); }
.s-limit { stroke: var(--s-limit); background: var(--s-limit); }
.s-used { stroke: var(--s-used); background: var(--s-used); }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-top: .6rem; font-size: .85rem; }
.legend .dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; vertical-align: -1px; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem .5rem; }

dialog {
  width: min(560px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 1.1rem;
}
dialog::backdrop { background: rgba(5, 9, 18, .65); }
dialog h2 { margin: 0 0 .3rem; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; gap: .7rem; }
@media (max-width: 480px) { .row { flex-direction: column; } }

.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1rem; letter-spacing: .08em; word-break: break-all;
  background: var(--panel-2); padding: .5rem .7rem; border-radius: 8px; user-select: all; }

#toast {
  position: fixed; left: 50%; bottom: calc(5rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); padding: .6rem 1rem; border-radius: 10px; z-index: 20;
  max-width: calc(100vw - 2rem);
}
#toast.error { border-color: var(--bad); color: var(--bad); }
