:root {
  --bg: #f3f5f2; --surface: #ffffff; --surface-2: #f7f8f6; --text: #18211d; --muted: #66726c; --line: #e2e6e1;
  --accent: #1d7a55; --accent-2: #e2f1e9; --accent-ink: #ffffff;
  --sun: #e3a21a; --grid: #3b7dd8; --bat: #1d9a6c; --load: #8b5bd6; --warn: #c2511f; --warn-2: #fbe9df;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .05);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --surface: #171e1b; --surface-2: #1d2622; --text: #e6ece8; --muted: #8d9a93; --line: #27312c;
    --accent: #3fbf8a; --accent-2: #183328; --accent-ink: #08130e;
    --sun: #f0b93a; --grid: #6aa3f0; --bat: #3fbf8a; --load: #b08cf0; --warn: #f08a5d; --warn-2: #3a2219;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 頂部 ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1120px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.brand .logo svg { width: 18px; height: 18px; color: var(--accent-ink); }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 10px; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; gap: 6px; }
.tabs button svg { width: 17px; height: 17px; }
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.pill.on .dot { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; width: 34px; height: 34px;
  display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

main { max-width: 1120px; margin: 0 auto; padding: 20px 20px 100px; }
section.tab { display: none; }
section.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-h h2 { font-size: 15px; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-h h2 svg { width: 18px; height: 18px; color: var(--muted); }
.sub { color: var(--muted); font-size: 13px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; }
.layout > .stack > .card + .card { margin-top: 16px; }
.section-title { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .4px; margin: 28px 4px 10px; }

/* ---------- 能量流向 ---------- */
.flow { width: 100%; height: auto; display: block; }
.flow .wire { fill: none; stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.flow .wire.live { stroke-dasharray: 2 9; stroke-width: 3.5; animation: flow 1s linear infinite; }
.flow .wire.live.rev { animation-direction: reverse; }
.flow .wire.sun.live { stroke: var(--sun); } .flow .wire.grid.live { stroke: var(--grid); }
.flow .wire.bat.live { stroke: var(--bat); } .flow .wire.load.live { stroke: var(--load); }
@keyframes flow { to { stroke-dashoffset: -22; } }
.flow .node circle { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.5; }
.flow .node.on circle { stroke-width: 2; }
.flow .node.sun.on circle { stroke: var(--sun); } .flow .node.grid.on circle { stroke: var(--grid); }
.flow .node.bat.on circle { stroke: var(--bat); } .flow .node.load.on circle { stroke: var(--load); }
.flow .node .ic { color: var(--muted); }
.flow .node.sun.on .ic { color: var(--sun); } .flow .node.grid.on .ic { color: var(--grid); }
.flow .node.bat.on .ic { color: var(--bat); } .flow .node.load.on .ic { color: var(--load); }
.flow .hub rect { fill: var(--accent); }
.flow .hub .ic { color: var(--accent-ink); }
.flow text { fill: var(--text); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.flow text.lab { fill: var(--muted); font-size: 11px; font-weight: 500; }

/* ---------- SOC ---------- */
.soc { display: flex; align-items: center; gap: 20px; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring .val { fill: none; stroke: var(--bat); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring.low .val { stroke: var(--warn); }
.ring .c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .c b { font-size: 30px; line-height: 1; }
.ring .c b small { font-size: 14px; font-weight: 500; color: var(--muted); }
.ring .c span { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kv { display: grid; gap: 8px; flex: 1; }
.kv div { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.kv div span:first-child { color: var(--muted); }
.kv div span:last-child { font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); }
.badge.green { background: var(--accent-2); color: var(--accent); }
.badge.warn { background: var(--warn-2); color: var(--warn); }

/* ---------- 模式卡片 ---------- */
.modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mode { position: relative; text-align: left; border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 14px;
  padding: 14px; cursor: pointer; transition: border-color .15s, transform .15s; }
.mode:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-1px); }
.mode .code { font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.mode .name { font-size: 13px; font-weight: 600; margin-top: 2px; }
.mode .desc { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.mode .chain { display: flex; gap: 3px; margin-top: 10px; }
.mode .chain i { width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center; }
.mode .chain i svg { width: 12px; height: 12px; }
.mode .chain i.sun { background: color-mix(in srgb, var(--sun) 18%, transparent); color: var(--sun); }
.mode .chain i.grid { background: color-mix(in srgb, var(--grid) 18%, transparent); color: var(--grid); }
.mode .chain i.bat { background: color-mix(in srgb, var(--bat) 18%, transparent); color: var(--bat); }
.mode.current { border-color: var(--accent); background: var(--accent-2); cursor: default; transform: none; }
.mode.current::after { content: "使用中"; position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 700;
  color: var(--accent-ink); background: var(--accent); padding: 1px 8px; border-radius: 999px; }
.mode:disabled { opacity: .6; }
.sched-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ---------- 數據格 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 11px 13px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 19px; font-weight: 700; margin-top: 2px; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }

/* ---------- 表單 ---------- */
input, select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; min-width: 0; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type=number] { width: 120px; } input[type=time] { width: 128px; }
input:disabled, select:disabled { opacity: .6; }
.btn { border: 0; border-radius: 10px; padding: 8px 16px; cursor: pointer; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.warn { background: var(--warn); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: background .15s; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%;
  background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ---------- 設定 ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 500px), 1fr)); gap: 16px; }
.settings-grid .card + .card { margin-top: 0; }
.srow { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.srow:first-of-type { border-top: 0; padding-top: 0; }
.srow .l { flex: 1; min-width: 0; }
.srow .l .n { font-size: 14px; font-weight: 500; }
.srow .l .u { font-size: 12px; color: var(--muted); }
.srow .c { display: flex; align-items: center; gap: 8px; }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; margin-left: 6px; vertical-align: 1px; }
.tag.danger { background: var(--warn-2); color: var(--warn); }
.tag.ro { background: var(--surface-2); color: var(--muted); }
.srow .apply { visibility: hidden; }
.srow.dirty .apply { visibility: visible; }
.srow.dirty input, .srow.dirty select { border-color: var(--accent); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- 排程 ---------- */
.timeline { display: grid; grid-template-columns: 44px 1fr; gap: 6px 10px; align-items: center; }
.timeline .d { font-size: 13px; color: var(--muted); font-weight: 600; }
.timeline .d.today { color: var(--accent); }
.timeline .bar { position: relative; display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.timeline .seg { height: 100%; min-width: 1px; position: relative; }
.timeline .seg.def { background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, color-mix(in srgb, var(--line) 70%, transparent) 6px 7px); }
.timeline .now { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); border-radius: 2px; }
.timeline .axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.rule { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--surface-2); border-left: 5px solid var(--rc, var(--accent)); }
.rule + .rule { margin-top: 12px; }
.rule.off { opacity: .6; }
.rule .top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rule .top input[type=text] { flex: 1 1 180px; font-weight: 600; background: var(--surface); }
.rule .tools { display: flex; gap: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 10px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; user-select: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip.quick { border-style: dashed; color: var(--muted); }
.timerange { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.timerange input { background: var(--surface); }
.actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 14px; }
.actions label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.actions select, .actions input { width: 100%; background: var(--surface); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 14px; }
.savebar { position: sticky; bottom: 16px; margin-top: 16px; display: flex; justify-content: flex-end; gap: 10px; }
.savebar .btn { box-shadow: 0 6px 20px rgba(0,0,0,.15); }

/* ---------- 紀錄 ---------- */
.logs { list-style: none; margin: 0; padding: 0; }
.logs li { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.logs li:first-child { border-top: 0; }
.logs .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.logs .ic svg { width: 15px; height: 15px; }
.logs .ic.write { background: var(--accent-2); color: var(--accent); }
.logs .ic.sched { background: color-mix(in srgb, var(--grid) 15%, transparent); color: var(--grid); }
.logs .ic.bad { background: var(--warn-2); color: var(--warn); }
.logs .t { font-size: 12px; color: var(--muted); }
.logs .m { font-size: 14px; }

/* ---------- 對話框與提示 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(10, 15, 12, .45); padding: 20px; }
.modal.show { display: grid; animation: fade .15s ease; }
.modal .box { background: var(--surface); border-radius: 18px; padding: 22px; width: min(420px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0; color: var(--muted); white-space: pre-line; }
.modal .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 12px; opacity: 0; transition: .2s; pointer-events: none; max-width: 90vw; z-index: 60; font-size: 14px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 登入 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(380px, 100%); }
.login .brand { margin-bottom: 22px; }
.login label { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); }
.login input { width: 100%; margin-top: 6px; padding: 11px 12px; }
.login .btn { width: 100%; justify-content: center; margin-top: 22px; padding: 11px; }
.err { color: var(--warn); font-size: 13px; min-height: 1.5em; margin-top: 10px; }

/* ---------- 手機 ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  /* backdrop-filter 會讓內層 fixed 元素相對頂部列定位，底部分頁列就跑不到底下 */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .topbar-in { padding: 10px 16px; }
  main { padding: 16px 16px 96px; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; margin: 0; z-index: 20; justify-content: space-around;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .tabs button { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 10px; flex: 1; }
  .tabs button svg { width: 21px; height: 21px; }
  .tabs button.active { box-shadow: none; background: var(--accent-2); color: var(--accent); }
  .pill .txt { display: none; }
  .card { padding: 16px; }
  .soc { flex-direction: column; align-items: stretch; }
  .ring { margin: 0 auto; }
  .srow { flex-wrap: wrap; }
  .srow .c { width: 100%; justify-content: flex-end; }
  .savebar { bottom: 84px; }
}

/* ---------- 雜項（CSP 不允許 HTML 內嵌 style） ---------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.mt16 { margin-top: 16px; }
.note { margin: 14px 0 0; }
.actions.flush { margin-top: 0; }
.legend i.def-swatch { background: repeating-linear-gradient(135deg, var(--surface-2) 0 3px, var(--line) 3px 4px); border: 1px solid var(--line); }
.timerange .tr-ic { width: 16px; height: 16px; }
.timerange .allday { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; cursor: pointer; margin-right: 6px; }
.timerange .times { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timerange .times[hidden] { display: none; }

/* ---------- 用電分析 ---------- */
:root { --p-peak: #eb6834; --p-semi: #2a78d6; --p-off: #1baf7a; --gridline: #e8ebe7; }
@media (prefers-color-scheme: dark) { :root { --p-peak: #d95926; --p-semi: #3987e5; --p-off: #199e70; --gridline: #26302b; } }
.field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .gl { stroke: var(--gridline); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { cursor: default; }
.chart .bar.peak { fill: var(--p-peak); } .chart .bar.semi { fill: var(--p-semi); } .chart .bar.off { fill: var(--p-off); }
.chart .hit { fill: transparent; }
.chart .hit:hover + .hl, .chart .col:hover .hl { opacity: 1; }
.chart .hl { fill: var(--text); opacity: 0; pointer-events: none; }
.chart .nowl { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 3 3; }
.chart .lbl { fill: var(--text); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend i.peak { background: var(--p-peak); } .legend i.semi { background: var(--p-semi); } .legend i.off { background: var(--p-off); }
.legend .rng { color: var(--muted); }
.table-wrap { overflow-x: auto; margin-top: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr.total td { font-weight: 700; border-bottom: 0; }
.tbl .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.peak { background: var(--p-peak); } .sw.semi { background: var(--p-semi); } .sw.off { background: var(--p-off); }
details.more summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 12px; }
details.more[open] summary { margin-bottom: 4px; }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.plan { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 16px; background: var(--surface-2); }
.plan.best { border-color: var(--accent); background: var(--accent-2); }
.plan h3 { margin: 0 0 8px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.plan .row2 { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.plan .row2 span:first-child { color: var(--muted); }
.plan .big { font-size: 22px; font-weight: 700; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.rates { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 10px; }
.rates fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 14px; margin: 0; }
.rates legend { font-weight: 600; font-size: 14px; padding: 0 4px; }
.rates label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.rates input { width: 96px; }
.tip { position: fixed; z-index: 70; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; line-height: 1.5;
  padding: 7px 10px; border-radius: 9px; opacity: 0; transition: opacity .1s; max-width: 240px; font-variant-numeric: tabular-nums; }
.tip.show { opacity: 1; }
.tip .b { font-weight: 700; }

/* ---------- 用電分析 v2 ---------- */
:root { --wk: #6250d6; --we: #e87ba4; }
@media (prefers-color-scheme: dark) { :root { --wk: #9085e9; --we: #d55181; } }
.en-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.en-bar .nav { display: flex; align-items: center; gap: 8px; }
.en-label { font-weight: 700; font-size: 16px; min-width: 150px; text-align: center; font-variant-numeric: tabular-nums; }
.en-sub { margin: 8px 2px 14px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.sm button { padding: 3px 10px; font-size: 12px; }
.en-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.en-grid .card + .card { margin-top: 0; }
.tile .v.up { color: var(--warn); } .tile .v.down { color: var(--accent); }
.delta { font-weight: 600; } .delta.up { color: var(--warn); } .delta.down { color: var(--accent); }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { width: 168px; flex: none; margin: 0 auto; }
.donut svg { width: 100%; height: auto; display: block; }
.donut .arc { stroke: var(--surface); stroke-width: 2; }
.donut .arc.peak { fill: var(--p-peak); } .donut .arc.semi { fill: var(--p-semi); } .donut .arc.off { fill: var(--p-off); }
.donut .ctr1 { fill: var(--text); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.donut .ctr2 { fill: var(--muted); font-size: 11px; }
.donut-list { flex: 1; min-width: 180px; display: grid; gap: 10px; }
.donut-list .it { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: baseline; }
.donut-list .it .nm { font-weight: 600; font-size: 14px; }
.donut-list .it .pc { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.donut-list .it .dt { grid-column: 2 / 4; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.wk { stroke: var(--wk); } .chart .line.we { stroke: var(--we); stroke-dasharray: 5 4; }
.chart .dot.wk { fill: var(--wk); } .chart .dot.we { fill: var(--we); }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .band.peak { fill: var(--p-peak); opacity: .07; } .chart .band.semi { fill: var(--p-semi); opacity: .07; }
.chart .xh { stroke: var(--muted); stroke-width: 1; opacity: 0; }
.chart .endlbl { font-size: 11px; font-weight: 600; fill: var(--text); }
.legend i.wk { background: var(--wk); } .legend i.we { background: repeating-linear-gradient(90deg, var(--we) 0 4px, transparent 4px 6px); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split .box { background: var(--surface-2); border-radius: 12px; padding: 14px; }
.split .box .t { font-size: 13px; color: var(--muted); font-weight: 600; }
.split .box .n { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.split .box .n small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.split .box .s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.split .bar2 { grid-column: 1 / 3; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.kpis .stat .v { font-size: 20px; }
.table-wrap.flush { margin-top: 0; }
@media (max-width: 860px) { .en-grid { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .en-bar { gap: 10px; }
  .en-bar .nav { width: 100%; justify-content: space-between; }
  .en-label { min-width: 0; flex: 1; font-size: 15px; }
  .split { grid-template-columns: 1fr 1fr; }
}
#en-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { #en-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { #en-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } #en-tiles .tile .v { font-size: 22px; } }
#en-battery { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
