@font-face { font-family: "Caveat"; src: url("fonts/caveat-400.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
/* ---- 1.16: design tokens. Colours, type scale and spacing live here; the rules below use only these.
   The energy colours (--e-*) are shared with the charts: charts.js reads them with getComputedStyle. ---- */
:root {
  /* surfaces */
  --bg: #f4f5f2; --panel: #ffffff; --panel-2: #f9faf8; --panel-3: #f1f4f2; --neutral: #eef0ed;
  --line: #e1e4e0; --line-strong: #cdd2cc; --line-hover: #b5bcb4;
  /* text */
  --ink: #1d2327; --ink-2: #3c464d; --muted: #5f6a73; --on-brand: #ffffff; --on-brand-2: #c9d6db;
  /* brand and actions */
  --brand: #18343f; --brand-hover: #0f2730; --brand-tint: #e7eef1;
  --accent: #e8a317; --accent-hover: #d39410; --accent-ink: #2d2000; --accent-tint: #fff9ec;
  --link: #1f6f8b;
  /* states */
  --ok: #2f7d4f; --ok-bg: #e5f3ea; --ok-line: #c4e3cf; --ok-dot: #35a066;
  --err: #b4372d; --err-bg: #fbe9e7; --err-line: #f2c7c2; --err-line-hover: #e39d95; --err-dot: #c9483d;
  --warn: #7a5200; --warn-bg: #fff4dc; --warn-line: #f1dca8; --warn-bar: #e2b54a;
  --info: #1f5468; --info-bg: #eef5f8;
  /* energy – the same colours in the charts, legends, the schedule bar and "Централата днес" */
  --e-solar: #f2b01e; --e-solar-line: #d99a0f;
  --e-load: #1f6f8b;                     /* consumption */
  --e-grid: #4a7fd0;                     /* bought from the grid */
  --e-sell: #16a39a;                     /* sold to the grid */
  --e-battery: #2f9e5f; --e-battery-out: #1f7a46;   /* battery level / charged, discharged */
  --e-charge: #e8a317; --e-hold: #5b8fb0; --e-use: #b9c2bf;   /* what a charging plan does in an hour */
  --e-common: #b9c2c7; --e-nodata: #e8eae6; --e-price: #18343f;
  --tl-use: #d3ecd9; --tl-keep: #d2e3ee; --tl-charge: #f6d58c;   /* schedule bar (lighter, text on top) */
  /* type scale */
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-2xs: 11px; --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-base: 15px; --fs-lg: 17px; --fs-xl: 20px;
  --fs-2xl: 24px; --fs-kpi: 26px; --fs-hero: 34px; --fs-hero-lg: 38px; --fs-hero-xl: 46px;
  /* spacing (4 px grid), radii, shadows */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius: 10px; --radius-sm: 7px; --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(16, 32, 40, .05); --shadow-2: 0 6px 20px rgba(16, 32, 40, .10);
  --focus: 0 0 0 3px rgba(31, 111, 139, .35); --focus-line: #9cc6d4; --focus-border: #6aa8bd;
  --accent-line: #f0cf86; --accent-strong: #8a5a00; --row-hover: #fbfcfa; --err-tint: #fffafa; --info-line: #d3e4ea;
  --ok-on-dark: #8fdcae; --err-on-dark: #ffb4a8; --slogan: #8a979c;
  --tap: 36px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: var(--fs-base)/1.5 var(--font);
  background: var(--bg); color: var(--ink);
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: var(--fs-2xl); line-height: 1.25; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: var(--fs-lg); line-height: 1.3; margin: 0 0 12px; }
h3 { font-size: var(--fs-base); margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
code, .mono { font-family: var(--mono); font-size: var(--fs-sm); }

/* top bar */
.topbar { background: var(--brand); color: var(--on-brand); }
.topbar .inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 9px; color: var(--on-brand); text-decoration: none; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; flex: none; }
.logo-mark svg { width: 64%; height: 64%; }
.logo-mark.lg { width: 58px; height: 58px; border-radius: 15px; }
.logo-word { font-family: Poppins, "Segoe UI Semibold", system-ui, var(--font); font-weight: 600; font-size: 21px; letter-spacing: -0.02em; line-height: 1; }
.logo-word.lg { font-size: var(--fs-hero-xl); color: var(--brand); }
.brand-lockup { display: flex; align-items: center; gap: 15px; margin: 4px 0 18px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.dn { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; font-weight: 400; }
.setup-title { font-size: var(--fs-xl); margin: 0 0 6px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--on-brand-2); text-decoration: none; padding: 7px 11px; border-radius: var(--radius-sm); font-size: var(--fs-md); font-weight: 500; white-space: nowrap; }
.nav a:hover { color: var(--on-brand); background: rgba(255,255,255,0.08); }
.nav a.active { color: var(--on-brand); background: rgba(255,255,255,0.14); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar form { margin: 0; }
.topbar .who { color: var(--on-brand-2); font-size: var(--fs-sm); display: flex; gap: 10px; align-items: center; }
.linkbtn { background: none; border: 0; color: var(--link); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }
.topbar .linkbtn { color: var(--on-brand-2); }
.topbar .linkbtn:hover { color: var(--on-brand); }

main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: var(--s4); box-shadow: var(--shadow-1); }
.panel.tight { padding: 0; overflow: hidden; }
.grid { display: grid; gap: var(--s4); }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.kpi .value { font-size: var(--fs-kpi); font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi .value small { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi .sub { font-size: var(--fs-sm); line-height: 1.4; color: var(--muted); }
.kpi .value.sm { font-size: var(--fs-lg); line-height: 1.3; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
td { font-variant-numeric: tabular-nums; }
th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600;
  background: var(--panel-2); border-bottom-color: var(--line-strong); }
th .unit { text-transform: none; letter-spacing: 0; font-weight: 500; }
tr:last-child > td { border-bottom: 0; }
tr.total td { font-weight: 700; background: var(--panel-2); border-top: 2px solid var(--line-strong); }
tr.group td { background: var(--panel-3); font-weight: 600; }
.panel.tight table tr:not(.group):not(.total):hover > td { background: var(--row-hover); }
.panel.tight th:first-child, .panel.tight td:first-child { padding-left: var(--s4); }
.panel.tight th:last-child, .panel.tight td:last-child { padding-right: var(--s4); }
td.ind, .panel.tight td.ind { padding-left: 30px; } td.ind2, .panel.tight td.ind2 { padding-left: 50px; }
th.grp { text-align: center; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
th.sepl, td.sepl { border-left: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: var(--s3); border: 1px solid transparent; border-left-width: 4px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); border-left-color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); border-color: var(--err-line); border-left-color: var(--err); }
.note { background: var(--warn-bg); border: 1px solid var(--warn-line); border-left: 4px solid var(--warn-bar); color: var(--warn);
  border-radius: 8px; padding: 10px 14px; font-size: var(--fs-md); }
.note.info { background: var(--info-bg); border-color: var(--info-line); border-left-color: var(--link); color: var(--info); }
.mb-4 { margin-bottom: var(--s4); } .mb-3 { margin-bottom: var(--s3); } .mt-0 { margin-top: 0; }

label { display: block; font-size: var(--fs-sm); font-weight: 600; margin: 0 0 4px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], select {
  width: 100%; min-height: var(--tap); padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit;
  background: var(--panel); color: var(--ink);
}
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled) { border-color: var(--line-hover); }
input:focus, select:focus { outline: none; border-color: var(--focus-border); box-shadow: var(--focus); }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 180px; margin-bottom: 0; }
.help { font-size: var(--fs-sm); line-height: 1.45; color: var(--muted); margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 7px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); font: inherit;
  font-size: var(--fs-md); font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--panel-3); border-color: var(--line-hover); }
.btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-hover); font-weight: 650; }
.btn.accent:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--link); }
.btn.ghost:hover { background: var(--info-bg); border-color: transparent; }
.btn.danger { background: var(--panel); color: var(--err); border-color: var(--err-line); }
.btn.danger:hover { background: var(--err-bg); border-color: var(--err-line-hover); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: var(--fs-sm); }
.btn.lg { min-height: 44px; padding: 10px 18px; font-size: var(--fs-base); }
.btn[disabled], .btn:disabled, .btn[aria-disabled=true] { opacity: .55; cursor: not-allowed; }
.btn[disabled]:hover, .btn:disabled:hover { background: var(--panel); border-color: var(--line-strong); }
/* Q5: a visible focus for the keyboard only */
.btn:focus-visible, .linkbtn:focus-visible, .seg button:focus-visible, .tabs a:focus-visible, .nav a:focus-visible,
.lang-switch:focus-visible, summary:focus-visible, .plant-tabs button:focus-visible, .cov a:focus-visible {
  outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
.nav a:focus-visible { box-shadow: 0 0 0 3px rgba(255, 255, 255, .5); }

.badge { display: inline-block; font-size: var(--fs-xs); font-weight: 600; line-height: 18px; padding: 1px 8px; border-radius: var(--radius-pill);
  background: var(--neutral); color: var(--ink-2); white-space: nowrap; vertical-align: 1px; }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.on { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: var(--err-bg); color: var(--err); }
.badge.est { background: var(--warn-bg); color: var(--warn); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); margin-right: 6px; }
.dot.on { background: var(--ok-dot); } .dot.off { background: var(--err-dot); }

.device { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow-1); }
.device-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.device-head .title { font-weight: 650; }
.ch-row { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(180px, 1.2fr) minmax(220px, 1.4fr); gap: 10px; align-items: center; padding: 9px 16px; border-bottom: 1px solid var(--line); }
.ch-row:last-child { border-bottom: 0; }
.ch-row.tracked { background: var(--accent-tint); }
.ch-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.ch-head { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--panel); }
.sticky-save { position: sticky; bottom: 0; background: rgba(244,245,242,0.95); padding: 12px 0; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; backdrop-filter: blur(4px); box-shadow: 0 -4px 14px rgba(16, 32, 40, .06); }

.daynav { display: flex; gap: 6px; align-items: center; }
.daynav input[type=date] { width: auto; }
.daynav .btn.small { min-width: var(--tap); min-height: var(--tap); padding: 0 8px; font-size: var(--fs-lg); line-height: 1; }
.daynav .btn.small.today { font-size: var(--fs-sm); padding: 0 12px; }
.chart-box { position: relative; min-height: 290px; }
.chart-tip { position: absolute; display: none; pointer-events: none; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; font-size: var(--fs-sm); box-shadow: var(--shadow-2); white-space: nowrap; z-index: 5; font-variant-numeric: tabular-nums; }

