:root {
  --bg: #0b0d10;
  --card: #15181d;
  --card-2: #1c2027;
  --line: #262b33;
  --text: #eef1f5;
  --muted: #8b94a3;
  --faint: #5a6270;
  --accent: #7cc4ff;
  --good: #5fd39a;
  --warn: #ffc15e;
  --bad: #ff6b6b;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.wrap { max-width: 560px; margin: 0 auto; padding: 12px 16px 48px; }

/* Header */
header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 10px; margin: 0 -16px 8px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}
header.scrolled { border-bottom-color: var(--line); }
header h1 { font-size: 26px; margin: 0; letter-spacing: -0.02em; flex: 1; }
header .updated { display: block; font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-top: 2px; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn svg { width: 22px; height: 22px; }
.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  background: #3a2a10; color: var(--warn); border-radius: 12px;
  padding: 10px 14px; font-size: 14px; margin-bottom: 12px;
}

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; margin-bottom: 14px;
}
.card h2 {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}
.tag {
  font-size: 11px; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 99px;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line); text-transform: none;
}
.tag.manual { color: var(--warn); border-color: #5a4520; }
.big { font-size: 48px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.hero .big { font-size: 56px; }
.sub { color: var(--muted); font-size: 14px; margin-top: 6px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: clamp(20px, 7.2vw, 30px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.over { color: var(--bad); }
.near { color: var(--warn); }

.rows { margin-top: 14px; border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 11px 0; border-bottom: 1px solid var(--line); align-items: baseline;
}
.row:last-child { border-bottom: 0; }
.row .name { font-weight: 500; }
.row .meta { font-size: 13px; color: var(--muted); }
.row .amt { text-align: right; font-weight: 600; }
.row .amt small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

.grid3 { display: grid; grid-template-columns: 1fr 62px 62px 70px; gap: 6px; align-items: baseline; }
.grid3 > span:not(:first-child) { text-align: right; }
.grid3.head { font-size: 12px; color: var(--faint); padding: 10px 0 4px; }
.grid3.body { padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }
.grid3 .n { font-variant-numeric: tabular-nums; }

details { margin-top: 4px; }
details:first-of-type { margin-top: 12px; }
details summary {
  cursor: pointer; color: var(--accent); font-size: 15px; padding: 10px 0; list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::after { content: " +"; }
details[open] summary::after { content: " -"; }

.err { margin-top: 12px; font-size: 13px; color: var(--warn); background: #2a2110; border-radius: 10px; padding: 8px 12px; }
.muted { color: var(--muted); }
.card.disabled { opacity: 0.45; }
.card.disabled .big { font-size: 26px; color: var(--muted); }

/* Settings */
.field { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field label { font-size: 15px; }
.field label small { display: block; color: var(--muted); font-size: 12px; }
input[type=text], input[type=number], input[type=password] {
  width: 100%; font: inherit; font-size: 17px; color: var(--text);
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; min-height: 46px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.prefix { position: relative; }
.prefix::before { content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.prefix input { padding-left: 24px; }

.fixed-row { display: grid; grid-template-columns: 1fr 96px 64px 40px; gap: 8px; margin-bottom: 8px; align-items: center; }
.fixed-head { display: grid; grid-template-columns: 1fr 96px 64px 40px; gap: 8px; font-size: 12px; color: var(--faint); margin-bottom: 6px; }
.del { width: 40px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }

.btn {
  display: block; width: 100%; min-height: 52px; border-radius: 14px; border: 0;
  font: inherit; font-size: 17px; font-weight: 600; cursor: pointer; margin-top: 12px;
  background: var(--accent); color: #07121c;
}
.btn.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn:active { transform: scale(0.99); }
.note { font-size: 14px; margin-top: 10px; min-height: 20px; color: var(--muted); }
.note.ok { color: var(--good); }
.note.bad { color: var(--bad); }

.hidden { display: none !important; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: 100%; max-width: 360px; }
.login h1 { font-size: 30px; margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 20px; }

/* Max plan meters */
.meter { padding: 6px 0 12px; }
.meter + .meter { border-top: 1px solid var(--line); padding-top: 14px; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; }
.meter-top .label { font-size: 15px; font-weight: 500; }
.meter-top .value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.bar { height: 10px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin: 8px 0 6px; }
.fill { height: 100%; border-radius: 99px; background: var(--good); }
.fill.near { background: var(--warn); }
.fill.over { background: var(--bad); }
.meter .meta { font-size: 13px; color: var(--muted); }
