/* billshadow UI - tokens mirror icd-energy-manager (web/src/styles/theme.css) */
:root {
  color-scheme: light;
  --bg: #fbfbfc; --surface: #ffffff; --surface-2: #f5f6f8; --surface-3: #eef0f3;
  --border: #e8e9ed; --border-strong: #d7d9df;
  --fg: #0b0d12; --fg-muted: #555b68; --fg-subtle: #858b98;
  --accent: #0ea5a4; --accent-hover: #0b8f8e; --accent-strong: #0a7c7b; --accent-soft: rgba(14,165,164,.10);
  --elec: #f59e0b; --gas: #8b5cf6;
  --success: #15803d; --success-soft: rgba(21,128,61,.10);
  --warning: #b45309; --warning-soft: rgba(180,83,9,.10);
  --danger: #dc2626; --danger-soft: rgba(220,38,38,.09);
  --info: #2563eb; --info-soft: rgba(37,99,235,.09);
  /* coverage status series - validated (dataviz) for CVD + contrast on --surface */
  --s-evidenced: #15803d; --s-linked: #2563eb; --s-mismatch: #d97706; --s-contract: #7c3aed; --s-gap: #dc2626; --s-neutral: #c3c7cf;
  --shadow-xs: 0 1px 2px rgba(16,18,24,.04); --shadow-sm: 0 1px 3px rgba(16,18,24,.06), 0 1px 2px rgba(16,18,24,.04);
  --shadow-lg: 0 12px 32px rgba(16,18,24,.12);
  --r-md: 6px; --r-lg: 8px; --r-xl: 12px;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --sans: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0d12; --surface: #11141a; --surface-2: #161a21; --surface-3: #1c2129;
    --border: #22262f; --border-strong: #2e333e;
    --fg: #eceef2; --fg-muted: #9ba1ad; --fg-subtle: #6b7180;
    --accent: #14b8b6; --accent-hover: #2dd4d1; --accent-soft: rgba(20,184,182,.14);
    --success: #22a052; --success-soft: rgba(34,160,82,.16); --warning: #e0a030; --warning-soft: rgba(224,160,48,.14);
    --danger: #ef4444; --danger-soft: rgba(239,68,68,.15); --info: #4b83f0; --info-soft: rgba(75,131,240,.15);
    --s-evidenced: #22a052; --s-linked: #4b83f0; --s-mismatch: #c27508; --s-contract: #9b6cf5; --s-gap: #ef4444; --s-neutral: #3a404c;
    --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12; --surface: #11141a; --surface-2: #161a21; --surface-3: #1c2129;
  --border: #22262f; --border-strong: #2e333e;
  --fg: #eceef2; --fg-muted: #9ba1ad; --fg-subtle: #6b7180;
  --accent: #14b8b6; --accent-hover: #2dd4d1; --accent-soft: rgba(20,184,182,.14);
  --success: #22a052; --success-soft: rgba(34,160,82,.16); --warning: #e0a030; --warning-soft: rgba(224,160,48,.14);
  --danger: #ef4444; --danger-soft: rgba(239,68,68,.15); --info: #4b83f0; --info-soft: rgba(75,131,240,.15);
  --s-evidenced: #22a052; --s-linked: #4b83f0; --s-mismatch: #c27508; --s-contract: #9b6cf5; --s-gap: #ef4444; --s-neutral: #3a404c;
  --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg); font: 13px/1.5 var(--sans);
  font-feature-settings: "cv11", "ss01"; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); text-decoration: none; }
