/* Bijli — grid charging tracker */
:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --surface-3: #e8e7e3;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #6f6e69;
  --border: #e4e3df;
  --grid: #ebeae6;
  --axis: #cfcec9;
  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-soft: #e6f0fc;
  --btn-bg: #2a78d6;
  --btn-bg-press: #256abf;
  --series-1: #2a78d6;
  --sun: #eda100;
  --danger: #c23434;
  --danger-soft: #fbeaea;
  --good: #0a7d0a;
  --tip-bg: #1f1f1d;
  --tip-ink: #ffffff;
  --toast-action: #86b6ef;
  --shadow: 0 1px 2px rgba(20, 20, 18, 0.04), 0 4px 14px rgba(20, 20, 18, 0.04);
  --radius: 16px;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1c1c1a;
    --surface-2: #262624;
    --surface-3: #30302d;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #9a998f;
    --border: #33332f;
    --grid: #2a2a27;
    --axis: #4a4a45;
    --accent: #3987e5;
    --accent-strong: #86b6ef;
    --accent-soft: #182a42;
    --btn-bg: #2a78d6;
    --btn-bg-press: #1c5cab;
    --series-1: #3987e5;
    --danger: #e66767;
    --danger-soft: #3a2020;
    --good: #4cc24c;
    --tip-bg: #f0efec;
    --tip-ink: #0b0b0b;
    --toast-action: #1c5cab;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1c1c1a;
  --surface-2: #262624;
  --surface-3: #30302d;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --text-3: #9a998f;
  --border: #33332f;
  --grid: #2a2a27;
  --axis: #4a4a45;
  --accent: #3987e5;
  --accent-strong: #86b6ef;
  --accent-soft: #182a42;
  --btn-bg: #2a78d6;
  --btn-bg-press: #1c5cab;
  --series-1: #3987e5;
  --danger: #e66767;
  --danger-soft: #3a2020;
  --good: #4cc24c;
  --tip-bg: #f0efec;
  --tip-ink: #0b0b0b;
  --toast-action: #1c5cab;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.noscroll { overflow: hidden; }
button, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0 0 10px; }
[hidden] { display: none !important; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-3); }
.small { font-size: 13.5px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  max-width: 640px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #2a78d6, #104281);
}
.brand-mark svg { width: 18px; height: 18px; fill: #fab219; stroke: none; }
.topbar h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.rate-chip {
  display: inline-flex; align-items: center; gap: 1px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 600; white-space: nowrap;
}
.rate-chip .rc-unit { color: var(--text-3); font-weight: 500; }
.rate-chip .ic { width: 16px; height: 16px; margin-right: 4px; }

main { max-width: 640px; margin: 0 auto; padding: 4px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px); }
.view { display: flex; flex-direction: column; gap: 12px; }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.card-head.pad { padding: 14px 16px 6px; margin: 0; }
.card-head h3, .card-title { font-size: 16px; font-weight: 650; }
.card-title { margin-bottom: 12px; }
.eyebrow { font-size: 13px; color: var(--text-2); font-weight: 500; }

/* hero */
.hero { padding: 18px 18px 16px; }
.hero-value { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 2px; }
.hero-value .big { font-size: 52px; font-weight: 650; letter-spacing: -0.02em; line-height: 1; }
.hero-value .big-unit { font-size: 18px; color: var(--text-2); font-weight: 500; }
.hero-sub { font-size: 16px; color: var(--text-2); }
.hero-sub strong { color: var(--text); font-weight: 650; }
.hero-sub .dot { margin: 0 6px; color: var(--text-3); }
.hero-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.hf-item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.hf-item .ic { width: 16px; height: 16px; color: var(--text-3); }

/* tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.t-label { font-size: 13px; color: var(--text-2); }
.t-value { font-size: 26px; font-weight: 650; margin: 4px 0 2px; letter-spacing: -0.01em; line-height: 1.1; }
.t-unit { font-size: 14px; color: var(--text-2); font-weight: 500; margin-left: 5px; letter-spacing: 0; }
.t-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* charts */
.chart { position: relative; min-height: 180px; margin: 4px -4px 0; }
.chart-wrap { position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .grid.base { stroke: var(--axis); }
.chart .tick, .chart .xl { fill: var(--text-3); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--series-1); }
.chart .hl { fill: var(--text); opacity: 0.06; }
.chart .peak { fill: var(--text-2); font-size: 10.5px; font-weight: 650; }
.chart .empty-note { fill: var(--text-3); font-size: 12.5px; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  transform: translate(-50%, calc(-100% - 8px));
  background: var(--tip-bg); color: var(--tip-ink);
  border-radius: 8px; padding: 6px 10px; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.tt-title { font-size: 12px; opacity: 0.8; }
.tt-body { font-size: 13px; font-weight: 600; }
.chart-cap { font-size: 13px; color: var(--text-2); margin-top: 6px; }
.chart-cap strong { color: var(--text); font-weight: 600; }

/* lists */
.list-card { padding: 0; overflow: hidden; }
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 16px; border: 0; background: transparent; text-align: left;
  border-top: 1px solid var(--border);
}
.list .row:first-child { border-top: 0; }
.list-card .card-head + .list .row:first-child { border-top: 1px solid var(--border); }
.row:active { background: var(--surface-2); }
.row-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; flex: none; }
.row-ic .ic { width: 17px; height: 17px; color: var(--accent-strong); }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-title { font-weight: 600; font-size: 15.5px; }
.row-meta { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* history */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px; }
.mn-center { text-align: center; min-width: 0; }
.mn-title { font-size: 17px; font-weight: 650; }
.mn-sub { font-size: 13px; color: var(--text-2); }
.hist-actions { display: flex; justify-content: space-between; align-items: center; min-height: 24px; padding: 0 4px; }
.day-group { display: flex; flex-direction: column; gap: 6px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 4px 0; gap: 8px; }
.dh-date { font-weight: 600; font-size: 14.5px; }
.dh-total { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 600; text-decoration: none; transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.985); background: var(--surface-2); }
.btn .ic { width: 18px; height: 18px; }
.btn.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: #fff; }
.btn.primary:active { background: var(--btn-bg-press); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.busy { opacity: 0.6; pointer-events: none; }
.btn:disabled { opacity: 0.45; }
.link {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 4px 0; color: var(--accent-strong); font-weight: 600; font-size: 14px;
}
.link .ic { width: 16px; height: 16px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--text-2);
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.3; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }

