@font-face { font-family: Barlow; font-weight: 400; font-display: swap; src: url(vendor/fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Barlow; font-weight: 500; font-display: swap; src: url(vendor/fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Barlow; font-weight: 600; font-display: swap; src: url(vendor/fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: Barlow; font-weight: 700; font-display: swap; src: url(vendor/fonts/barlow-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url(vendor/fonts/barlow-semi-condensed-latin-600-normal.woff2) format("woff2"); }

:root {
  --bg: #0d131b; --panel: #151c27; --card: #1b2431; --line: #283445;
  --text: #e6edf3; --muted: #8b98a9;
  --pv: #f5c542; --cons: #4ea8ff; --to: #3ddc84; --from: #ff9f43; --pool: #22d3ee; --pool-deep: #0e7490;
  --num: "Barlow Semi Condensed", Barlow, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Barlow, system-ui, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); -webkit-text-size-adjust: 100%; }
h2, h3 { margin: 0; font-weight: 600; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

button, .btn, select, input[type=date], input[type=text], input[type=password], input:not([type]) {
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 12px; min-height: 40px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
}
button:hover, .btn:hover { border-color: #3d4e66; }
:focus-visible { outline: 2px solid var(--pool); outline-offset: 2px; }
.primary { background: var(--pool-deep); border-color: var(--pool); color: #fff; font-weight: 600; }
.primary:hover { background: #0891b2; }
.ghost { background: transparent; }
.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }
input[type=date] { color-scheme: dark; }

/* ---------- Kopf ---------- */
.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 21px; letter-spacing: .01em; }
.brand svg { width: 22px; height: 22px; fill: var(--pool); }
.spacer { flex: 1; }
.brand-text { display: inline-flex; flex-direction: column; line-height: 1.05; }
.brand .tenant { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.tenant-name { font-size: 17px; font-weight: 600; color: var(--pool); margin: -6px 0 0 !important; }
.project-select { max-width: 260px; font-weight: 600; border-color: #36506b; }
.dlg-sub { margin: 2px 0 0; font-size: 14px; }
.dlg-small { width: min(460px, calc(100vw - 24px)); }
.dlg-small form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.field input, .field textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; width: 100%; resize: vertical; }
.error { color: #ff8a8a; margin: 0; font-size: 14px; }
.props li.current { border: 1px solid var(--pool); }
.role-read .write-only, body:not(.is-admin) .admin-only { display: none !important; }
#readNote { display: none; }
.no-project .proj-only, .no-project .write-only, .no-project #readNote { display: none !important; }
.role-read #readNote { display: block; }
.notice-inline { background: #ff9f431a; border: 1px solid #ff9f4366; border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 0 0 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.user-new { display: grid; gap: 10px; background: var(--card); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.user-new h3 { margin: 0; }
.users { display: grid; gap: 8px; }
.users details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.users summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; }
.users summary::-webkit-details-marker { display: none; }
.users summary b { flex: 1; }
.users summary small { color: var(--muted); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #0e749055; color: var(--pool); border: 1px solid #22d3ee55; }
.users .ubody { padding: 4px 12px 12px; display: grid; gap: 10px; border-top: 1px solid var(--line); }
.users .acc { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; font-size: 14px; }
.users .acc select { min-height: 34px; padding: 4px 8px; }
.users .saved { color: var(--to); font-size: 13px; }
.users .pwrow { display: flex; gap: 8px; flex-wrap: wrap; }
.users .pwrow input { flex: 1; min-width: 160px; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }
@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .example th, .example td { padding: 6px 5px; font-size: 12px; }
  .empty { padding: 20px 14px; }
  .empty h2 { font-size: 21px; }
}
.props .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.small-text { font-size: 14px; margin: 4px 0 8px; }
.export-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--pool); }
.btn.busy { opacity: .6; pointer-events: none; }
.logout svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); min-height: 34px; padding: 4px 14px; border-radius: 8px; font-weight: 600; }
.seg button[aria-pressed=true] { background: var(--pool-deep); color: #fff; }

.timebar { display: flex; align-items: center; gap: 12px; padding: 0 16px 12px; }
.timebar .nav, .timebar .play { display: flex; align-items: center; gap: 6px; }
.timebar .nav button { width: 40px; padding: 0; font-size: 20px; }
.timebar input[type=range] { flex: 1; accent-color: var(--pool); height: 28px; min-width: 120px; }
.time { font: 600 21px var(--num); color: var(--pool); min-width: 112px; text-align: center; }
#btnPlay[aria-pressed=true] { border-color: var(--pool); color: var(--pool); }
.timebar.off { opacity: .55; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(400px, 1fr); gap: 16px; padding: 0 16px 16px; }
.stage { position: sticky; top: 8px; align-self: start; }
#pool { display: block; width: 100%; height: calc(100vh - 160px); min-height: 560px; border-radius: 18px;
  touch-action: manipulation; cursor: default; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13px; padding: 8px 4px 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; }
.tip { position: absolute; pointer-events: none; background: var(--card); border: 1px solid var(--pool);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; min-width: 220px; z-index: 5; box-shadow: 0 8px 24px #0008; }
.tip b { display: block; margin-bottom: 4px; font-size: 14px; }
.tip div { display: flex; justify-content: space-between; gap: 16px; }
.tip span:last-child { font-family: var(--num); }

.empty { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px clamp(16px, 4vw, 40px);
  display: grid; gap: 14px; max-width: 860px; margin: 0 auto; }
.empty h2 { font-size: 24px; }
.empty > p { color: var(--muted); margin: 0; }
.empty .row { justify-content: flex-start; margin-top: 4px; }
/* Leeres Projekt: Anleitung statt leerer Grafik */
.is-empty .proj-only, .is-empty #pool, .is-empty .legend, .is-empty .side, .is-empty .timebar, .is-empty .seg, .is-empty #year { display: none !important; }
.is-empty .layout { grid-template-columns: 1fr; }
.is-empty .stage { position: static; }
.guide { display: grid; gap: 14px; }
.guide code { font: 600 13px var(--num); background: var(--card); padding: 1px 6px; border-radius: 5px; color: var(--text); }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.rules { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: #c7d0dc; font-size: 14px; }
.example table { background: var(--card); border-radius: 12px; overflow: hidden; max-width: 520px; }
.example caption { text-align: left; color: var(--muted); font-size: 13px; padding: 0 0 6px; }
.example th { background: #0e7490; color: #fff; position: static; }
.example td { color: var(--text); }
.example td:first-child { font-family: var(--num); font-weight: 400; }
.example th, .example td { white-space: nowrap; }
.example tr.gap td { color: var(--muted); text-align: center; }
.howto { background: var(--card); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--pool); }
.howto[open] summary { margin-bottom: 10px; }
.howto .example table { background: var(--panel); }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

.side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; min-width: 0; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { display: block; font: 600 23px/1.15 var(--num); color: var(--c); white-space: nowrap; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-head h2 { font-size: 19px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-radius: 0; background: transparent; color: var(--muted); border-bottom: 2px solid transparent; min-height: 38px; }
.tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--pool); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.panel h3 { font-size: 14px; color: var(--muted); font-weight: 500; }
.panel h3 small { font-size: 12px; opacity: .8; margin-left: 6px; }
.panel h3 + .chart { margin-bottom: 10px; }
.chart { min-width: 0; }

/* uPlot */
.uplot { font-family: Barlow, sans-serif; }
.u-legend { color: var(--muted); font-size: 12.5px; text-align: left; }
.u-legend .u-marker { border-radius: 3px; }
.u-legend th { font-weight: 500; }
.u-legend td { font-family: var(--num); color: var(--text); }
.u-select { background: rgba(34, 211, 238, .12); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid #222c3a; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
th:first-child, td:first-child { text-align: left; }
td { font-family: var(--num); }
td:first-child { font-family: Barlow, sans-serif; font-weight: 500; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #1a2231; }
tbody tr.sel { background: #0e749033; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }

/* Liste der Liegenschaften (nur Handy) */
.node-list { display: none; gap: 8px; }
.short { display: none; }
.node { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 12px;
  padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left; color: var(--text); width: 100%; }
.node.sel { border-color: var(--pool); box-shadow: 0 0 0 2px #22d3ee44; border-left-color: var(--c); }
.node .nm { font-weight: 600; }
.node .net { font: 600 17px var(--num); color: var(--c); text-align: right; }
.node .fl { color: var(--muted); font-size: 13px; }
.node .bars { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; align-items: center; margin-top: 4px; font: 13px var(--num); color: var(--muted); }
.node .b { height: 6px; background: #ffffff14; border-radius: 3px; overflow: hidden; }
.node .b i { display: block; height: 100%; border-radius: 3px; background: var(--bc); }

/* Dialog */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 18px; }
dialog::backdrop { background: #000a; backdrop-filter: blur(3px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.drop { display: grid; gap: 4px; text-align: center; border: 2px dashed var(--line); border-radius: 14px; padding: 22px 16px; cursor: pointer; }
.drop span { color: var(--muted); font-size: 14px; }
.drop.over { border-color: var(--pool); background: #22d3ee10; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.log, .props { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.log li { font-size: 14px; padding: 6px 10px; border-radius: 8px; background: var(--card); }
.log li.ok { border-left: 3px solid var(--to); }
.log li.err { border-left: 3px solid #ef5b5b; }
.props li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; background: var(--card); }
.props li span { flex: 1; min-width: 0; }
.props small { display: block; color: var(--muted); }
dialog h3 { margin-top: 16px; font-size: 16px; }

/* Login */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); display: grid; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px; }
.login label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.login input { width: 100%; justify-content: flex-start; cursor: text; }
.login .error { color: #ff8a8a; margin: 0; }
.login .notice { background: var(--card); border-radius: 10px; padding: 10px; font-size: 14px; margin: 0; }
.login p { margin: 0; }

/* ---------- Handy / Tablet ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .stage { position: relative; top: 0; }
  #pool { height: auto; aspect-ratio: 1 / 1.08; min-height: 0; }
  .node-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
@media (min-width: 961px) { .stage { position: sticky; } }
@media (max-width: 640px) {
  .bar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 19px; white-space: nowrap; }
  .brand-text { display: none !important; }
  .project-select { flex: 1; max-width: none; min-width: 0; }
  .long { display: none; } .short { display: inline; }
  .bar .btn, .bar button { padding: 6px 10px; }
  .node { padding: 8px 10px; }
  .bar .spacer { display: none; }
  .seg { order: 5; flex: 1; }
  #btnExcel { padding: 6px 10px; }
  .logout { order: 7; width: 40px; padding: 0 !important; }
  .seg button { flex: 1; }
  #year { order: 6; }
  .timebar { flex-wrap: wrap; padding: 0 12px 10px; gap: 8px; }
  .timebar .nav { flex: 1; }
  .timebar .nav input { flex: 1; min-width: 0; }
  .timebar input[type=range] { order: 3; flex-basis: 100%; }
  .timebar .play { order: 4; width: 100%; }
  .timebar .play #btnPlay { flex: 1; }
  .layout { padding: 0 8px 16px; gap: 12px; }
  #pool { border-radius: 14px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi b { font-size: 21px; }
  .panel { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Datenqualität ---------- */
.quality { background: #ef5b5b14; border: 1px solid #ef5b5b66; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.quality summary { cursor: pointer; font-weight: 600; color: #ffb3b3; }
.quality ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; color: #d5dbe3; }
.quality small { color: var(--muted); }
.kpi.warn b { color: #ff8a8a; }

/* ---------- Wirtschaftlichkeit ---------- */
.money-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.money-head h3 { color: var(--text); font-size: 16px; }
#moneyTable td.pos { color: var(--to); }
#moneyTable td.neg { color: var(--from); }
.models { display: grid; gap: 8px; }
.model { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-size: 14px; color: var(--muted); }
.model b { display: block; color: var(--text); font-size: 15px; }
.model input { margin-top: 4px; accent-color: var(--pool); width: 18px; height: 18px; }
.model:has(input:checked) { border-color: var(--pool); background: #0e749022; }
.prices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
#dlgSettings { width: min(860px, calc(100vw - 24px)); }
#dlgSettings form { display: grid; gap: 10px; }
#dlgSettings h3 { margin-top: 6px; }
.settings-table input { width: 84px; font: inherit; font-family: var(--num); color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; text-align: right; }
.settings-table input:disabled { opacity: .35; }
.settings-table td, .settings-table th { padding: 5px 6px; }
.audit-wrap { max-height: 65vh; overflow: auto; }
#auditTable td { font-family: Barlow, sans-serif; text-align: left; white-space: normal; vertical-align: top; font-size: 13.5px; }
#auditTable td:first-child { white-space: nowrap; color: var(--muted); }
#auditTable th { text-align: left; }
#dlgAudit { width: min(900px, calc(100vw - 24px)); }
.legal { text-align: center; padding: 6px 0 18px; font-size: 13px; }
.legal a, .legal-login a { color: var(--muted); margin: 0 8px; }
.legal-login { text-align: center; font-size: 13px; }
@media (max-width: 640px) { .prices { grid-template-columns: 1fr 1fr; } }
#table td.neg { color: #ff8a8a; font-weight: 600; }
.login h2 { font-size: 19px; margin: 0; }
.login a { color: var(--pool); }
.forgot { text-align: center; margin: -4px 0 0 !important; }
.code-input { font: 600 24px var(--num) !important; letter-spacing: .25em; text-align: center; justify-content: center !important; }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 210px; height: 210px; margin: 0 auto; display: grid; place-items: center; }
.qr svg { width: 100%; height: 100%; }
.secret { font: 600 15px var(--num); letter-spacing: .08em; word-break: break-all; text-align: center; background: var(--card); border-radius: 8px; padding: 8px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font: 600 16px var(--num); }
.codes span { background: var(--card); border-radius: 8px; padding: 6px; text-align: center; letter-spacing: .06em; }
.badge.ok { background: #3ddc8422; color: var(--to); border-color: #3ddc8466; }
.account { display: grid; gap: 10px; }
.account .line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.account .line input { flex: 1; min-width: 200px; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }

#cmpTable small { font-size: 12px; margin-left: 4px; }
#cmpTable small.up { color: var(--from); }
#cmpTable small.down { color: var(--to); }

.co2-head { margin-top: 12px !important; color: var(--text) !important; font-size: 16px !important; }
#dlgInfo { width: min(900px, calc(100vw - 24px)); }
#infoTable tbody tr { cursor: pointer; }
#infoTable td { font-family: Barlow, sans-serif; }
#infoTable td.num { font-family: var(--num); }
#infoTable td.neg, #table td.flag { color: #ff8a8a; font-weight: 600; }
.side-head .row { gap: 6px; flex-wrap: nowrap; }
.role-read #infoForm input, .role-read #infoForm textarea { pointer-events: none; opacity: .8; }
#infoTable th, #infoTable td { text-align: left; }
#infoTable th:nth-child(2), #infoTable th:nth-child(3), #infoTable td.num { text-align: right; }
.year-row { margin: 8px 0 0; flex-wrap: wrap; }
.year-row input { width: 90px; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
