/* GeoSun Wärmepumpen – Web-App. Farben: GeoSun-Grün #B9D110, GeoSun-Gold #FABD14 */
:root {
  --paper: #F7F6F2; --card: #FFFFFF; --ink: #1C1C1A; --ink2: #3F3F3B; --mute: #77776F; --line: #E6E4DC; --fill: #EFEEE8;
  --green: #B9D110; --green-ink: #6F7F00; --gold: #FABD14; --alarm: #D93B30; --offline: #E8833A; --ok: #8FA80A; --unknown: #9CA3AF;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121311; --card: #1B1C19; --ink: #F1F1EC; --ink2: #D2D2CA; --mute: #9A9A90; --line: #2B2C27; --fill: #24251F;
    --green-ink: #C7DD3A; --alarm: #F0645A; --offline: #F09A5A; --ok: #C7DD3A;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121311; --card: #1B1C19; --ink: #F1F1EC; --ink2: #D2D2CA; --mute: #9A9A90; --line: #2B2C27; --fill: #24251F;
  --green-ink: #C7DD3A; --alarm: #F0645A; --offline: #F09A5A; --ok: #C7DD3A; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 17px; margin: 28px 0 10px; font-weight: 650; }
h3 { font-size: 15px; margin: 0; font-weight: 600; }
.meta { color: var(--mute); font-size: 13px; }
.small { color: var(--mute); font-size: 12px; }
.over { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--mute); font-weight: 600; }
.hidden { display: none !important; }