:root[data-theme="dark"] a, :root:not([data-theme="light"]) a { color: var(--accent); }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--fg-muted); } .subtle { color: var(--fg-subtle); }
.num { text-align: right; font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* ── layout ── */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; padding: 14px 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #0b6b8f); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm); }
.brand-name { font-weight: 650; letter-spacing: -.01em; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--fg-subtle); }
.nav-group { font-size: 11px; color: var(--fg-subtle); padding: 12px 10px 4px; text-transform: uppercase; letter-spacing: .06em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-md); color: var(--fg-muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--fg); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
:root[data-theme="dark"] .nav a.active { color: var(--accent); }
.nav svg { width: 16px; height: 16px; flex: none; }
.nav .count { margin-left: auto; font-size: 11px; font-family: var(--mono); color: var(--fg-subtle); }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 11px; color: var(--fg-subtle); display: flex; flex-direction: column; gap: 8px; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(8px); }
.search { flex: 1; max-width: 520px; position: relative; }
.search input { width: 100%; height: 34px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-lg); padding: 0 12px 0 34px; outline: none; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--fg-subtle); }
.kbd { font: 11px var(--mono); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--fg-subtle); }
.search .kbd { position: absolute; right: 9px; top: 8px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-subtle); }
.dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
.page { padding: 22px 24px 60px; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 20px; font-weight: 650; letter-spacing: -.015em; margin: 0; }
h2 { font-size: 13px; font-weight: 600; margin: 0; letter-spacing: -.005em; }
.lede { color: var(--fg-muted); margin: 4px 0 0; max-width: 820px; }

/* ── components ── */
.btn { height: 32px; padding: 0 12px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; box-shadow: var(--shadow-xs); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn svg { width: 14px; height: 14px; }
.icon-btn { width: 32px; padding: 0; justify-content: center; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-h { min-height: 48px; padding: 14px 16px 10px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-h h2 { font-size: 13px; }
.card-h p { margin: 2px 0 0; font-size: 12px; color: var(--fg-muted); }
.card-b { padding: 0 16px 16px; }
.card-f { border-top: 1px solid var(--border); padding: 10px 16px; font-size: 12px; color: var(--fg-muted); }
.kpi { padding: 16px; }
.kpi .label { font-size: 12px; color: var(--fg-muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.hero { padding: 20px; display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: center; }
.hero .big { font-size: 46px; font-weight: 700; letter-spacing: -.035em; line-height: 1; }
.hero .big small { font-size: 22px; color: var(--fg-muted); font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: var(--r-md); font-size: 11px; font-weight: 550; white-space: nowrap; background: var(--surface-3); color: var(--fg-muted); }
.badge .bd { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge.contract { background: rgba(124,58,237,.10); color: var(--s-contract); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md); padding: 0 10px; outline: none; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-md); padding: 2px; background: var(--surface-2); }
.seg button { border: 0; background: transparent; height: 26px; padding: 0 10px; border-radius: 4px; cursor: pointer; color: var(--fg-muted); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-xs); }

/* tables */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--fg-subtle); text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tr.click { cursor: pointer; }
.trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--fg-muted); font-size: 12px; }

