/* Look and feel follows the "Power BI Dashboard Template Case" Figma community file:
   dark rounded shell, translucent dark cards with green edges, Open Sans, green accent. */
@font-face { font-family: "Open Sans"; font-weight: 300; font-display: swap; src: url(fonts/open-sans-latin-300-normal.woff2) format("woff2"); }
@font-face { font-family: "Open Sans"; font-weight: 400; font-display: swap; src: url(fonts/open-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Open Sans"; font-weight: 600; font-display: swap; src: url(fonts/open-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Open Sans"; font-weight: 700; font-display: swap; src: url(fonts/open-sans-latin-700-normal.woff2) format("woff2"); }

:root {
  color-scheme: dark;
  --bg: #0b0a0a; --surface: rgba(0, 0, 0, .30); --surface2: rgba(255, 255, 255, .07); --solid: #1b1e1c;
  --text: #f3f5f3; --muted: #a9b3ad; --line: rgba(255, 255, 255, .11);
  --card-border: rgba(26, 99, 42, .74); --card-border-soft: rgba(159, 164, 160, .35);
  --accent: #5be35b; --accent-ink: #04200a; --danger: #ff8a80; --ok: #5be35b;
  --on: #ff7a5c; --mid: #f7d35b; --off: #5be35b; --flat: #98a59e;
  --c-load: #8ab4ff; --c-solar: #f7d35b; --c-grid: #c9a0f0; --c-battery: #4cd0c0;
  --band-on: rgba(255, 122, 92, .17); --band-mid: rgba(247, 211, 91, .15); --band-off: rgba(91, 227, 91, .05); --band-flat: rgba(152, 165, 158, .06);
  --shell: linear-gradient(90deg, rgba(11, 58, 10, .97) 0, rgba(4, 41, 4, .97) 1.5%, rgba(55, 58, 55, .97) 1.5%, rgba(90, 93, 91, .97) 100%);
  --page: linear-gradient(180deg, #080707 0%, #1a1514 55%, #2d2422 100%);
  --header: rgba(44, 40, 40, .92); --welcome: rgba(31, 86, 17, .42);
  --shadow: none;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f3f1; --surface: #ffffff; --surface2: #eef1ee; --solid: #ffffff;
  --text: #1b2421; --muted: #5d6b65; --line: #d9dfdb;
  --card-border: #cfe0d2; --card-border-soft: #d9dfdb;
  --accent: #1f7a3a; --accent-ink: #ffffff; --danger: #b3261e; --ok: #1f7a4d;
  --on: #d9482b; --mid: #c98f00; --off: #1f8a55; --flat: #7b8a84;
  --c-load: #2b5fb4; --c-solar: #c98f00; --c-grid: #8a4fb0; --c-battery: #1a8f8f;
  --band-on: rgba(217, 72, 43, .12); --band-mid: rgba(224, 162, 27, .13); --band-off: rgba(47, 143, 107, .06); --band-flat: rgba(123, 138, 132, .05);
  --shell: #e4e9e5; --page: #d5dbd7; --header: #ffffff; --welcome: #e3f1e3;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overflow-anchor: none; scroll-behavior: auto; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0 0 .5rem; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5rem .8rem; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem;
  padding: .55rem 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.brand span:nth-child(2) { color: var(--text); }
button.badge { cursor: pointer; }
button.badge:hover { background: var(--accent); color: var(--accent-ink); }
.badge { font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--surface2); color: var(--muted); border: 1px solid var(--line); }
.tabs { display: flex; gap: .15rem; margin-left: auto; overflow-x: auto; }
.tabs a { padding: .4rem .75rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs a:hover { background: var(--surface2); }
.tabs a[aria-current="page"] { background: var(--surface2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--muted); width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--surface2); }

main { max-width: 1180px; margin: 0 auto; padding: 16px; outline: none; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { text-align: right; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.card > h2 + * { margin-top: 10px; }
.grid { display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.cols2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); min-height: 92px; }
.tile .label { font-size: .8rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.tile .value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.tile .value small { font-size: .9rem; font-weight: 600; color: var(--muted); margin-left: 2px; }
.tile .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 650; color: #fff; }
.pill.on { background: var(--on); } .pill.mid { background: var(--mid); color: #2a1f00; } .pill.off { background: var(--off); color: #04231a; } .pill.flat { background: var(--flat); }

.chart-box { position: relative; height: 320px; }
.chart-box.short { height: 240px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }

button, .btn, select, input, textarea {
  font: inherit; color: var(--text);
}
button, .btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .8rem;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; font-weight: 600;
}
button:hover, .btn:hover { background: var(--surface2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.active { background: var(--surface2); box-shadow: inset 0 -2px 0 var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .55rem; min-width: 0; }
input[type=number] { width: 7.5rem; }
input[type=text] { width: 100%; }
textarea { width: 100%; min-height: 220px; font: 12.5px/1.45 ui-monospace, Menlo, Consolas, monospace; }
label.field { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); font-weight: 600; }
label.field input, label.field select { font-weight: 400; color: var(--text); }
.seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; color: var(--muted); font-weight: 650; text-transform: none; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.bar { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; margin-bottom: 10px; }
.hbar:last-child { margin-bottom: 0; }
.hbar .bar { grid-column: 1 / -1; }

.notice { padding: .6rem .8rem; border-radius: 10px; background: var(--surface2); border: 1px solid var(--line); font-size: .9rem; }
.notice.warn { border-color: var(--mid); }
.notice.err { border-color: var(--danger); color: var(--danger); }
.ok { color: var(--ok); } .err { color: var(--danger); }
pre { margin: 0; padding: .7rem .8rem; background: var(--surface2); border-radius: 8px; overflow-x: auto; font: 12.5px/1.45 ui-monospace, Menlo, Consolas, monospace; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 99px; background: var(--flat); margin-right: 6px; }
.status-dot.live { background: var(--ok); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: .4rem .8rem; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .icon-btn { margin-left: auto; }
  .chart-box { height: 260px; }
  .tile .value { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.live-readout { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 10px 0 4px; }
.live-cell { display: grid; gap: 0; min-width: 90px; }
.live-cell .label { font-size: .78rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.live-num { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 99px; background: var(--ok); margin-right: 8px; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }


/* ------------------------------------------------------------------ Figma-style shell */
body { font-family: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--page) fixed; min-height: 100vh; padding: 20px 16px; }
.shell { max-width: 1280px; margin: 0 auto; border-radius: 24px; background: var(--shell); padding: 14px 14px 18px; border: 1px solid rgba(255, 255, 255, .08); }
.top { position: sticky; top: 8px; z-index: 5; border: 0; border-radius: 14px; background: var(--header); padding: .55rem 14px; backdrop-filter: blur(6px); }
.brand { color: var(--accent); font-size: 1.05rem; }
.brand .logo { width: 34px; height: 34px; border-radius: 99px; display: grid; place-items: center; color: var(--accent-ink); background: radial-gradient(circle at 35% 30%, #8dff8d, #2fa84a); box-shadow: 0 0 0 3px rgba(91, 227, 91, .2); }
.tabs a { text-transform: uppercase; letter-spacing: .09em; font-size: .72rem; font-weight: 700; color: var(--muted); }
.tabs a[aria-current="page"] { color: var(--text); background: transparent; box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.tabs a:hover { background: var(--surface2); }
.icon-btn { border-radius: 99px; border: 0; color: var(--accent); background: transparent; }
.icon-btn:hover { background: var(--surface2); color: var(--accent); }
#refresh svg { width: 22px; height: 22px; }
.rule { height: 6px; margin: 10px 4px 0; border-top: 1px solid rgba(255, 255, 255, .2); border-bottom: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .05); }
main { max-width: none; padding: 14px 0 0; }

.card, .tile { background: var(--surface); border: 1px solid var(--card-border); border-radius: 14px; box-shadow: none; }
:root[data-theme="light"] .card, :root[data-theme="light"] .tile { box-shadow: var(--shadow); }
.card.welcome { background: var(--welcome); border-color: var(--card-border-soft); }
.tile .label, th, label.field { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; }
th { text-transform: none; letter-spacing: 0; font-size: .78rem; }
h2 { font-weight: 600; font-size: .95rem; }
button, .btn, input, select, textarea { background: rgba(0, 0, 0, .28); border-color: var(--line); color: var(--text); }
:root[data-theme="light"] button, :root[data-theme="light"] .btn, :root[data-theme="light"] input, :root[data-theme="light"] select, :root[data-theme="light"] textarea { background: #fff; }
button:hover, .btn:hover { background: var(--surface2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
select option { background: var(--solid); color: var(--text); }
pre { background: rgba(0, 0, 0, .35); }
.badge, button.badge { background: rgba(0, 0, 0, .3); }
button.badge:hover { background: var(--accent); }
.bar { background: rgba(255, 255, 255, .09); }
.notice { background: rgba(0, 0, 0, .3); }
.top .tabs a:focus-visible, .top button:focus-visible { outline-offset: 0; }

/* overview layout: greeting + KPIs on top, live and daily charts below, like the template */
.dash { display: grid; gap: 12px; grid-template-columns: minmax(0, 553fr) minmax(0, 643fr); align-items: stretch; }
.dash > * { min-width: 0; }
.welcome h1 { font-size: 1.15rem; font-weight: 600; margin: 0; }
.welcome .lede { color: var(--muted); font-weight: 300; margin: 2px 0 14px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px 18px; }
.feature { display: grid; grid-template-columns: 28px 1fr; gap: 2px 8px; align-items: start; }
.feature svg { color: var(--accent); margin-top: 2px; }
.feature .f-label { font-size: .78rem; font-weight: 600; }
.feature .f-value { grid-column: 2; font-size: 1.6rem; font-weight: 700; line-height: 1.15; }
.feature .f-value small { font-size: .85rem; color: var(--muted); font-weight: 600; margin-left: 2px; }
.feature .f-sub { grid-column: 2; font-size: .78rem; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpis .tile { min-height: 0; }
@media (max-width: 980px) { .dash { grid-template-columns: 1fr; } }
@media (max-width: 640px) { body { padding: 8px; } .shell { padding: 8px 8px 12px; border-radius: 18px; } .top { top: 4px; } }