/* chips + segmented */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 9px 14px; font-size: 14px; font-weight: 500; line-height: 1;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.chip.sm { padding: 8px 12px; font-size: 13.5px; }
.chip.ghost { border-color: transparent; color: var(--text-3); }
.chip:active { background: var(--surface-2); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg.full { display: flex; }
.seg.full button { flex: 1; }
.seg button {
  border: 0; background: transparent; color: var(--text-2);
  font-size: 13.5px; font-weight: 500; padding: 7px 12px; border-radius: 8px; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

/* forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 14px; font-weight: 600; color: var(--text); }
.field input, .units-box {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
.field input:focus, .units-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field input[type="date"] { min-width: 0; }
.hint { font-size: 12.5px; color: var(--text-3); }
.date-row { display: flex; gap: 8px; align-items: center; }
.date-row input { flex: 1; }
.units-box { display: flex; align-items: baseline; gap: 8px; padding: 6px 16px; }
.units-box input {
  border: 0; background: transparent; padding: 0; min-height: 0; box-shadow: none !important;
  font-size: 36px; font-weight: 650; width: 100%; letter-spacing: -0.01em;
}
.ub-suffix { color: var(--text-2); font-size: 16px; font-weight: 500; }
.quick { margin-top: 2px; }
.cost-line {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 15px;
}
.cost-line strong { font-size: 18px; }
.err { color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--btn-bg); flex: none; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.tr-text { display: flex; flex-direction: column; }
.tr-title { font-weight: 600; font-size: 15px; }
.tr-sub { font-size: 13px; color: var(--text-3); }
.switch {
  -webkit-appearance: none; appearance: none; width: 46px; height: 28px; border-radius: 999px; flex: none;
  background: var(--surface-3); position: relative; transition: background 0.15s; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s;
}
.switch:checked { background: var(--btn-bg); }
.switch:checked::after { transform: translateX(18px); }

/* reports */
.preview .pv-range { font-size: 18px; font-weight: 650; margin: 4px 0 12px; }
.pv-note { margin: -6px 0 12px; }
.preview .pv-range .muted { font-weight: 400; font-size: 15px; }
.pv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.pv-v { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.pv-l { font-size: 12.5px; color: var(--text-3); }
.actions { display: flex; flex-direction: column; gap: 10px; }

/* settings */
.rate-now { margin: 2px 0 10px; }
.rn-v { font-size: 28px; font-weight: 650; }
.rate-list { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; }
.rate-item { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 12px; border-top: 1px solid var(--border); }
.rate-item:first-child { border-top: 0; }
.ri-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.ri-d { flex: 1; font-size: 13.5px; }
.kv { display: flex; justify-content: space-between; font-size: 14px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 6px 0 12px; }
.kv span:first-child { color: var(--text-2); }
.btn-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.pill.good { color: var(--good); font-weight: 600; }
.pill .ic { width: 15px; height: 15px; }
.about { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; color: var(--text-3); text-align: center; margin: 4px 0 0; }
.about .ic { width: 14px; height: 14px; }

/* empty + welcome */
.empty { text-align: center; padding: 26px 20px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty.slim { padding: 18px; color: var(--text-2); }
.empty.slim p { margin: 0; }
.empty h2, .welcome h2 { font-size: 20px; }
.empty p { color: var(--text-2); max-width: 36ch; }
.empty-mark {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(145deg, #2a78d6, #104281); margin-bottom: 4px;
}
.empty-mark .ic { width: 28px; height: 28px; fill: #fab219; stroke: #fab219; }
.welcome { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 4px 0 18px; }
.welcome p { max-width: 38ch; margin: 0; }

/* banners */
.banner {
  display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 8px 10px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 14px; padding: 12px 6px 12px 12px;
}
.banner .b-ic { color: var(--accent-strong); margin-top: 1px; }
.b-text { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; color: var(--text-2); }
.b-text strong { color: var(--text); font-size: 15px; }
.banner > .btn { grid-column: 2; grid-row: 2; justify-self: start; }
.banner > .icon-btn { grid-column: 3; grid-row: 1; margin-top: -6px; }

/* tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 max(8px, env(safe-area-inset-left)) env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--surface); border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 100%; border: 0; background: none; color: var(--text-3); font-size: 11.5px; font-weight: 500;
}
.tab .ic { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--accent-strong); font-weight: 600; }
.fab {
  width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center;
  background: var(--btn-bg); color: #fff; margin-top: -22px;
  box-shadow: 0 6px 18px rgba(42, 120, 214, 0.38), 0 0 0 4px var(--bg);
}
.fab .ic { width: 26px; height: 26px; stroke-width: 2.4; }
.tab-add:active .fab { transform: scale(0.95); }
@media (min-width: 680px) { .tabbar { left: 50%; transform: translateX(-50%); max-width: 640px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); border-radius: 18px 18px 0 0; } }

/* sheets */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.42); opacity: 0; transition: opacity 0.22s; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  max-width: 640px; margin: 0 auto; max-height: 94vh; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 6px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.open { transform: none; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--surface-3); margin: 6px auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin: 0 -8px 12px 0; }
.sheet-head h2 { font-size: 20px; }
.sheet-body { margin-bottom: 16px; color: var(--text-2); }
.sheet-body strong { color: var(--text); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }

/* toast */
#toast {
  position: fixed; left: 50%; z-index: 80;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 16px;
  width: max-content; max-width: calc(100% - 32px);
  background: var(--tip-bg); color: var(--tip-ink); border-radius: 12px; padding: 12px 16px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: var(--toast-action); font-weight: 700; padding: 4px; white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 360px) {
  .hero-value .big { font-size: 44px; }
  .t-value { font-size: 22px; }
  .seg button { padding: 7px 9px; }
}