/* status bars */
.sbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: transparent; }
.sbar.lg { height: 16px; border-radius: 6px; }
.sbar span { display: block; min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--fg-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--fg); font-weight: 600; font-family: var(--mono); font-size: 12px; margin-left: 4px; }
.mini { width: 120px; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text, .chart text.ax { fill: var(--fg-subtle); font-size: 10.5px; font-family: var(--sans); }
.chart .grid line { stroke: var(--border); }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; min-width: 150px; opacity: 0; transition: opacity .08s; }
.tip.on { opacity: 1; }
.tip .t { font-weight: 600; margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .r i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* feed */
.feed { max-height: 420px; overflow: auto; }
.ev { display: grid; grid-template-columns: 62px 74px 1fr; gap: 8px; padding: 7px 16px; border-bottom: 1px solid var(--border); font-size: 12px; animation: fadein .25s; }
.ev:last-child { border-bottom: 0; }
.ev .when { color: var(--fg-subtle); font-family: var(--mono); font-size: 11px; }
.ev .msg { min-width: 0; overflow-wrap: anywhere; }
@keyframes fadein { from { background: var(--accent-soft); } }
.progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* detail */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--fg-muted); }
.kv dd { margin: 0; }
.prose { color: var(--fg-muted); line-height: 1.6; }
.empty { padding: 36px 16px; text-align: center; color: var(--fg-muted); }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-md); height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); font-size: 13px; z-index: 50; animation: fadein .2s; }
.answer { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; background: var(--surface-2); }
.answer .rate { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.src-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.src-card .links { font-size: 12px; max-height: 140px; overflow: auto; }

/* sweeps */
.sw-label { font-size: 12px; font-weight: 600; color: var(--fg-muted); margin-bottom: 6px; }
.in { width: 100%; height: 30px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md); padding: 0 8px; outline: none; }
.in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.in.md { width: 76px; }
.in.bad { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.sw-win td { padding: 6px 8px; vertical-align: middle; }
.sw-win th { padding: 6px 8px; }
.sw-win tbody tr:hover td { background: transparent; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-muted); cursor: pointer; white-space: nowrap; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 30px; height: 18px; border-radius: 9px; background: var(--border-strong); position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.sw-next { display: flex; flex-direction: column; }
.sw-next > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.sw-next > div:last-child { border-bottom: 0; }
.sw-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 14px; border-radius: var(--r-lg); margin-bottom: 14px; font-size: 13px; border: 1px solid transparent; }
.sw-banner.warn { background: var(--warning-soft); }
.sw-banner.ok { background: var(--success-soft); }
.sw-banner.info { background: var(--info-soft); justify-content: flex-start; }
.sw-log { margin: 0; padding: 12px 16px; max-height: 360px; overflow: auto; background: var(--surface-2); font: 11.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.yr { overflow-x: auto; }
.yr-row { display: grid; grid-template-columns: 56px repeat(31, minmax(12px, 1fr)); gap: 3px; margin-bottom: 3px; min-width: 520px; align-items: center; }
.yr-head span { font-size: 10px; color: var(--fg-subtle); text-align: center; font-family: var(--mono); }
.yr-m { font-size: 11px; color: var(--fg-muted); white-space: nowrap; }
.yr-d { height: 14px; border-radius: 3px; background: var(--surface-3); }
.yr-d.we { opacity: .7; }
.yr-d.wk { background: color-mix(in srgb, var(--accent) 40%, transparent); opacity: 1; }
.yr-d.win { background: var(--accent); opacity: 1; }
.yr-d.today { outline: 2px solid var(--fg); outline-offset: 1px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-main, .g3 { grid-template-columns: 1fr; } .hero { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .nav-group, .sidebar-foot, .brand-sub { display: none; }
  .nav { display: flex; flex-wrap: wrap; }
  .page { padding: 16px; } .topbar { padding: 8px 16px; } .g4, .g2 { grid-template-columns: 1fr; }
}

/* add rates (upload) */
.up-form { display: grid; gap: 12px; }
.up-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
.up-form .subtle { font-weight: 400; font-size: 12px; }
.up-form input:not([type=checkbox]):not([type=file]), .up-form select { height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md); padding: 0 10px; outline: none; }
.up-form input:focus, .up-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.up-form fieldset { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px 12px; display: grid; gap: 10px; margin: 0; }
.up-form legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.up-form .up-check { display: flex; align-items: center; gap: 8px; font-weight: 400; }

/* sign-in gate, account, people */
body.gated .app { display: none; }
#gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.gate-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow-xs); display: grid; gap: 14px; }
.gate-card h1 { margin: 0; font-size: 20px; }
.gate-brand { display: flex; align-items: center; gap: 10px; }
.gate-msg { padding: 8px 12px; border-radius: var(--r-md); font-size: 13px; }
.gate-msg.danger { background: var(--danger-soft); }
.gate-msg.info { background: var(--info-soft); }
.gate-msg.ok { background: var(--success-soft); }
.gate-foot { margin: 0; font-size: 12px; }
body:not(.can-editor) .need-editor, body:not(.can-admin) .need-admin { display: none !important; }
#who { display: grid; gap: 2px; font-size: 12px; }
#who .who-name { color: var(--fg); font-weight: 600; }
.qr { width: 180px; height: 180px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: var(--r-md); }
.pp-act { white-space: nowrap; text-align: right; }
.pp-act .btn { height: 28px; padding: 0 8px; font-size: 12px; }
.btn.danger { border-color: var(--danger, #dc2626); color: var(--danger, #dc2626); }
.pp-link { display: flex; gap: 8px; margin-top: 8px; }
.pp-link input { flex: 1; min-width: 0; height: 32px; border: 1px solid var(--border); border-radius: var(--r-md); padding: 0 10px; background: var(--surface-2); font: 12px var(--mono); }
[hidden] { display: none !important; }