.cov { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.cov a { display: block; text-decoration: none; border-radius: 6px; padding: 6px; font-size: var(--fs-xs); text-align: center; border: 1px solid var(--line); color: var(--ink); background: var(--panel); }
.cov a.full { background: var(--ok-bg); border-color: var(--ok-line); }
.cov a.part { background: var(--warn-bg); border-color: var(--warn-line); }
.cov a.none { background: var(--panel-3); color: var(--muted); }

.auth { max-width: 420px; margin: 8vh auto; }
.steps { margin: 0; padding-left: 20px; } .steps li { margin-bottom: 6px; }
details summary { cursor: pointer; font-weight: 600; }

#bands td { padding: 6px 8px; }
#bands input[type=time] { width: 120px; }
#bands input[name=band_price] { width: 130px; text-align: right; }
#bands select { width: 150px; }
#bands .timepick select { width: auto; }

.building { border-left: 4px solid var(--brand); }
.building-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.obj-list { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.obj { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(200px, 1.6fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.obj:last-child { border-bottom: 0; }
.obj.main-row { background: var(--panel-2); }
.obj .obj-form { grid-column: 1 / -1; }
.chip { display: inline-block; font-size: var(--fs-sm); padding: 3px 9px; border-radius: 999px; background: var(--info-bg); color: var(--info); margin: 2px 4px 2px 0; }
.chip.off { background: var(--panel-3); color: var(--muted); text-decoration: line-through; }
.c-tenant select { width: 100%; }

.section-title { margin-bottom: 10px; }
.page-h2 { font-size: var(--fs-xl); margin: 0 0 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 18px; overflow-x: auto; overflow-y: hidden; padding-bottom: 1px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs { flex-wrap: nowrap; max-width: 100%; -webkit-overflow-scrolling: touch; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: var(--fs-md); font-weight: 500; flex: none; }
.tabs .sep { flex: 0 0 1px; align-self: stretch; background: var(--line-strong); margin: 9px 6px; }
.tabs a .ext { font-size: var(--fs-xs); color: var(--muted); margin-left: 3px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.steps-done { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.steps-done li { display: flex; gap: 10px; align-items: flex-start; }
.steps-done .mark { flex: 0 0 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 700; background: var(--neutral); color: var(--muted); }
.steps-done li.done .mark { background: var(--ok-bg); color: var(--ok); }
.steps-done li.done .txt { color: var(--muted); text-decoration: line-through; }
.steps-done li.next .mark { background: var(--accent); color: var(--accent-ink); }
.attach { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.attach select { width: auto; max-width: 260px; padding: 5px 8px; font-size: var(--fs-sm); }
.chip form { display: inline; margin: 0; }
.chip .x { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 0 0 4px; font-size: var(--fs-sm); opacity: .6; }
.chip .x:hover { opacity: 1; color: var(--err); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-sm); margin: 6px 0 4px; color: var(--ink-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-legend .sw.ln { height: 3px; width: 14px; border-radius: 2px; }
.chart-legend i { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 0; vertical-align: -1px; }
.chart-legend i.line { height: 3px; vertical-align: 2px; }
/* Q8: a one-line legend that only repeats the card's name above it */
.obj-chart .chart-legend, #easyChart .chart-legend { display: none; }
.chart-box svg text { font-family: inherit; }
/* energy swatches for legends written in the templates */
.sw-solar { background: var(--e-solar); } .sw-load { background: var(--e-load); } .sw-battery { background: var(--e-battery); }
.sw-charge { background: var(--e-charge); } .sw-hold { background: var(--e-hold); } .sw-use { background: var(--e-use); }
.sw-grid { background: var(--e-grid); } .sw-sell { background: var(--e-sell); }
.sw-night { background: rgba(31, 111, 139, .12); } .sw-gridcharge { background: rgba(232, 163, 23, .35); }
.sw-tl-use { background: var(--tl-use); } .sw-tl-keep { background: var(--tl-keep); } .sw-tl-charge { background: var(--tl-charge); }
.c-charge { color: var(--e-charge); } .c-hold { color: var(--e-hold); } .c-use { color: var(--e-use); }
.more-meter summary { list-style: none; cursor: pointer; font-size: var(--fs-sm); color: var(--link); }
.more-meter summary::-webkit-details-marker { display: none; }
.more-meter[open] summary { display: none; }

.choice { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; font-size: var(--fs-base); margin: 0 14px 0 0; }
.choice input { accent-color: var(--brand); width: 17px; height: 17px; }
.timepick { display: inline-flex; gap: 2px; align-items: center; }
.timepick select { width: auto; padding: 6px 4px; }
.src { font-size: var(--fs-sm); }
.src.err { color: var(--err); }

.slogan { margin: -2px 0 14px; font-family: Caveat, "Segoe Print", "Bradley Hand", cursive; font-weight: 400; font-size: 21px; line-height: 1.1; color: var(--slogan); letter-spacing: 0.01em; }

/* shared helpers */
.nowrap { white-space: nowrap; }
.err-text { color: var(--err); }
.intro { margin: -6px 0 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.section-sub { font-size: var(--fs-lg); margin: 22px 0 10px; }
.show-sm { display: none; }
.c-check { width: 1%; text-align: center; }
.c-check input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; vertical-align: middle; margin: 0; }
.radio-row { align-items: center; }
.radio-row .choice { margin: 0; }
.radio-row > span { flex-basis: 100%; }

/* inverters */
.inv-body { padding: 14px 16px; }
.inv-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inv-card .title { color: var(--ink); text-decoration: none; font-size: var(--fs-lg); }
.inv-card .title:hover { text-decoration: underline; }
.inv-card .kpi { background: var(--panel-2); border-color: var(--line); }
.inv-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px 16px; flex-wrap: wrap; margin-top: 12px; }
.empty p { margin-top: 0; }
.panel.empty { text-align: center; padding: 32px 18px; }
.panel.empty p { max-width: 540px; margin: 0 auto 14px; color: var(--ink-2); }
.panel.empty h2 { margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 16px; }
.kv > div { display: flex; flex-direction: column; }
.kv span { font-size: var(--fs-sm); color: var(--muted); }
.kv strong { font-variant-numeric: tabular-nums; }
.inv-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.inv-section h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
details.inv-section[open] > summary { margin-bottom: 12px; }
.inv-note { margin: 14px 0 0; }
table.tou td { padding: 6px 10px; }
table.tou input[type=time] { width: 120px; }
table.tou input.w-power { width: 110px; }
table.tou input.w-soc { width: 80px; }
table.tou input:disabled { background: var(--panel-3); color: var(--muted); }
.tou-diff tr.changed td { background: var(--warn-bg); }
.inv-pick tr.group td { background: var(--panel-3); }
.inv-pick th.c-check { white-space: nowrap; }
.inv-pick tr.picked td { background: var(--accent-tint); }
.st-row { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; }
.st-row .btn { margin-left: auto; font-weight: 400; }
.st-row .small { font-weight: 400; }
.inv-label { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 500; font-size: var(--fs-base); margin: 0; cursor: pointer; }
.inv-label .dot { margin-right: 0; }
.pick-wrap .sticky-save { margin: -4px 0 18px; padding: 12px 2px; }
.sticky-save.dirty { background: rgba(255,244,220,0.97); border-top-color: var(--warn-line); }
.sticky-save.dirty #pick-state { color: var(--warn); font-weight: 600; }
.acc-del { padding: 10px 16px; border-top: 1px solid var(--line); }
.acc-del summary { font-weight: 500; color: var(--muted); }
.acc-del[open] form { margin-top: 10px; }
.add-acc > summary { font-size: var(--fs-lg); }
.add-acc[open] > summary { margin-bottom: 16px; }

@media (max-width: 820px) {
  .tabs { gap: 0; margin-left: -2px; margin-right: -2px; }
  .tabs a { padding: 9px 10px; font-size: var(--fs-sm); }
  .kpi .value.sm { font-size: var(--fs-base); }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  .inv-body { padding: 12px; }
  .kv { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  table.tou th { padding: 8px 3px; font-size: var(--fs-xs); letter-spacing: 0; text-transform: none; }
  table.tou td { padding: 6px 3px; }
  table.tou input { padding: 6px 5px; }
  table.tou input[type=time] { width: 88px; }
  table.tou input.w-power { width: 66px; }
  table.tou input.w-soc { width: 52px; }
  .inv-pick th, .inv-pick td { padding: 8px 10px; }
  .inv-pick th.c-check { white-space: normal; }
  #bands tr:first-child { display: none; }
  #bands tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  #bands td { display: block; padding: 0; border: 0; }
  #bands td[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-xs); color: var(--muted); margin-bottom: 2px; }
  #bands td.num { align-self: end; }
  .ch-row { grid-template-columns: 1fr; gap: 6px; }
  .ch-row .c-counter { display: none; }
  .topbar .inner { gap: 6px 12px; padding-top: 8px; }
  .nav { order: 3; flex: 1 0 100%; padding-bottom: 6px; }
  .nav a { flex: 0 0 auto; padding: 6px 4px; font-size: var(--fs-sm); }
  .topbar .who { margin-left: auto; }
  main { padding-top: 16px; }
  .ch-head { display: none; }
  .kpi .value { font-size: var(--fs-xl); }
  .grid.k4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 10px 12px; }
  .kpi .label { font-size: var(--fs-2xs); }
  #bands input[name=band_price], #bands td > select { width: 100%; }
  .obj { grid-template-columns: 1fr; }
}
.brand-lockup .slogan { margin: 3px 0 0 2px; }

/* night charging overview */
.charge-steps li { margin-bottom: 6px; }
.charge-chart { height: 220px; }
.eval-good { color: var(--ok); } .eval-bad { color: var(--err); }

.app-foot { text-align: center; font-size: var(--fs-xs); color: var(--muted); padding: 18px 0 26px; }
.app-foot a { color: inherit; }

/* dashboard views */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; padding: 2px; gap: 2px; background: var(--panel-3); }
.seg button, .seg a { border: 0; background: none; padding: 6px 14px; border-radius: var(--radius-sm); font: inherit; font-size: var(--fs-sm);
  font-weight: 500; cursor: pointer; color: var(--ink-2); text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; }
.seg button.on, .seg a.on { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-1); }
.seg button:not(.on):hover, .seg a:not(.on):hover { background: var(--panel); }
.seg a:focus-visible { outline: none; box-shadow: var(--focus); }
.easy-hero { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.easy-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-1); }
.easy-card.big { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.easy-card.big .label, .easy-card.big .sub, .easy-card.big .value small { color: var(--on-brand-2); }
.easy-card.big .eval-good { color: var(--ok-on-dark); } .easy-card.big .eval-bad { color: var(--err-on-dark); }
.easy-card .label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.easy-card .value { font-size: var(--fs-hero); font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.easy-card.big .value { font-size: var(--fs-hero-xl); }
.easy-card .value small { font-size: var(--fs-lg); font-weight: 500; color: var(--muted); }
.easy-card .sub { font-size: var(--fs-md); color: var(--muted); margin-top: 4px; }
.easy-tip { background: var(--warn-bg); border: 1px solid var(--warn-line); border-left: 4px solid var(--warn-bar); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: var(--fs-base); }
@media (max-width: 720px) {
  .easy-hero { grid-template-columns: 1fr 1fr; gap: 10px; }
  .easy-hero .easy-card.big { grid-column: 1 / -1; }
  .easy-card { padding: 14px 16px; }
  .easy-card .value { font-size: var(--fs-kpi); }
  .easy-card.big .value { font-size: var(--fs-hero-lg); }
  .seg button, .seg a { padding: 6px 10px; }
}

/* login / registration: many small, faint Phase logos scattered in different directions */
body.auth-page { position: relative; min-height: 100vh; overflow-x: hidden; }
body.auth-page::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: url("auth-bg.svg") repeat; background-size: 720px 720px; opacity: .09;
}
@media (max-width: 720px) { body.auth-page::before { background-size: 460px 460px; } }
body.auth-page main, body.auth-page .app-foot { position: relative; z-index: 1; }
body.auth-page .auth { background: rgba(255, 255, 255, .92); backdrop-filter: blur(2px); }

.apply-box{display:flex;gap:14px;align-items:center;justify-content:space-between;flex-wrap:wrap;
  border:1px solid var(--accent);border-radius:10px;padding:12px 14px;margin:6px 0 12px;
  background:color-mix(in srgb, var(--accent) 7%, transparent)}
.apply-box form{margin:0}

/* --- 1.9: timeline bars (inverter schedule), decision box, plan settings --- */
.tl { position: relative; height: 34px; border-radius: 8px; overflow: hidden; display: flex; background: var(--neutral); border: 1px solid var(--line); }
.tl .tl-seg { height: 100%; display: flex; align-items: center; justify-content: center; font-size: var(--fs-xs); white-space: nowrap;
  overflow: hidden; border: 0; border-right: 1px solid rgba(255,255,255,.7); border-radius: 0; background: transparent;
  color: var(--ink); min-width: 0; }
.tl .tl-seg:last-child { border-right: 0; }
.tl .tl-seg.use { background: var(--tl-use); }
.tl .tl-seg.keep { background: var(--tl-keep); }
.tl .tl-seg.charge { background: var(--tl-charge); }
.tl-row { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: center; margin: 6px 0; }
.tl-row .lbl { font-size: var(--fs-sm); color: var(--muted); }
.tl-axis { display: flex; justify-content: space-between; font-size: var(--fs-2xs); color: var(--muted); margin: 2px 0 0 80px; }
.tl-key { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-sm); color: var(--ink-2); margin-top: 6px; }
.tl-key i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
.decision { border: 1px solid var(--accent); border-radius: 12px; padding: 14px 16px; margin: 4px 0 14px;
  background: color-mix(in srgb, var(--accent) 7%, transparent); display: flex; gap: 14px; flex-wrap: wrap;
  align-items: center; justify-content: space-between; }
.decision { border-color: var(--accent-line); background: var(--accent-tint); box-shadow: var(--shadow-1); padding: 16px 18px; }
.decision > div:first-child { flex: 1 1 280px; min-width: 0; }
.decision .big { font-size: var(--fs-lg); font-weight: 600; line-height: 1.35; }
.decision .big strong { color: var(--accent-strong); }
.decision .acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: center; max-width: 320px; }
.decision .acts .small { color: var(--muted); }
.decision .meta { font-size: var(--fs-sm); color: var(--muted); margin-top: 4px; }
.decision form { margin: 0; }
.plan-settings { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 14px 0 6px; }
.plan-settings .field { margin: 0; }
.plan-settings .hint { flex-basis: 100%; font-size: var(--fs-sm); color: var(--muted); margin: 0; }
.plan-settings { gap: 12px 20px; }
.plan-settings .grow { flex: 1 1 0; }
.plan-settings .acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
/* M5: a unit inside the field ("20 | %") */
.input-suffix { display: flex; align-items: stretch; width: 120px; max-width: 100%; }
.input-suffix.w-lg { width: 150px; }
.input-suffix input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); text-align: right; min-width: 0; flex: 1 1 auto; width: auto; }
.input-suffix > span { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--panel-2); color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
/* M4: "Какво ще стане" as a time line with the same colours as the bar and the chart */
ol.timeline-steps { list-style: none; margin: 0 0 6px; padding: 0; display: grid; }
.timeline-steps li { display: grid; grid-template-columns: 112px 14px minmax(0, 1fr); gap: 10px; align-items: start; padding: 7px 0;
  border-bottom: 1px dashed var(--line); margin: 0; }
.timeline-steps li:last-child { border-bottom: 0; }
.timeline-steps .t { font-weight: 600; font-variant-numeric: tabular-nums; font-size: var(--fs-md); white-space: nowrap; }
.timeline-steps .m { width: 12px; height: 12px; border-radius: 3px; margin-top: 5px; background: var(--neutral); }
.timeline-steps .m.charge { background: var(--e-charge); } .timeline-steps .m.hold, .timeline-steps .m.night { background: var(--e-hold); }
.timeline-steps .m.use, .timeline-steps .m.day { background: var(--e-battery); } .timeline-steps .m.sum { background: var(--brand); border-radius: 50%; }
.timeline-steps .d { font-size: var(--fs-md); color: var(--ink-2); min-width: 0; }
.timeline-steps li.sum .d { color: var(--ink); }
@media (max-width: 520px) {
  .timeline-steps li { grid-template-columns: 14px minmax(0, 1fr); gap: 2px 10px; }
  .timeline-steps .t { grid-column: 2; } .timeline-steps .m { grid-row: 1; grid-column: 1; } .timeline-steps .d { grid-column: 2; }
}
.time-pick { display: flex; gap: 2px; align-items: center; }
.time-pick select { width: auto; padding: 5px 4px; }
.match { font-size: var(--fs-sm); font-weight: 600; padding: 2px 8px; border-radius: var(--radius-pill); }
.match.ok { background: var(--ok-bg); color: var(--ok); }
.match.diff { background: var(--warn-bg); color: var(--warn); }
details.more { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
details.more > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-md); padding: 4px 0; }
.lang-switch { font-size: var(--fs-sm); text-decoration: none; border: 1px solid rgba(255,255,255,.35); border-radius: 6px;
  padding: 3px 8px; color: inherit; margin-right: 10px; white-space: nowrap; }
.lang-switch:hover { background: rgba(255,255,255,.12); }
.lang-switch { font-weight: 600; }
@media (max-width: 640px) { .tl-row { grid-template-columns: 1fr; gap: 2px; } .tl-axis { margin-left: 0; } .tl .tl-seg { font-size: var(--fs-2xs); } }
.lang-switch.floating { position: absolute; top: 14px; right: 16px; z-index: 5; color: var(--ink); border-color: var(--line);
  background: var(--panel); margin: 0; font-weight: 600; }
.lang-switch.floating:hover { background: var(--panel-3); }
.chart-tip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* показания по обекти */
.obj-group{margin:14px 0 8px;font-size: var(--fs-base);overflow-wrap:anywhere}
.obj-group .badge{white-space:normal;display:inline-block;max-width:100%;vertical-align:middle}
.obj-head .dot{flex:0 0 auto}
.obj-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,300px),1fr));gap:12px}
.obj-card{border:1px solid var(--line);border-radius:var(--radius);padding:10px 12px;background:var(--panel);min-width:0;overflow:hidden}
.obj-card > *{min-width:0}
.obj-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1 1 auto}
.obj-tariff{font-size: var(--fs-xs);color:var(--muted);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.obj-chart svg{max-width:100%}
.obj-card.common{background:var(--bg)}
.obj-head{display:flex;align-items:center;gap:6px;flex-wrap:nowrap;min-width:0}
.obj-now{margin-left:auto;font-weight:600;white-space:nowrap;flex:0 0 auto}
.obj-nums{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:8px 0 4px}
.obj-nums .label{font-size: var(--fs-xs);color:var(--muted)}
.obj-nums .v{font-size: var(--fs-xl);font-weight:600;white-space:nowrap}
.obj-nums > div{min-width:0}
.obj-nums .sub{font-size: var(--fs-sm)}
.obj-chart{min-height:0}

/* --- 1.13: first-run wizard and the trial / subscription bar --- */
.wiz { max-width: 640px; margin: 0 auto; }
.wiz-steps { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; counter-reset: wiz; }
.wiz-steps li { counter-increment: wiz; font-size: var(--fs-sm); padding: 4px 10px; border-radius: 999px; background: var(--neutral); color: var(--muted); }
.wiz-steps li::before { content: counter(wiz) ". "; }
.wiz-steps li.on { background: var(--brand); color: #fff; }
.wiz-choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 10px; cursor: pointer; background: var(--panel); }
.wiz-choice:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(24, 52, 63, .12); }
.wiz-choice input { margin-top: 4px; width: 18px; height: 18px; flex: 0 0 auto; }
.wiz-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.wiz-actions .btn { min-height: 44px; }
.wiz-skip { margin-top: 10px; }
.wiz-station { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.wiz-station .choice { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.trial-bar { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: var(--fs-md); }
.trial-bar.soft { background: var(--panel-3); border-color: var(--line); color: var(--muted); }
.trial-bar.off { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.trial-bar a { font-weight: 600; }
/* --- 1.14: tenants --- */
.tenant-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.tenant-row summary { cursor: pointer; }
.tenant-row[open] summary { margin-bottom: 8px; }
.tenant-objs { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; max-height: 260px; overflow: auto; }
.tenant-objs .choice { display: flex; gap: 8px; align-items: center; }

/* --- 1.15: the plant today (dashboard) – live energy flows --- */
.plant-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 6px; }
.plant-head h2 { margin: 0; }
.plant-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.plant-tabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: var(--fs-sm); cursor: pointer; color: var(--muted); }
.plant-tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.plant-upd { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.plant-body { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 18px; align-items: center; margin-bottom: 10px; }
@media (max-width: 760px) { .plant-body { grid-template-columns: 1fr; } }
.plant-flow svg { width: 100%; height: auto; display: block; }
.pf-track { fill: none; stroke: var(--line); stroke-width: 6; stroke-linecap: round; }
.pf-dash { fill: none; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 14; animation: pf-move linear infinite; }
@keyframes pf-move { to { stroke-dashoffset: -32; } }
.pf-hub rect { fill: var(--brand); }
.pf-node circle:first-child { filter: drop-shadow(0 2px 4px rgba(24, 52, 63, .12)); }
.pf-lbl { font-size: var(--fs-xs); fill: var(--muted); text-anchor: middle; }
.pf-val { font-size: var(--fs-md); font-weight: 700; text-anchor: middle; }
.pf-sub { font-size: var(--fs-2xs); fill: var(--muted); text-anchor: middle; }
.pf-soc { transition: y .8s, height .8s; }
.pf-stale .pf-node, .pf-stale .pf-hub { opacity: .55; }
.pf-note { font-size: var(--fs-sm); color: var(--muted); text-align: center; margin-top: 4px; }
.plant-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .plant-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pt { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--panel); min-width: 0; }
.pt-top { font-size: var(--fs-sm); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.pt-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pt-val { font-size: 21px; font-weight: 700; color: var(--brand); margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.pt-val small { font-size: var(--fs-xs); font-weight: 500; color: var(--muted); }
.pt-bar { height: 5px; background: var(--neutral); border-radius: 3px; overflow: hidden; }
.pt-bar i { display: block; height: 100%; border-radius: 3px; transition: width .8s ease; }
.pt-sub { font-size: var(--fs-2xs); color: var(--muted); margin-top: 3px; }
@media (prefers-reduced-motion: reduce) { .pf-dash { animation: none; stroke-dasharray: none; opacity: .6; } }

/* --- 1.15.2: phones – no side scrolling. Wide tables become "card rows": each row is a small card with
   label: value pairs (td[data-label]); .m-full cells take the whole card width, .m-hide cells are dropped.
   table.compact keeps a real table but squeezes padding and headers so it fits 360 px. --- */
select, input, textarea { max-width: 100%; }
.row > .field { min-width: 0; }
@media (max-width: 820px) {
  .table-wrap:has(> table.mcards) { overflow: visible; }
  table.mcards, table.mcards > tbody { display: block; width: 100%; }
  table.mcards tr:has(> th) { display: none; }
  table.mcards tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 10px; padding: 9px 12px;
    border-bottom: 1px solid var(--line); }
  table.mcards.c2 tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.mcards.c1 tr { grid-template-columns: minmax(0, 1fr); }
  table.mcards tr:last-child { border-bottom: 0; }
  table.mcards td { display: block; padding: 0 !important; border: 0; text-align: left; min-width: 0; background: none;
    overflow-wrap: anywhere; }
  table.mcards td.num { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  table.mcards td[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-2xs); font-weight: 400;
    color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  table.mcards td.m-full, table.mcards td[colspan] { grid-column: 1 / -1; }
  table.mcards td.m-full.num { white-space: normal; }
  table.mcards td:empty, table.mcards td.m-hide { display: none; }
  table.mcards td .dn { display: block; }
  table.mcards tr.group { background: var(--panel-3); }
  table.mcards tr.total { background: var(--panel-2); }
  table.mcards tr.picked { background: var(--accent-tint); }
  table.mcards tr.sub { padding-left: 24px; }
  table.mcards .m-title { font-weight: 600; }
  table.mcards td form { display: inline-flex !important; flex-wrap: wrap; max-width: 100%; }
  table.compact th { padding: 7px 4px; font-size: var(--fs-2xs); letter-spacing: 0; text-transform: none; white-space: normal; }
  table.compact td { padding: 6px 4px; font-size: var(--fs-sm); }
  table.compact th:first-child, table.compact td:first-child { padding-left: 10px; }
  .inv-pick th { white-space: normal; }
  .inv-pick th, .inv-pick td { padding: 8px 6px; }
  .st-row { flex-wrap: nowrap; }
  .st-row > span { min-width: 0; }
  .btn { min-height: 40px; }
  table.tou .time-pick select { padding: 6px 2px; }
  table.tou input.w-power { width: 56px; }
  table.tou input.w-soc { width: 44px; }
}
.show-sm-b { display: none; }
@media (max-width: 820px) { .show-sm-b { display: block; } }
@media (max-width: 820px) {
  table.mcards.c4 tr { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  table.mcards td.m-title { grid-column: 1 / -1; font-weight: 600; }
  table.mcards.c4 td.m-title { grid-column: 1 / 4; }
  table.mcards td.m-right { text-align: right; }
  table.mcards td .dn { white-space: normal; }
}
@media (max-width: 820px) {
  table.mcards.tfull td.m-title { grid-column: 1 / -1; }
  table.mcards td.m-keep:empty { display: block; }
}
@media (max-width: 820px) {
  table.mcards td.m-actions { grid-column: 1 / -1; text-align: left; }
  table.mcards td.m-actions .row { justify-content: flex-start !important; gap: 8px; }
  table.mcards td.m-actions:has(.row:empty) { display: none; }
  table.users-t td > form { margin: 4px 0; }
}
@media (max-width: 820px) {
  table.mcards .badge { white-space: normal; max-width: 100%; }
  table.mcards td.m-title .badge { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
}
@media (max-width: 820px) {
  .topbar .who .linkbtn { padding: 10px 2px; }
}
@media (max-width: 820px) {
  button.linkbtn { min-height: 40px; }
  .topbar .who .linkbtn { min-height: 0; }
  .chip .x { padding: 6px 6px; margin: -6px -4px -6px 0; }
  table.tou td { padding: 6px 2px; }
}
/* users list (Settings → Потребители, a full-width tab since 1.16): a table on wide screens, cards on phones */
table.users-t td > form { margin: 2px 0; }
table.users-t td { overflow-wrap: anywhere; }
table.users-t td.m-title { width: 32%; }
/* plan history: a long Deye answer in the status badge wraps instead of widening the table */
.plan-log .badge { white-space: normal; }

/* --- 1.16: design system – components shared by all pages --- */
.tabs, .nav { position: relative; }
.form-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
/* M8: deleting is kept apart from saving – a red "опасна зона" */
.danger-zone { border: 1px solid var(--err-line); border-radius: var(--radius); background: var(--err-tint); padding: 14px 16px; margin-top: 16px; }
.danger-zone h3 { color: var(--err); font-size: var(--fs-md); margin: 0 0 6px; }
.danger-zone .help { margin: 0 0 10px; }
details.danger-zone > summary { color: var(--err); font-weight: 600; }
details.danger-zone[open] > summary { margin-bottom: 10px; }
.acc-del.acc-danger > summary { color: var(--err); }
.acc-del.acc-danger[open] { background: var(--err-tint); box-shadow: inset 3px 0 0 var(--err-line); }
.pill-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--fs-sm); color: var(--ink-2); margin: 8px 0 0; }
.pill-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; border: 1px solid var(--line); }
.page-head .seg { flex-wrap: wrap; }
.obj-name { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; line-height: 1.3; }
@media (max-width: 820px) {
  :root { --tap: 40px; }
  .btn.small { min-height: 40px; }
  main { padding-left: 12px; padding-right: 12px; }
  .panel { padding: 14px; }
  .panel.tight { padding: 0; }
  .panel.empty { padding: 24px 14px; }
  h1 { font-size: 21px; }
  /* Q9: the menu and the tabs stay on one line; they scroll inside themselves, never the page */
  .topbar .inner { padding-left: 10px; padding-right: 10px; }
  .nav { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; gap: 0; justify-content: space-between; min-width: 0; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 8px 5px; }
  .page-head { gap: 10px; }
  .daynav input[type=date] { flex: 1 1 auto; min-width: 0; }
  .kpi .label { font-size: var(--fs-xs); }
  .decision { padding: 12px; }
  .decision .acts { max-width: none; flex: 1 1 100%; }
  .decision .acts form, .decision .acts .btn { width: 100%; }
  .plan-settings .acts { margin-left: 0; width: 100%; }
  .plan-settings .acts .btn.primary { flex: 1 1 auto; }
  .sticky-save .btn { flex: 1; }
  /* Q10: a real table that scrolls inside its box keeps the first column in view */
  .panel.tight .table-wrap > table:not(.mcards) th:first-child, .panel.tight .table-wrap > table:not(.mcards) td:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
  .panel.tight .table-wrap > table:not(.mcards) th:first-child { background: var(--panel-2); }
  .auth .btn.primary { width: 100%; }
  .seg { max-width: 100%; }
}
@media (max-width: 380px) {
  .grid.k4 { gap: 8px; }
  .kpi { padding: 10px; }
}
@media (max-width: 820px) {
  /* the period switch in Отчети: three equal parts that may break onto two lines, never wider than the screen */
  nav.seg { display: flex; width: 100%; }
  nav.seg a { flex: 1 1 0; min-width: 0; white-space: normal; justify-content: center; text-align: center; line-height: 1.2; min-height: 40px; }
}

/* --- 1.17: the "Лесен" view (body.easy on the dashboard) – bigger text and tap targets, one question per card.
   Scoped to body.easy, so the tenant pages that share .easy-hero / .easy-card stay as they were. --- */
body.easy { font-size: var(--fs-lg); }
body.easy .small, body.easy .muted.small { font-size: var(--fs-base); }
body.easy .btn { min-height: 44px; font-size: var(--fs-base); }
body.easy .seg button { min-height: 40px; padding: 6px 16px; font-size: var(--fs-base); }
.easy-head .seg-wrap { display: flex; align-items: center; gap: var(--s2); margin: 0; }
.easy-head .seg-label { font-size: var(--fs-base); color: var(--muted); }
.easy-past { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; background: var(--info-bg); color: var(--info);
  border: 1px solid var(--info-line); border-radius: var(--radius); padding: 10px 16px; margin-bottom: var(--s4); }
.easy-past .btn { margin-left: auto; }
/* B2: does everything work */
.easy-status { display: flex; align-items: flex-start; gap: var(--s3); border-radius: var(--radius); padding: 10px 16px; margin-bottom: var(--s4);
  border: 1px solid var(--ok-line); background: var(--ok-bg); color: var(--ok); }
.easy-status .ico { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--ok); color: var(--on-brand); }
.easy-status p { margin: 2px 0; }
.easy-status .when { margin-left: auto; font-size: var(--fs-base); color: var(--ink-2); white-space: nowrap; padding-top: 2px; }
.easy-status.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.easy-status.warn .ico { background: var(--warn-bar); color: var(--accent-ink); }
.easy-status.warn > div { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
/* B8: the one-time intro */
.easy-intro { background: var(--accent-tint); border: 2px solid var(--accent-line); border-radius: var(--radius); padding: var(--s4) var(--s5); margin-bottom: var(--s4); }
.easy-intro h2 { margin: 0 0 var(--s2); }
.easy-intro ol { margin: 0 0 var(--s3); padding-left: 22px; }
.easy-intro li { margin-bottom: 6px; }
.easy-intro form { margin: 0; }
/* the money cards */
body.easy .easy-hero { grid-template-columns: 1.3fr 1fr 1fr; }
body.easy .easy-hero.two { grid-template-columns: 1.3fr 1fr; }
body.easy .easy-card h2.label { font-size: var(--fs-base); margin: 0 0 4px; }
body.easy .easy-card .sub { font-size: var(--fs-base); color: var(--ink-2); }
body.easy .easy-card.big .sub { color: var(--on-brand-2); }
body.easy .easy-card .value small { font-size: var(--fs-lg); }
body.easy .hint-unit { font-size: var(--fs-md); }
.easy-card .cmp strong { font-weight: 650; }
.easy-card.big .cmp.less strong { color: var(--ok-on-dark); } .easy-card.big .cmp.more strong { color: var(--err-on-dark); }
.easy-card .forecast { margin-top: var(--s3); padding-top: 10px; border-top: 1px solid var(--line); font-size: var(--fs-base); }
.easy-card .forecast strong { font-size: var(--fs-xl); white-space: nowrap; }
.easy-card .forecast.muted-2 { color: var(--muted); }
.pill { display: inline-block; border-radius: var(--radius-pill); padding: 2px 12px; font-weight: 600; background: var(--neutral); color: var(--ink-2); }
.pill.use-low { background: var(--ok-bg); color: var(--ok); } .pill.use-normal { background: var(--info-bg); color: var(--info); }
.pill.use-high { background: var(--warn-bg); color: var(--warn); }
/* the battery and "Тази нощ" (A1) */
.easy-two { display: grid; grid-template-columns: 1.15fr 1fr; gap: var(--s4); margin-bottom: var(--s4); align-items: start; }
.bat-list { list-style: none; margin: 0; padding: 0; }
.bat-list li { display: flex; align-items: center; gap: var(--s4); padding: 10px 0; border-bottom: 1px solid var(--line); min-height: 56px; }
.bat-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.bat-list li:first-child { padding-top: 4px; }
.bat-txt { min-width: 0; overflow-wrap: anywhere; }
.bat-name { font-weight: 650; }
.battery { position: relative; flex: none; width: 96px; height: 46px; border: 3px solid var(--ink-2); border-radius: 9px; background: var(--panel); margin-right: 8px; }
.battery::after { content: ""; position: absolute; right: -9px; top: 12px; width: 6px; height: 16px; background: var(--ink-2); border-radius: 0 3px 3px 0; }
.battery .fill { position: absolute; left: 3px; top: 3px; bottom: 3px; max-width: calc(100% - 6px); border-radius: 5px; background: var(--e-battery); opacity: .55; }
.battery b { position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--fs-lg); color: var(--ink); }
.easy-plan { border: 2px solid var(--accent); background: var(--accent-tint); }
.easy-plan .plan-one + .plan-one { border-top: 1px solid var(--accent-line); margin-top: var(--s3); padding-top: var(--s3); }
.easy-plan .plan-name { font-weight: 650; color: var(--ink-2); }
.easy-plan .say { font-size: var(--fs-lg); line-height: 1.45; margin: 4px 0 var(--s2); }
.easy-plan .plan-off { margin: var(--s3) 0 0; color: var(--ink-2); font-size: var(--fs-base); }
.easy-plan .sub { color: var(--ink-2); font-size: var(--fs-base); }
.easy-tl { display: flex; height: 36px; border-radius: 8px; overflow: hidden; font-size: var(--fs-sm); font-weight: 600; margin-top: var(--s2); }
.easy-tl span { display: grid; place-items: center; color: var(--ink); white-space: nowrap; overflow: hidden; border-right: 2px solid var(--panel); min-width: 0; }
.easy-tl .keep { background: var(--tl-keep); } .easy-tl .charge { background: var(--tl-charge); } .easy-tl .use { background: var(--tl-use); }
.easy-tl-axis { display: flex; justify-content: space-between; font-size: var(--fs-md); color: var(--muted); margin-top: 2px; }
.save { display: inline-block; margin-top: var(--s2); background: var(--ok-bg); color: var(--ok); border-radius: var(--radius-pill); padding: 4px 14px; font-weight: 600; font-size: var(--fs-base); }
.easy-more { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; margin-top: 4px; }
/* tip, chart, who */
body.easy .easy-tip { display: flex; gap: var(--s3); align-items: flex-start; font-size: var(--fs-lg); color: var(--ink); }
body.easy .easy-tip .ico { font-size: var(--fs-2xl); line-height: 1; }
.easy-key { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: var(--fs-base); color: var(--ink-2); margin-top: 6px; }
.easy-key i { display: inline-block; width: 14px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.easy-key .k-use { background: var(--e-load); } .easy-key .k-now { background: var(--accent); }
.easy-key .k-cheap { background: var(--ok-bg); border: 1px solid var(--ok-line); }
.chart-say { font-size: var(--fs-lg); margin: var(--s2) 0 0; }
.easy-chart #easyChart .chart-legend { display: none; }
.easy-who { margin-bottom: var(--s4); }
.who-list { list-style: none; margin: 0; padding: 0; }
.who-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 20px; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--line); min-height: 56px; }
.who-list li:last-child { border-bottom: 0; }
.who-list .n { font-weight: 600; overflow-wrap: anywhere; }
.who-list .common .n { font-weight: 500; color: var(--ink-2); }
.who-list .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.who-list .v small { display: block; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.who-list .bar { grid-column: 1 / -1; height: 8px; background: var(--neutral); border-radius: 4px; overflow: hidden; }
.who-list .bar span { display: block; height: 100%; background: var(--e-load); border-radius: 4px; }
.who-list .common .bar span { background: var(--e-common); }
/* the footer: VAT once, other days, the detailed view (A9) */
.easy-foot { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; justify-content: space-between; margin-top: var(--s4); color: var(--ink-2); font-size: var(--fs-base); }
.easy-foot-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.easy-foot-btns form { margin: 0; }
.easy-day { display: flex; align-items: center; gap: var(--s2); }
.easy-day label { margin: 0; font-size: var(--fs-base); font-weight: 500; color: var(--ink-2); }
.easy-day input[type=date] { width: auto; min-height: 44px; font-size: var(--fs-base); }
/* many plants: "Тази нощ" across the page, the batteries in a grid under it */
.easy-two.many { grid-template-columns: 1fr; }
.easy-two.many .bat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); column-gap: var(--s5); }
.easy-two.many .bat-list li, .easy-two.many .bat-list li:first-child { padding: 10px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) {
  .easy-two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  body.easy .easy-hero, body.easy .easy-hero.two { grid-template-columns: 1fr; gap: var(--s3); }
  body.easy .easy-card .value { font-size: var(--fs-hero); }
  body.easy .easy-card.big .value { font-size: var(--fs-hero-xl); }
  .easy-head .seg-wrap { width: 100%; }
  .easy-status .when { display: none; }
  .easy-intro { padding: var(--s4); }
  .easy-foot { flex-direction: column; align-items: stretch; }
  .easy-foot-btns { display: grid; grid-template-columns: 1fr 1fr; }
  .easy-foot-btns .btn, .easy-foot-btns form, .easy-foot-btns form .btn { width: 100%; }
  .easy-foot-btns form:last-child { grid-column: 1 / -1; }
  .easy-day { grid-column: 1 / -1; }
  .easy-day input[type=date] { flex: 1 1 auto; min-width: 0; }
  .who-list li { gap: 4px 12px; }
  .battery { width: 84px; height: 42px; }
  .battery::after { top: 10px; }
}

