/* Home Energy Dashboard theme (design §12). The palette lives only here; charts read the custom properties. */
:root {
  --bg: #0e1322;
  --panel: #161d33;
  --panel-2: #1c2541;
  --border: #2a3456;
  --text: #e8ecf7;
  --muted: #9aa5c4;
  --pink: #f050a8;
  --violet: #8b6cf6;
  --teal: #2ed3b7;
  --red: #ff6b6b;
  --gas: #4fa3ff;
  --amber: #ffb347;
  --hm-0: #1b2440;
  --hm-1: #2b3f7a;
  --hm-2: #5b4fc4;
  --hm-3: #b04fd8;
  --hm-4: #f050a8;
  --hm-5: #ffb347;
  --grad: linear-gradient(135deg, var(--violet), var(--pink));
  --radius: 12px;
  --gap: 16px;
  --sidebar-w: 224px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; }
h1, h2, h3, p { margin: 0; }
a { color: var(--pink); }
button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; }

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 14px; border-radius: 8px;
  background: var(--grad); color: var(--bg); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 8px; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view { padding: 0 24px 32px; outline: none; }

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--panel); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 17px; }
.brand__logo {
  width: 32px; height: 32px; border-radius: 9px; background: var(--grad); color: var(--bg);
  display: grid; place-items: center;
}
.brand__logo .icon { fill: currentColor; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav--bottom { margin-top: auto; }
.nav__group { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 16px 10px 6px; }
.nav__link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 9px;
  color: var(--text); text-decoration: none; background: none; border: 0; text-align: left; cursor: pointer;
}
.nav__link:hover { background: var(--panel-2); }
.nav__link[aria-current="page"] { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--pink); }
.nav__link--disabled { color: var(--muted); cursor: default; }
.nav__link--disabled:hover { background: none; }
.badge {
  margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted);
}
.scrim { display: none; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 18px 24px; position: sticky; top: 0; z-index: 5;
  background: var(--bg); border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.topbar h1 { font-size: 22px; }
.topbar__title { min-width: 0; flex: 1; }
.topbar__tariff { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar__right { display: flex; align-items: center; gap: 14px; }
.menu-btn {
  display: none; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 8px;
  cursor: pointer;
}
.menu-btn .icon { width: 20px; height: 20px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--grad); color: var(--bg); font-weight: 700;
  display: grid; place-items: center; font-size: 14px; flex: none;
}

.pills { display: inline-flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; }
.pills--small { padding: 3px; }
.pill {
  border: 0; background: none; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pill:hover { color: var(--text); }
.pill[aria-pressed="true"] { background: var(--grad); color: var(--bg); }

/* ---------- freshness banner ---------- */
.banner {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px;
  margin-bottom: var(--gap); font-size: 13px; color: var(--muted);
}
.banner__line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.banner__line .icon { color: var(--teal); }
.banner__warnings { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; }
.banner__warnings li { display: flex; gap: 8px; align-items: flex-start; color: var(--red); }
.banner__warnings .icon { color: var(--red); margin-top: 1px; }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.span-12-xl8 { grid-column: span 12; }
.span-12-xl4 { grid-column: span 12; }
@media (min-width: 1280px) {
  .span-12-xl8 { grid-column: span 8; }
  .span-12-xl4 { grid-column: span 4; }
}

/* ---------- cards ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  min-width: 0; display: flex; flex-direction: column; gap: 12px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card__head h2 { font-size: 16px; font-weight: 650; }
.card__sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 13px; }
.footnote { color: var(--muted); font-size: 12px; }

/* KPI cards */
.kpi { gap: 6px; position: relative; }
.kpi__label { color: var(--muted); font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.kpi__sublabel { font-weight: 400; }
.kpi__total { font-size: 30px; font-weight: 750; letter-spacing: -.01em; }
.kpi__split { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.kpi__fuel { display: flex; justify-content: space-between; gap: 8px; }
.kpi__fuel-name { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--elec { background: var(--pink); }
.dot--gas { background: var(--gas); }
.kpi__foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; margin-top: 4px; }
.kpi__foot > .muted { white-space: nowrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: var(--panel-2); border: 1px solid var(--border);
}
.chip--down { color: var(--teal); }
.chip--up { color: var(--red); }
.chip--flat { color: var(--muted); }
.chip--final { color: var(--teal); align-self: flex-start; }
.kpi--highlight { border: 1px solid transparent; background: linear-gradient(var(--panel), var(--panel)) padding-box, var(--grad) border-box; }
.kpi--active { box-shadow: 0 0 0 2px var(--pink); }
.kpi--highlight.kpi--active { box-shadow: 0 0 0 2px rgba(240, 80, 168, .45); }
.kpi__forecast { font-size: 13px; padding-top: 6px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.kpi__forecast strong { color: var(--text); }
.progress-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
progress { flex: 1; height: 6px; appearance: none; border: 0; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--panel-2); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--grad); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--grad); border-radius: 999px; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tile__label { color: var(--muted); font-size: 12px; }
.tile__value { font-size: 18px; font-weight: 700; margin-top: 2px; }
.tile__sub { color: var(--muted); font-size: 12px; }
.tile__value--down { color: var(--teal); }
.tile__value--up { color: var(--red); }
.tile__value--text { font-size: 14px; font-weight: 600; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
caption { text-align: left; color: var(--muted); font-size: 13px; padding-bottom: 8px; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td, tr:last-child th { border-bottom: 0; }
.vs-down { color: var(--teal); font-weight: 600; }
.vs-up { color: var(--red); font-weight: 600; }
.vs-flat { color: var(--muted); }
.table-scroll { overflow-x: auto; }

/* Charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .label-strong { fill: var(--text); font-weight: 600; }
.chart .label-pink { fill: var(--pink); }
.chart .label-ref { fill: var(--muted); }
.chart-wrap { position: relative; }
.chart-empty { color: var(--muted); font-size: 14px; padding: 40px 0; text-align: center; }
details.data { font-size: 12px; color: var(--muted); }
details.data summary { cursor: pointer; width: max-content; }
details.data table { margin-top: 8px; font-size: 12px; }
details.data .table-scroll { max-height: 260px; overflow: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.swatch--elec { background: var(--grad); }
.swatch--carbon { background: var(--teal); }
.swatch--gas { background: var(--gas); }
.swatch--actual { background: var(--pink); }
.swatch--proj { background: var(--violet); }
.swatch--ref { background: var(--muted); }
.swatch--flexible { background: var(--muted); }
.swatch--tracker { background: var(--teal); }
.swatch--agile { background: var(--violet); }
.swatch--agile_shift { background: var(--pink); }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.heat-legend__bar { height: 8px; width: 160px; border-radius: 4px; background: linear-gradient(90deg, var(--hm-0), var(--hm-1), var(--hm-2), var(--hm-3), var(--hm-4), var(--hm-5)); }

/* Weather */
.wx { display: flex; gap: 14px; align-items: center; }
.wx__icon { width: 56px; height: 56px; }
.wx__temp { font-size: 30px; font-weight: 750; }
.wx__facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-size: 13px; }
.wx__facts dt { color: var(--muted); }
.wx__facts dd { margin: 0; font-weight: 600; }
.wx__days { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.wx__day { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px; text-align: center; font-size: 12px; }
.wx__day .icon { width: 28px; height: 28px; margin: 2px auto; display: block; }
.wx__day-name { color: var(--muted); }

/* Phase 2 placeholders */
.placeholder { border: 2px dashed var(--border); background: transparent; justify-content: center; align-items: flex-start; }
.placeholder .icon { width: 28px; height: 28px; color: var(--muted); }
.placeholder p { color: var(--muted); font-size: 13px; }

/* Forms */
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: var(--gap); }
.field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
input[type="date"], select {
  background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; color: var(--text);
}
.btn {
  border: 0; border-radius: 9px; padding: 9px 16px; font-weight: 700; cursor: pointer; background: var(--grad); color: var(--bg);
}
.page-title { font-size: 18px; margin-bottom: 12px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.tick { color: var(--teal); font-weight: 700; }
.cross { color: var(--red); font-weight: 700; }
.status-ok { color: var(--teal); }
.status-bad { color: var(--red); }
.error-card { max-width: 560px; margin: 40px auto; }
.loading { color: var(--muted); padding: 24px 0; }
.list { margin: 0; padding-left: 18px; font-size: 13px; }
.list--plain { list-style: none; padding-left: 0; }

/* ---------- mobile (< 768 px) ---------- */
@media (max-width: 767px) {
  .view { padding: 0 14px 24px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .grid > * { grid-column: 1 / -1; }
  .menu-btn { display: inline-flex; }
  .topbar { flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .topbar__title { flex: 1 1 calc(100% - 110px); }
  .topbar h1 { font-size: 19px; }
  .topbar__right { width: 100%; order: 3; justify-content: space-between; }
  .topbar__right .pills { overflow-x: auto; max-width: calc(100% - 50px); scrollbar-width: none; }
  .avatar { order: -1; position: absolute; top: 12px; right: 14px; }
  .topbar { position: relative; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 20; transform: translateX(-100%); visibility: hidden;
    transition: transform .2s ease, visibility .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .5);
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 15; }
  .kpi__total { font-size: 28px; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
