:root {
  --bg: #f4f6f8; --card: #fff; --text: #1c2630; --muted: #6b7885; --line: #dde3e9;
  --accent: #0b7a75; --accent-text: #fff; --eff: #0b7a75; --est: #e0a526; --danger: #c0392b;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11171c; --card: #1a2229; --text: #e6ebef; --muted: #93a1ad; --line: #2b3640;
    --accent: #2bb3ac; --accent-text: #08201f; --eff: #2bb3ac; --est: #e8b84a; --danger: #ef6b5b; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
h1 { font-size: 1.15rem; margin: 0; padding: 12px 16px 4px; }
h1 small { color: var(--muted); font-weight: 400; font-size: .8rem; }
h2 { font-size: 1.15rem; margin: 4px 0 12px; }
h3 { font-size: 1rem; margin: 22px 0 8px; }
nav { display: flex; gap: 4px; overflow-x: auto; padding: 4px 12px 8px; }
nav button { flex: 0 0 auto; border: 0; background: none; color: var(--muted); padding: 8px 12px; border-radius: 8px; font: inherit; font-size: .92rem; cursor: pointer; }
nav button.active { background: var(--accent); color: var(--accent-text); }
main { max-width: 860px; margin: 0 auto; padding: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.card, .item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.card .label { color: var(--muted); font-size: .8rem; }
.card .value { font-size: 1.45rem; font-weight: 650; margin-top: 2px; }
.card .sub { color: var(--muted); font-size: .8rem; }
form { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
label { display: block; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
input, select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
input[type=range] { padding: 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 12px; }
.hint { color: var(--muted); font-size: .78rem; font-weight: 400; display: inline; }
label .hint { display: inline; }
p.hint { display: block; margin-top: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
button { font: inherit; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 8px; }
button.link.del { color: var(--danger); }
.preview { background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 10px; margin-bottom: 12px; min-height: 2.6em; }
.item { margin-bottom: 8px; }
.item .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item .when { font-weight: 600; }
.item .meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.item .tools { margin-top: 6px; }
.badge { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 99px; border: 1px solid currentColor; vertical-align: 1px; }
.badge.eff { color: var(--eff); } .badge.est { color: var(--est); }
.badge.type { color: var(--muted); }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .88rem; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; }
tr:last-child td { border-bottom: 0; } tfoot td { font-weight: 650; }
.tablewrap { overflow-x: auto; }
.empty { color: var(--muted); padding: 16px; text-align: center; }
#chart svg, #kwhChart svg, #costChart svg { width: 100%; height: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
#chart text, #kwhChart text, #costChart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 80px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; opacity: 0; transition: .25s; z-index: 10; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }

[hidden] { display: none !important; }

.login { max-width: 340px; margin: 12vh auto 0; padding: 0 20px; text-align: center; }
.login h1 { padding: 8px 0 0; font-size: 1.6rem; }
.login form { text-align: left; margin-top: 18px; }
.login button { width: 100%; }
.login .err { color: var(--danger); min-height: 1.4em; margin: 10px 0 0; text-align: center; }

.err { color: var(--danger); }
.plan-result { background: var(--accent); color: var(--accent-text); border-radius: 12px; padding: 16px; margin: 4px 0 12px; }
.plan-result .big { font-size: 2rem; font-weight: 700; line-height: 1.2; margin: 2px 0 6px; }
.plan-result div { font-size: .92rem; }
#planChart svg { width: 100%; height: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
#planChart text { fill: var(--muted); font-size: 9px; }

#vehBar { padding: 0 12px 6px; }
#vehBar label { display: flex; align-items: center; gap: 8px; margin: 0; }
#vehBar select { margin: 0; padding: 6px 8px; width: auto; min-width: 160px; }
.danger-box { background: var(--card); border: 1px solid var(--danger); border-radius: 12px; padding: 12px 14px; }
.danger-box p { margin-top: 0; font-size: .9rem; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:disabled { opacity: .4; cursor: not-allowed; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .85em; }

#logBox { max-height: 260px; overflow: auto; font-size: .72rem; white-space: pre-wrap; word-break: break-all; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 0 0 8px; }
.btn { display: inline-block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: inherit; background: var(--card); }
textarea { width: 100%; font: inherit; box-sizing: border-box; }
.notice { background: #fff4d6; border: 1px solid #e6c870; color: #5a4300; border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; }
@media (prefers-color-scheme: dark) { .notice { background: #3a3012; border-color: #7a6320; color: #f1dca0; } }
