/* v0.2: navigation, generic diagram, admin editor, control panel, market */
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; border: 1px solid transparent; white-space: nowrap; }
.nav a:hover { color: var(--text); }
.nav a.on { color: var(--text); background: var(--panel2); border-color: var(--line2); }
.pill.mode { color: var(--modetext); border-color: rgba(244, 148, 21, .45); background: rgba(244, 148, 21, .1); }
.blk .card { fill: var(--card); stroke: var(--line2); stroke-width: 1.2; }
.blk.bad .card { stroke: var(--alarm); }
.blk.stale .card { stroke: var(--warn); }
.blk.dim .card { stroke: var(--none); stroke-dasharray: 4 4; fill: transparent; }
.blk .t { fill: var(--muted); font-size: 12px; }
.blk .v { fill: var(--text); font-size: 17px; font-weight: 600; }
.blk .s { fill: var(--muted); font-size: 11px; }
.blk.dim .t, .blk.dim .s, .blk.dim .v { fill: var(--dim); }
.sld-busrect { fill: var(--bus); }
.sld-busrect.dim { fill: var(--none); }
.ico path { fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.ico { opacity: .8; }
.i-grid path, .i-meter path { stroke: var(--grid); } .i-pv path, .i-inverter path { stroke: var(--pv); }
.i-bess path { stroke: var(--bess); } .i-load path { stroke: var(--load); } .i-generator path { stroke: var(--ok); }
.socbox { fill: var(--well); stroke: var(--line2); }
.flow.gen { stroke: var(--ok); }

.btn { font: inherit; font-size: 13px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--btnhover); }
.btn.primary { background: var(--bess); border-color: var(--bess); color: #1d1d1f; }
.btn.danger { background: #b3202f; border-color: #d23443; color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.modal { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal .box { background: var(--panel2); border: 1px solid var(--line2); border-radius: 14px; padding: 18px 20px; width: min(520px, 100%); box-shadow: 0 20px 60px var(--shadow); }
.modal h3 { margin: 0 0 10px; font-size: 17px; }
.modal .mbody { color: var(--text2); font-size: 14px; }
.modal .mbody table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.modal .mbody td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.modal .mbtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; padding: 12px 16px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line2); max-width: 440px; box-shadow: 0 10px 30px var(--shadow); }
.toast.ok { border-color: rgba(47, 210, 126, .6); } .toast.err { border-color: rgba(255, 77, 94, .7); }
.banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; border: 1px solid; }
.banner.demo { color: var(--bannerdemo); border-color: rgba(255, 176, 32, .4); background: rgba(255, 176, 32, .07); }
.banner.info { color: var(--bannerinfo); border-color: rgba(79, 157, 255, .35); background: rgba(79, 157, 255, .07); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line2); position: sticky; top: 0; background: var(--panel); }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tbl .r { text-align: right; }
.scroll { max-height: 420px; overflow: auto; }
.field { display: grid; gap: 4px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea { font: inherit; font-size: 13px; color: var(--text); background: var(--well); border: 1px solid var(--line2); border-radius: 7px; padding: 6px 8px; width: 100%; }
.field.check { grid-template-columns: auto 1fr; align-items: center; }
.field.check input { width: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.res-ok { color: var(--ok); } .res-bad { color: var(--alarm); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; }
.tag.charge { color: var(--ok); border-color: rgba(47, 210, 126, .45); }
.tag.discharge { color: var(--bess-ink, var(--bess)); border-color: rgba(244, 148, 21, .5); }

/* admin editor */
.editor { display: grid; grid-template-columns: 170px minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.editor > * { min-width: 0; }
.palette button { display: flex; align-items: center; gap: 8px; width: 100%; margin-bottom: 6px; text-align: left; }
.palette svg { width: 16px; height: 16px; flex: none; }
.palette .hint { margin: 10px 0 0; font-size: 12px; line-height: 1.5; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar .sep { width: 1px; height: 24px; background: var(--line2); }
.toolbar .status { margin-left: auto; color: var(--muted); font-size: 12px; }
.toolbar .status.dirty { color: var(--warn); }
#canvas { width: 100%; height: auto; display: block; background: var(--canvas); border-radius: 10px; border: 1px solid var(--line); touch-action: none; user-select: none; }
#canvas .blk { cursor: grab; }
#canvas .blk.sel .card, #canvas .blk.sel .sld-busrect, #canvas .blk.sel .xf { stroke: var(--hi); stroke-width: 2; }
#canvas .blk.sel > rect:first-child { stroke: var(--hi); stroke-dasharray: 3 3; }
#canvas .blk.src .card, #canvas .blk.src > rect:first-child { stroke: var(--ok); stroke-width: 2.5; }
#canvas .lnk .hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
#canvas .lnk .sld-wire, #canvas .lnk .flow { pointer-events: none; }
#canvas .lnk.sel .sld-wire { stroke: var(--hi); stroke-width: 3; }
#canvas.connecting, #canvas.connecting .blk { cursor: crosshair; }
#canvas .rz { fill: var(--hi); stroke: var(--canvas); cursor: nwse-resize; }
.props h4 { margin: 0 0 10px; font-size: 13px; color: var(--h2); }
.props .empty { color: var(--muted); font-size: 13px; line-height: 1.5; }
.errs { color: var(--alarm); font-size: 12px; margin: 6px 0 0; padding-left: 16px; }
.versions { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; }
.versions li { font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.versions li span { color: var(--muted); }
.versions li button { margin-left: auto; }

/* control */
.ctlgrid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 14px; align-items: start; }
.ctlgrid > * { min-width: 0; }
.ctlgrid .scroll { overflow-x: auto; }
.modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.modebtn { text-align: left; background: var(--card); border: 1px solid var(--line2); border-radius: 12px; padding: 12px; color: var(--text); cursor: pointer; font: inherit; min-height: 96px; }
.modebtn b { display: block; font-size: 14px; margin-bottom: 4px; }
.modebtn span { color: var(--muted); font-size: 12px; }
.modebtn.on { border-color: var(--bess); background: rgba(244, 148, 21, .1); box-shadow: inset 0 0 0 1px var(--bess); }
.estop { width: 100%; padding: 16px; font-size: 16px; font-weight: 600; border-radius: 12px; background: var(--estop); border: 2px solid var(--alarm); color: #fff; cursor: pointer; letter-spacing: .3px; }
.secstate { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.big { font-size: 26px; font-weight: 600; }
.bigsub { color: var(--muted); font-size: 13px; }
.stack > * + * { margin-top: 14px; }

/* market */
.mkpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.mgrid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); gap: 14px; margin-bottom: 14px; align-items: start; }
.mgrid > * { min-width: 0; }
#mchart { width: 100%; height: 320px; display: block; }
.reco { font-size: 15px; line-height: 1.7; }
.reco b { color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--text); }

@media (max-width: 1280px) {
  .editor { grid-template-columns: 150px minmax(0, 1fr); } .editor .props { grid-column: 1 / -1; }
  .ctlgrid { grid-template-columns: 1fr; }
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mkpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .mgrid { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; } .nav { order: 5; width: 100%; margin-left: 0; overflow-x: auto; }
}
@media (max-width: 760px) {
  .editor { grid-template-columns: 1fr; } .palette { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .palette button { margin: 0; } .palette .hint { grid-column: 1 / -1; }
  .modes { grid-template-columns: 1fr 1fr; } .mkpis { grid-template-columns: 1fr 1fr; } .secstate { grid-template-columns: 1fr; }
  .mkpis .kpi .val { font-size: 20px; white-space: normal; } #mchart { height: 260px; }
  .pills .pill.ok { display: none; } .row2 { grid-template-columns: 1fr; }
}

/* ---- Light theme v2 (02.11.2026): Columbus band ----
   Solid #f49415 band with a rounded bottom carries the header and the first row of cards;
   everything else sits on a cool light sheet. Montserrat (columbusenergy.com.ua font) for headings and numbers.
   No gradients, no darker orange. Dark theme untouched. */
html:not([data-theme="dark"]) {
  --bg: #f3f5f8; --line: #e8ecf1; --line2: #d5dce5; --text: #1d2433; --muted: #667085; --dim: #7a8496;
  --well: #f1f4f7; --zero: #c9d0da; --gridpat: #edf0f4;
  --display: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --card-shadow: 0 1px 2px rgba(29, 36, 51, .05), 0 8px 24px rgba(29, 36, 51, .06);
  --band: 196px;
}
html:not([data-theme="dark"]) body { position: relative; background: var(--bg); }
html:not([data-theme="dark"]) .wrap { position: relative; z-index: 1; }

/* header on the band */
html:not([data-theme="dark"]) .top { background: #f49415; border-bottom: 0; backdrop-filter: none; color: #fff; }
html:not([data-theme="dark"]) .brand b { font-family: var(--display); font-weight: 700; font-size: 18px; }
html:not([data-theme="dark"]) .brand small, html:not([data-theme="dark"]) .clock small { color: rgba(255, 255, 255, .85); }
html:not([data-theme="dark"]) .clock b { font-family: var(--display); font-weight: 700; }
html:not([data-theme="dark"]) .logo { background: #fff; color: #f49415; border-radius: 50%; }
html:not([data-theme="dark"]) .nav { margin-left: 18px; }
html:not([data-theme="dark"]) .nav a { color: rgba(255, 255, 255, .85); border: 0; border-radius: 0; padding: 8px 2px; margin: 0 10px; border-bottom: 2px solid transparent; }
html:not([data-theme="dark"]) .nav a:hover { color: #fff; }
html:not([data-theme="dark"]) .nav a.on { background: none; color: #fff; font-weight: 600; border-bottom-color: #fff; }
html:not([data-theme="dark"]) .pill { border: 0; background: rgba(255, 255, 255, .2); color: #fff; }
html:not([data-theme="dark"]) .pill.ok, html:not([data-theme="dark"]) .pill.demo, html:not([data-theme="dark"]) .pill.mode { background: rgba(255, 255, 255, .2); color: #fff; }
html:not([data-theme="dark"]) .themebtn, html:not([data-theme="dark"]) .alarmcount { background: rgba(255, 255, 255, .2); border: 0; color: #fff; }
html:not([data-theme="dark"]) .alarmcount.on { background: #fff; color: var(--alarm); }
html:not([data-theme="dark"]) .link { box-shadow: 0 0 0 2px #fff; }

/* cards */
html:not([data-theme="dark"]) .phead { margin-bottom: 14px; }
html:not([data-theme="dark"]) .phead h2 { font-family: var(--display); text-transform: none; letter-spacing: 0; font-size: 17px; font-weight: 700; color: var(--text); }
html:not([data-theme="dark"]) .hint { color: var(--dim); }
html:not([data-theme="dark"]) .kpi::before { display: none; }
html:not([data-theme="dark"]) .kpi .lbl { color: var(--muted); font-size: 13px; gap: 8px; }
html:not([data-theme="dark"]) .kpi .val { font-family: var(--display); font-weight: 700; font-size: 28px; letter-spacing: -.4px; margin: 10px 0 4px; }
html:not([data-theme="dark"]) .kpi .val small { font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: 0; }
html:not([data-theme="dark"]) .bar { border: 0; background: var(--well); height: 8px; border-radius: 999px; }
html:not([data-theme="dark"]) .bar i { border-radius: 999px; }
html:not([data-theme="dark"]) .chip, html:not([data-theme="dark"]) .tag { border: 0; background: var(--well); }
html:not([data-theme="dark"]) .chip.demo { background: #fff4e5; }
html:not([data-theme="dark"]) .chip.discharge, html:not([data-theme="dark"]) .tag.discharge { background: #fff0e6; }
html:not([data-theme="dark"]) .chip.charge, html:not([data-theme="dark"]) .tag.charge { background: #e8f6ef; }

/* pill filters */
html:not([data-theme="dark"]) .tabs { gap: 6px; }
html:not([data-theme="dark"]) .tabs button, html:not([data-theme="dark"]) .seg button { border: 1px solid var(--line2); border-radius: 999px; padding: 5px 14px; background: #fff; color: var(--text); }
html:not([data-theme="dark"]) .tabs button.on, html:not([data-theme="dark"]) .seg button.on { border: 2px solid var(--text); padding: 4px 13px; background: #fff; color: var(--text); font-weight: 600; }
html:not([data-theme="dark"]) .seg { border: 0; gap: 6px; overflow: visible; background: none; }

/* lists */
html:not([data-theme="dark"]) .events li, html:not([data-theme="dark"]) .equip li { border-bottom: 1px solid var(--line); padding: 9px 2px; }
html:not([data-theme="dark"]) .equip li:last-child, html:not([data-theme="dark"]) .events li:last-child { border-bottom: 0; }

/* diagram */
html:not([data-theme="dark"]) .sld-wire { stroke: #b4bdca; stroke-width: 2; }
html:not([data-theme="dark"]) .sld-bus, html:not([data-theme="dark"]) .sld-busrect { stroke: #1d2433; }
html:not([data-theme="dark"]) .sld-busrect { fill: #1d2433; }
html:not([data-theme="dark"]) .node rect, html:not([data-theme="dark"]) .blk .card { fill: #fff; stroke: var(--line2); stroke-width: 1; rx: 10; }
html:not([data-theme="dark"]) .node .v, html:not([data-theme="dark"]) .blk .v, html:not([data-theme="dark"]) .lbl.big { font-family: var(--display); font-weight: 700; }

/* charts: dark tooltip, faint grid */
html:not([data-theme="dark"]) .gridline { stroke: #edf0f4; }
html:not([data-theme="dark"]) .tip { background: #1d2433; color: #fff; border: 0; border-radius: 10px; box-shadow: 0 10px 30px rgba(29, 36, 51, .25); }

/* buttons: brand rule, white non-bold text on orange */
html:not([data-theme="dark"]) .btn { border-radius: 999px; background: #fff; border-color: var(--line2); }
html:not([data-theme="dark"]) .btn.primary { background: #f49415; border-color: #f49415; color: #1d1d1f; font-weight: 400; }
html:not([data-theme="dark"]) .modebtn { border-radius: 16px; border-color: var(--line2); background: #fff; }
html:not([data-theme="dark"]) .modebtn.on { background: #fff4ec; }
html:not([data-theme="dark"]) .tbl th { background: #fff; }

@media (max-width: 1280px) { html:not([data-theme="dark"]) { --band: 236px; } }
@media (max-width: 760px) {
  html:not([data-theme="dark"]) { --band: 300px; }
  html:not([data-theme="dark"]) .kpi .val { font-size: 22px; }
  html:not([data-theme="dark"]) .panel { border-radius: 16px; padding: 14px; }
}
html:not([data-theme="dark"]) .wrap > .toolbar .tag { background: rgba(255, 255, 255, .2); color: #fff; }
html:not([data-theme="dark"]) .wrap > .toolbar .status { color: rgba(255, 255, 255, .9); }
html:not([data-theme="dark"]) .wrap > .toolbar .seg button { border-color: transparent; }

/* v2.1 (owner: header too orange): white header, soft orange tint band; solid orange only in accents */
html:not([data-theme="dark"]) .top { background: #fff; color: var(--text); box-shadow: 0 1px 0 var(--line); }
html:not([data-theme="dark"]) .brand small, html:not([data-theme="dark"]) .clock small { color: var(--muted); }
html:not([data-theme="dark"]) .logo { background: #f49415; color: #fff; }
html:not([data-theme="dark"]) .nav a { color: var(--muted); }
html:not([data-theme="dark"]) .nav a:hover { color: var(--text); }
html:not([data-theme="dark"]) .nav a.on { color: var(--text); border-bottom-color: #f49415; }
html:not([data-theme="dark"]) .pill, html:not([data-theme="dark"]) .pill.ok, html:not([data-theme="dark"]) .pill.demo, html:not([data-theme="dark"]) .pill.mode { background: var(--well); color: var(--text); }
html:not([data-theme="dark"]) .pill.ok { background: #e8f6ef; color: var(--ok); }
html:not([data-theme="dark"]) .pill.mode { background: #fff1e6; color: var(--text); }
html:not([data-theme="dark"]) .themebtn, html:not([data-theme="dark"]) .alarmcount { background: var(--well); color: var(--text); }
html:not([data-theme="dark"]) .alarmcount.on { background: #fde8ea; color: var(--alarm); }
html:not([data-theme="dark"]) .link { box-shadow: none; }
html:not([data-theme="dark"]) .wrap > .toolbar .tag { background: #fff; color: var(--muted); }
html:not([data-theme="dark"]) .wrap > .toolbar .status { color: var(--muted); }

/* v2.2 (owner: remove the tint band) */
