:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #17212b;
  --muted: #5f6b77;
  --border: #e1e6eb;
  --accent: #0f8a5f;
  --accent-soft: #e3f4ec;
  --cost: #d97706;
  --solar: #2f7fd8;
  --danger: #c0392b;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #182029;
    --text: #e6edf3;
    --muted: #93a1ae;
    --border: #2a3541;
    --accent: #34c38f;
    --accent-soft: #15352a;
    --cost: #f0a03c;
    --solar: #5aa2f0;
    --danger: #ef6b5b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.top { background: var(--surface); border-bottom: 1px solid var(--border); padding: 18px 0 12px; margin-bottom: 20px; }
.brand { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.logo { font-size: 26px; }
.tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 99px; }
.sub { margin: 4px 0 0; color: var(--muted); }
h2 { font-size: 17px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 10px; }
.between { justify-content: space-between; gap: 10px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 16px; cursor: pointer;
  margin-bottom: 14px; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { font-size: 32px; }
.cam-modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.cam-box { background: var(--card); border-radius: 12px; padding: 12px; max-width: 720px; width: 100%; }
.cam-box video { width: 100%; max-height: 70vh; border-radius: 8px; background: #000; display: block; }
.photo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 12px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { height: 90px; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:hover { filter: brightness(1.08); }
.status { min-height: 1.5em; margin: 10px 0 0; color: var(--muted); }
.status.error { color: var(--danger); }

.badge { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge.medie { background: #fff3d6; color: #8a5a00; }
.badge.scăzută { background: #fde2df; color: var(--danger); }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 12px 0; }
.grid-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.grid-form input { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.grid-form .full { grid-column: 1 / -1; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
pre { white-space: pre-wrap; font-size: 12px; max-height: 240px; overflow: auto; background: var(--bg); padding: 10px; border-radius: 8px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.kpi .k-label { font-size: 13px; color: var(--muted); }
.kpi .k-value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.kpi .k-value small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi .k-foot { font-size: 12px; color: var(--muted); }
.up { color: var(--danger); }
.down { color: var(--accent); }
.kpi.highlight { border-color: var(--accent); background: var(--accent-soft); }

.chart-box { position: relative; height: 300px; }
.note { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.note-box { font-size: 13px; background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }
.credit { color: var(--accent); }

.recs { display: grid; gap: 10px; margin-bottom: 10px; }
.rec { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: start; border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.rec-icon { font-size: 24px; line-height: 1; }
.rec h3 { margin: 0 0 4px; font-size: 15px; }
.rec p { margin: 0; }
.rec .saving { text-align: right; font-weight: 700; color: var(--accent); white-space: nowrap; }
.rec .saving small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.rec details { margin-top: 6px; }
.rec details p { font-size: 13px; color: var(--muted); margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.del:hover { color: var(--danger); }
.empty { text-align: center; color: var(--muted); }
footer { padding: 10px 16px 30px; }

@media (max-width: 560px) {
  .rec { grid-template-columns: 30px 1fr; }
  .rec .saving { grid-column: 2; text-align: left; }
  .chart-box { height: 240px; }
}

/* ---------- solar ---------- */
.section-title { font-size: 19px; margin: 26px 0 12px; }
.section-title:first-child { margin-top: 4px; }
.settings summary { cursor: pointer; list-style: none; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.settings summary::before { content: '⚙️'; }
.settings-body { margin-top: 14px; }
.lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.inp, .grid-form select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.grow { flex: 1; min-width: 160px; }
.place-results { list-style: none; padding: 0; margin: 8px 0; }
.place-results li { padding: 3px 0; }
.link { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-align: left; }
.link:hover { text-decoration: underline; }
.error { color: var(--danger); }
.live-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 8px; }
.live-tile { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.live-tile span { font-size: 13px; color: var(--muted); }
.live-tile strong { font-size: 22px; }
.live-tile small { font-size: 12px; color: var(--muted); }
.fdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.fday { border: 1px solid var(--border); border-radius: 12px; padding: 10px 4px; text-align: center; }
.fday.today { border-color: var(--solar); }
.fday-name { font-size: 13px; font-weight: 600; text-transform: capitalize; }
.fday-icon { font-size: 22px; margin: 4px 0; }
.fday-kwh { font-weight: 700; font-size: 17px; }
.fday-kwh small { font-weight: 500; font-size: 11px; color: var(--muted); }
.fday-meta { font-size: 11px; color: var(--muted); }
.small-chart { height: 200px; }
code { font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 640px) {
  .fdays { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- gaz ---------- */
#review-form.gas .el-only, #review-form:not(.gas) .gas-only { display: none; }
.gas-list { margin-top: 10px; }
.heat-costs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.heat-cost { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.heat-cost span { font-size: 13px; color: var(--muted); display: block; }
.heat-cost strong { font-size: 20px; }
.heat-cost small { display: block; font-size: 12px; color: var(--muted); }
.heat-cost.best { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- cele 3 părți (acordeon) ---------- */
.parts-hint { margin: 0 0 10px; }
.part { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.part[open] { border-color: var(--accent); background: transparent; border-style: solid; }
.part-head {
  list-style: none; cursor: pointer; padding: 16px 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-radius: var(--radius); background: var(--surface); user-select: none;
}
.part-head::-webkit-details-marker { display: none; }
.part-head::after { content: '▾'; margin-left: auto; color: var(--muted); transition: transform .2s; }
.part[open] > .part-head::after { transform: rotate(180deg); }
.part[open] > .part-head { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 1px solid var(--border); }
.part-title { font-size: 18px; font-weight: 700; }
.part-sum { font-size: 13px; color: var(--muted); }
.part-head:hover .part-title { color: var(--accent); }
.part-body { padding: 14px 12px 2px; }
.part-body > .card:last-child, .part-body > section:last-child { margin-bottom: 12px; }
.settings.inner { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
@media (max-width: 560px) {
  .part-body { padding: 10px 6px 2px; }
  .part-head { padding: 14px; }
  .part-sum { width: 100%; order: 3; }
}

/* ---------- file Curent / Gaz ---------- */
.combined { margin: 4px 2px 12px; font-size: 14px; }
.combined:empty { display: none; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tab {
  font: inherit; font-weight: 600; background: none; border: none; border-bottom: 3px solid transparent;
  padding: 10px 16px; cursor: pointer; color: var(--muted); margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count { font-size: 12px; font-weight: 500; background: var(--bg); border-radius: 99px; padding: 1px 8px; margin-left: 4px; }
.tab-count:empty { display: none; }

/* ---------- fără panouri solare ---------- */
#solar-form.no-pv .pv-only, body.no-pv .pv-card { display: none !important; }
.fday-temp { font-weight: 700; font-size: 15px; }

/* ---------- v0.3: baterie, autoconsum, raport, verificare, backup ---------- */
.sub-h { font-size: 15px; margin: 18px 0 8px; }
.wrap-row { flex-wrap: wrap; }
.cal-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.cal-box p { margin: 6px 0 0; }
.bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: var(--accent); }
.report-lines { margin: 12px 0 4px; padding-left: 20px; }
.report-lines li { margin: 4px 0; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list > li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.check-list ul { list-style: none; padding: 0; margin: 4px 0 0; }
td.chk { text-align: center; cursor: help; }
#report-month { max-width: 200px; }
footer .backup-row { margin-bottom: 8px; }
.file-btn { cursor: pointer; display: inline-block; }

/* ---------- conectare invertor ---------- */
.connect > summary { cursor: pointer; list-style: none; }
.connect > summary::-webkit-details-marker { display: none; }
.connect > summary h2 { margin: 0; }
.connect[open] > summary { margin-bottom: 8px; }
.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin: 12px 0; }
.method { text-align: left; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.method strong { display: block; }
.method small { color: var(--muted); }
.method[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.method .rec-tag { font-size: 11px; color: var(--accent); font-weight: 700; }
#connect-form .help { font-weight: 400; color: var(--muted); font-size: 12px; }
#connect-form select, #connect-form input { width: 100%; }
.test-ok { border-left: 3px solid var(--accent); padding: 6px 10px; margin-top: 10px; }
.test-err { border-left: 3px solid var(--danger); padding: 6px 10px; margin-top: 10px; color: var(--danger); }

/* aparatele utilizatorului */
.app-form { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.app-form .sub-h { margin-top: 0; }
.app-form select, .app-preset select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.app-preset { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; max-width: 360px; }
.app-grid label small { font-weight: 400; }
.app-form .err { color: var(--danger); min-height: 1em; margin: 0 0 8px; }
.app-actions { white-space: nowrap; text-align: right; }
.app-actions button { background: none; border: 0; cursor: pointer; font-size: 15px; padding: 2px 6px; border-radius: 6px; color: var(--muted); }
.app-actions button:hover, .app-actions button:focus-visible { background: var(--accent-soft); color: var(--text); }
td small.muted { display: block; font-size: 12px; }

/* consumatorii de gaz */
.stack-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--border); margin: 10px 0; }
.stack-bar span { display: block; height: 100%; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.check-row { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; font-weight: 500; margin: 6px 0; }
.grid-form .check-row { align-self: end; padding-bottom: 8px; }
[data-f][hidden] { display: none !important; }
.hint { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
#gas-breakdown td:first-child, #gas-consumers td:not(.app-actions) { white-space: normal; }
@media (max-width: 480px) { #gas-breakdown th, #gas-breakdown td { padding: 8px 6px; } }
#gasuse-card th { white-space: normal; }
@media (max-width: 480px) { #gasuse-card th, #gasuse-card td { padding: 8px 6px; } }
@media (max-width: 480px) { #gas-consumers td:nth-child(3), table:has(#gas-consumers) th:nth-child(3) { display: none; } }
.field-help ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.field-help li { margin: 4px 0; }
.field-help li strong { color: var(--text); font-weight: 600; }

/* comparator furnizori */
.steps { padding-left: 20px; margin: 8px 0 12px; }
.steps li { margin: 4px 0; }
.usage-list { padding-left: 18px; margin: 4px 0 8px; }
.usage-list li { margin: 3px 0; }
.credit-total { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 8px; }
.credit-big { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.credit-bar { display: inline-block; height: 8px; border-radius: 4px; background: var(--accent); opacity: .35; margin-right: 6px; vertical-align: middle; }
.credit-table td, .credit-table th { white-space: nowrap; }
.offers-table td { white-space: normal; vertical-align: top; }
.offers-table td small { display: block; font-size: 12px; }
.offers-table .current-row td { background: var(--accent-soft); }
.offers-table .warn-row td { font-size: 12px; color: var(--muted); border-top: 0; padding-top: 0; }
.offers-table .up { color: var(--danger); font-weight: 600; }
#of-form label select { margin-top: 4px; }

/* simulatorul „Ce-ar fi dacă”: bifele din blocurile opționale */
.grid-form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; margin: 8px 0; }
.grid-form label.check input { width: 18px; height: 18px; padding: 0; }
.sim-parts { margin: 0 0 12px; padding-left: 18px; font-size: 14px; }