/* ---------- Grundgerüst ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: 236px; flex: none; border-right: 1px solid var(--line); padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--card); }
.side .logo { display: block; width: 150px; margin: 0 8px 26px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink2); font-weight: 500; }
.nav a:hover { background: var(--fill); }
.nav a.on { background: var(--fill); color: var(--ink); font-weight: 650; box-shadow: inset 3px 0 0 var(--gold); }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav .badge { margin-left: auto; background: var(--alarm); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.side .foot { margin-top: auto; padding: 0 8px; }
main { flex: 1; min-width: 0; position: relative; overflow-x: hidden; }
.page { max-width: 1100px; margin: 0 auto; padding: 28px 32px 120px; position: relative; }
.sunarc { position: absolute; top: -40px; right: -60px; width: 380px; height: 240px; pointer-events: none; opacity: .9; z-index: 0; }
.page > *:not(.sunarc) { position: relative; z-index: 1; }
.top { display: none; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .side { display: none; }
  .top { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--paper); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); }
  .top .logo { width: 104px; display: block; }
  .page { padding: 18px 16px calc(100px + env(safe-area-inset-bottom)); }
  h1 { font-size: 26px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; text-decoration: none; color: var(--mute); padding: 4px 0; position: relative; }
  .tabbar a.on { color: var(--ink); font-weight: 650; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .badge { position: absolute; top: 0; right: calc(50% - 20px); background: var(--alarm); color: #fff; border-radius: 99px; font-size: 10px; padding: 0 5px; }
  .sunarc { width: 260px; height: 170px; right: -90px; top: -30px; }
}

/* ---------- Bausteine ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 18px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap8 > * + * { margin-top: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent; background: var(--ink); color: var(--paper); font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--fill); filter: none; }
.btn.green { background: var(--green); color: #1C1C1A; }
.btn.danger { background: transparent; color: var(--alarm); border-color: var(--line); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 4px 0; color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
label.f { display: block; margin: 12px 0; }
label.f > span { display: block; font-size: 13px; color: var(--mute); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=password], input[type=search], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--card); outline: none; min-height: 44px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 30%, transparent); }
.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green-ink); }
.err { color: var(--alarm); font-size: 13px; margin-top: 8px; min-height: 1em; }
.callout { border-left: 3px solid var(--gold); background: var(--card); padding: 14px 16px; border-radius: 0 12px 12px 0; margin: 16px 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.callout.alarm { border-left-color: var(--alarm); }
.callout .over { margin-bottom: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.dot.alarm { background: var(--alarm); } .dot.offline { background: var(--offline); } .dot.ok { background: var(--ok); } .dot.unknown { background: var(--unknown); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: var(--fill); font-size: 12px; font-weight: 600; }
.pill.alarm { color: var(--alarm); } .pill.offline { color: var(--offline); } .pill.ok { color: var(--green-ink); }
.tabs { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; margin: 18px 0 6px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 4px 0 7px; cursor: pointer; color: var(--mute); white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); font-weight: 650; border-bottom-color: var(--gold); }
.hair { border: 0; border-top: 1px solid var(--line); margin: 0; }
.empty { text-align: center; padding: 48px 16px; color: var(--mute); }
.empty img { width: 120px; opacity: .25; margin-bottom: 10px; }

/* ---------- Kennzahlen ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 22px; }
.kpi { padding: 16px 0 16px 16px; border-left: 1px solid var(--line); cursor: pointer; }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi .n { font-size: 34px; font-weight: 300; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { display: flex; align-items: center; gap: 7px; margin-top: 4px; }
.kpis.k4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 560px) { .kpis.k4 { grid-template-columns: repeat(2, 1fr); } .kpis.k4 .kpi:nth-child(3) { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); } .kpis.k4 .kpi:nth-child(4) { border-top: 1px solid var(--line); } .kpi .n { font-size: 28px; } }

/* ---------- Anlagenliste ---------- */
.search { display: flex; align-items: center; gap: 10px; background: var(--fill); border-radius: 12px; padding: 0 14px; margin-top: 20px; }
.search input { border: 0; background: transparent; min-height: 46px; padding: 0; box-shadow: none !important; }
.list { margin-top: 6px; }
.item { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none; cursor: pointer; }
.item:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .r { text-align: right; font-size: 12px; color: var(--mute); flex: none; max-width: 40%; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item .chev { color: var(--mute); flex: none; }

/* ---------- Detail ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink2); font-size: 14px; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
.chart { margin: 12px 0 4px; }
.chart svg { width: 100%; height: auto; aspect-ratio: 640 / 220; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink2); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: pointer; background: var(--fill); }
.note { padding: 12px 0; border-bottom: 1px solid var(--line); white-space: pre-wrap; }

/* ---------- Dokumente / Downloads ---------- */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 12px; }
.folder { padding: 16px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; }
.folder:hover { border-color: var(--green); }
.folder .ic { width: 38px; height: 38px; border-radius: 10px; background: color-mix(in srgb, var(--green) 25%, transparent); display: flex; align-items: center; justify-content: center; flex: none; color: var(--green-ink); }
.dl { padding: 16px 18px; margin-bottom: 12px; }
.ver { background: color-mix(in srgb, var(--gold) 30%, transparent); color: var(--ink); border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.msg { padding: 18px; margin-bottom: 12px; }
.msg.new { border-left: 3px solid var(--gold); }
.msg p { margin: 8px 0 0; white-space: pre-wrap; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; position: relative; overflow: hidden; }
.auth .box { width: 100%; max-width: 400px; position: relative; z-index: 1; }
.auth .logo { width: 200px; display: block; margin: 0 auto 28px; }

/* ---------- Dialog, Toast, Ladekreis ---------- */
dialog { border: 1px solid var(--line); border-radius: 18px; padding: 22px; background: var(--card); color: var(--ink); max-width: min(560px, calc(100vw - 24px)); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-top: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.imgview { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: 10px; }
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 12px; font-size: 14px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3.5px solid var(--fill); border-top-color: var(--gold); border-right-color: var(--green); animation: sp 1s linear infinite; }
.spin.s { width: 16px; height: 16px; border-width: 2.5px; display: inline-block; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }
code.copy { display: block; background: var(--fill); padding: 10px 12px; border-radius: 10px; word-break: break-all; font-size: 13px; }
table.t { width: 100%; border-collapse: collapse; }
table.t td, table.t th { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.t th { font-size: 12px; color: var(--mute); font-weight: 600; }
@media (max-width: 640px) { table.t .hm { display: none; } }

/* ---------- Profil / Avatar ---------- */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-block; background: var(--fill); }
.avatar.ini { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #1C1C1A;
  background: linear-gradient(135deg, var(--gold), var(--green)); }
.side .foot.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; text-decoration: none; color: var(--ink); }
.side .foot.me:hover { background: var(--fill); }
.side .foot.me .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avbtn { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }
.avcam { position: absolute; right: 0; bottom: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--paper); }
a.card.row:hover { border-color: var(--green); }
