:root {
  --bg: #f4f6f8; --card: #ffffff; --ink: #14202b; --muted: #66727e; --line: #e3e7eb;
  --accent: #0f766e; --house: #2f6fd6; --car: #0e9f8a;
  --cheap: #1f9d55; --mid: #d69e2e; --high: #d64545;
  --shadow: 0 1px 2px rgba(16,24,32,.06), 0 4px 16px rgba(16,24,32,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1720; --card: #17222d; --ink: #e8eef3; --muted: #93a1ad; --line: #26333f;
    --accent: #2dd4bf; --house: #6b9cf0; --car: #2cc5ac;
    --cheap: #3ccf7c; --mid: #f0b543; --high: #f26b6b; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1720; --card: #17222d; --ink: #e8eef3; --muted: #93a1ad; --line: #26333f;
  --accent: #2dd4bf; --house: #6b9cf0; --car: #2cc5ac;
  --cheap: #3ccf7c; --mid: #f0b543; --high: #f26b6b; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
.top { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px 4px; max-width: 640px; margin: 0 auto; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.tab { display: none; }
.tab.active { display: block; }
.card { background: var(--card); border-radius: 16px; padding: 16px; margin: 12px 0; box-shadow: var(--shadow); border: 1px solid var(--line); }
.label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 0 4px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap { gap: 12px; }
.big { font-size: 44px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0; font-variant-numeric: tabular-nums; }
.big .unit { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.val { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stats { margin: 10px 0 6px; }
.stats > div { flex: 1; min-width: 0; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--line); }
.pill.cheap { background: color-mix(in srgb, var(--cheap) 18%, transparent); color: var(--cheap); }
.pill.mid { background: color-mix(in srgb, var(--mid) 20%, transparent); color: var(--mid); }
.pill.high { background: color-mix(in srgb, var(--high) 18%, transparent); color: var(--high); }
.breakdown { margin-top: 10px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.spark { margin-top: 12px; }
.spark svg, .chart svg { display: block; width: 100%; height: auto; }
.status { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status.charging .dot { background: var(--car); box-shadow: 0 0 0 4px color-mix(in srgb, var(--car) 25%, transparent); animation: pulse 1.6s infinite; }
.status.connected .dot { background: var(--mid); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--car) 8%, transparent); } }
.windows { margin: 8px 0 4px; }
.win { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.win:last-child { border-bottom: 0; }
.win b { font-variant-numeric: tabular-nums; }
.splitbar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--line); margin: 8px 0 10px; }
.splitbar span { display: block; height: 100%; }
.c-house { color: var(--house); } .c-car { color: var(--car); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-house { background: var(--house); } .sw-car { background: var(--car); }
.split2 > .mini { flex: 1; }
.legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.lv { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-left: 6px; }
.lv-cheap { background: var(--cheap); } .lv-mid { background: var(--mid); } .lv-high { background: var(--high); }
.chart { margin-top: 10px; }
.tip { min-height: 20px; margin-top: 6px; }
.list .li { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.list .li:last-child { border-bottom: 0; }
.list .li.now { font-weight: 700; }
.list .daysep { padding: 14px 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.monthnav { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.monthnav button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 22px; }
.monthnav button:disabled { opacity: .35; }
#monthLabel { font-weight: 650; font-size: 18px; text-transform: capitalize; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; font: inherit; font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tabs button.on { color: var(--accent); font-weight: 600; }
.err { background: color-mix(in srgb, var(--high) 15%, var(--card)); color: var(--ink); border: 1px solid var(--high); border-radius: 12px; padding: 12px; margin: 12px 0; font-size: 14px; }
.skeleton { color: transparent !important; background: var(--line); border-radius: 6px; }
.login-body { padding-bottom: 0; }
.login { max-width: 360px; margin: 0 auto; padding: 12vh 16px 24px; text-align: center; }
.login img { border-radius: 16px; }
.login h1 { margin: 10px 0 4px; }
.login form { text-align: left; display: grid; gap: 10px; }
.login input { font: inherit; font-size: 17px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
.login button { font: inherit; font-weight: 650; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; }
.login button:disabled { opacity: .6; }
#msg { color: var(--high); min-height: 18px; }
.linkbtn { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; padding: 4px 0 4px 10px; }
svg text { fill: var(--muted); font-size: 10px; font-family: inherit; }