/* B1: the simple menu of the "Лесен" view – "Още" opens Обекти / Цени; phones get a bottom tab bar */
.nav-more { position: relative; }
.nav-more > summary { list-style: none; color: var(--on-brand-2); padding: 7px 11px; border-radius: var(--radius-sm); font-size: var(--fs-md); font-weight: 500; cursor: pointer; white-space: nowrap; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary::after { content: " ▾"; font-size: var(--fs-xs); }
.nav-more > summary:hover, .nav-more[open] > summary { color: var(--on-brand); background: rgba(255,255,255,0.08); }
.nav-more > summary.active { color: var(--on-brand); background: rgba(255,255,255,0.14); box-shadow: inset 0 -2px 0 var(--accent); }
.nav-more-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px; min-width: 160px; display: grid; }
.nav .nav-more-menu a { color: var(--ink); padding: 10px 12px; }
.nav .nav-more-menu a:hover, .nav .nav-more-menu a.active { background: var(--panel-3); color: var(--ink); box-shadow: none; }
body.easy-nav .nav a, body.easy-nav .nav-more > summary { font-size: var(--fs-base); padding: 9px 13px; }
.tabbar { display: none; }
@media (max-width: 720px) {
  body.easy-nav .topbar .nav { display: none; }
  body.easy-nav main { padding-bottom: 96px; }
  body.easy-nav .app-foot { padding-bottom: 86px; }
  body.easy-nav .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(16, 32, 40, .08); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a, .tabbar summary { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; list-style: none; }
  .tabbar summary::-webkit-details-marker { display: none; }
  .tabbar .i { font-size: var(--fs-2xl); line-height: 1; }
  .tabbar a.active, .tabbar summary.active { color: var(--brand); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
  .tabbar a:focus-visible, .tabbar summary:focus-visible { outline: none; box-shadow: var(--focus); }
  .tab-more { position: relative; }
  .tab-more-menu { position: absolute; bottom: calc(100% + 8px); right: 8px; min-width: 190px; display: grid; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px; }
  .tab-more-menu a { min-height: 48px; flex-direction: row; justify-content: flex-start; padding: 0 14px; font-size: var(--fs-base); color: var(--ink); }
}
/* B11: the station page in the "Лесен" view */
.st-sum { display: grid; grid-template-columns: 1fr 1.3fr; gap: var(--s4); margin-bottom: var(--s4); font-size: var(--fs-lg); }
.st-sum-top { display: flex; align-items: center; gap: var(--s4); min-width: 0; }
.st-sum-big { font-size: var(--fs-xl); }
.st-sum .sub { font-size: var(--fs-base); color: var(--ink-2); margin-top: 4px; }
.st-sum-plan { border-radius: var(--radius); padding: var(--s3) var(--s4); }
.st-sum-plan h2.label { font-size: var(--fs-base); margin: 0 0 4px; color: var(--muted); }
details.st-more > summary { font-size: var(--fs-base); min-height: 44px; display: flex; align-items: center; }
details.st-more[open] > summary { margin-bottom: var(--s3); }
@media (max-width: 820px) { .st-sum { grid-template-columns: 1fr; } }

/* --- 1.18: the public demo – the button on the sign-in page --- */
.demo-cta { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center; margin-top: var(--s4);
  padding-top: var(--s4); border-top: 1px solid var(--line); }
