:root {
  --bg: #f4f4f2; --surface: #fcfcfb; --surface-2: #efeeea; --line: #e2e1dc;
  --text: #0b0b0b; --text-2: #52514e; --muted: #7a7973;
  --accent: #2a78d6; --accent-ink: #fff; --accent-soft: #e3eefb;
  --good: #0ca30c; --good-ink: #006300; --warning: #fab219; --warning-ink: #7a5200;
  --serious: #ec835a; --critical: #d03b3b; --critical-ink: #a32121;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05); --side: 232px;
  color-scheme: light;
}
/* Dunkel wie auf allen Marco-Websites (Schatteria Companion): Klasse .dark auf <html>, gesetzt vom Inline-Script im <head>
   (Priorität: gespeicherte Wahl in localStorage 'theme' > Systemeinstellung). Palette: Canvas #0b0f18, Karten #141a27, Linien #2a3245. */
.dark {
  --bg: #0b0f18; --surface: #141a27; --surface-2: #1b2232; --line: #2a3245;
  --text: #e6e8ee; --text-2: #9aa3b2; --muted: #7c8596;
  --accent: #4b8fe8; --accent-soft: #1a2940; --good-ink: #5fd35f; --warning-ink: #fab219; --critical-ink: #f07a7a;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--text-2); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.small { padding: 3px 9px; font-size: 12.5px; }
select, input { font: inherit; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { color: var(--text-2); font-size: 12.5px; }
.tile .value { font-size: 28px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .hint { color: var(--muted); font-size: 12px; }

section.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.card-head .meta { color: var(--text-2); font-size: 12.5px; }
.card-head .spacer { flex: 1; }
.err { color: var(--critical-ink); padding: 12px 16px; white-space: pre-wrap; font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 550; color: var(--text-2); font-size: 12.5px; background: var(--surface-2); }
td.ver { font-variant-numeric: tabular-nums; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
tr.hidden { display: none; }
.muted { color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 550; white-space: nowrap; }
.badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { color: var(--good-ink); } .badge.ok::before { background: var(--good); }
.badge.update { color: var(--warning-ink); } .badge.update::before { background: var(--warning); }
.badge.error { color: var(--critical-ink); } .badge.error::before { background: var(--critical); }
.badge.unknown { color: var(--muted); }
.type { font-size: 11.5px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--text-2); }
.type.major { border-color: var(--critical); color: var(--critical-ink); }
.type.minor { border-color: var(--warning); color: var(--warning-ink); }

.fritz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding: 14px 16px; }
.fritz { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; background: var(--surface); }
.fritz h3 { margin: 0 0 2px; font-size: 14.5px; }
.fritz .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 2px 0; }
.fritz .row span:first-child { color: var(--text-2); }

.jobs { padding: 6px 16px 14px; }
.job { border-bottom: 1px solid var(--line); padding: 8px 0; }
.job:last-child { border-bottom: 0; }
.job summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.job pre { background: var(--surface-2); padding: 10px; border-radius: 7px; max-height: 320px; overflow: auto; font-size: 12px; white-space: pre-wrap; }

.settings { display: flex; flex-wrap: wrap; gap: 14px 22px; padding: 14px 16px; align-items: center; }
.settings label { display: flex; gap: 8px; align-items: center; color: var(--text-2); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 9px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; }

/* Login im Layout des Loxone Agent: zentrierte Karte, Icon, Wortmarke, „Bitte anmelden“, Felder, vollbreiter Button */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 330px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px 26px 26px; }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 30px; }
.login-icon { display: block; }
.login h1 { margin: 2px 0 0; line-height: 0; }
.login-sub { margin: 0; font-size: 12.5px; color: var(--text-2); }
.login input { display: block; width: 100%; margin-bottom: 10px; padding: 9px 12px; border-radius: 8px; background: var(--surface-2); }
.dark .login input { background: var(--surface); }
.login input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.login button { width: 100%; padding: 9px; margin-top: 6px; border-radius: 8px; font-weight: 650; }
.login #msg { margin: 10px 0 0; text-align: center; font-size: 13px; }
.login #msg:empty { display: none; }
@media (max-width: 640px) { th, td { padding: 7px 10px; } .hide-sm { display: none; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.chip { font-size: 12.5px; padding: 3px 10px; border-radius: 99px; }
.chip b { font-weight: 650; margin-left: 3px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.auto-grid { display: grid; gap: 8px; width: 100%; }
.auto-row { display: grid; grid-template-columns: 170px 240px 1fr; gap: 10px; align-items: center; }
.auto-row .muted { font-size: 12.5px; }
@media (max-width: 640px) { .auto-row { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- Layout: Seitenleiste + volle Breite ---------- */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; }
.brand { font-size: 16px; font-weight: 700; padding: 6px 10px 14px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.brand .logo { display: block; flex: none; }
/* Wortmarke „UPDATE AGENT“ (Familie Loxone Agent): helle bzw. dunkle Variante je nach Theme */
.wm { display: block; width: auto; max-width: 100%; }
.wm-d, .dark .wm-l { display: none; }
.dark .wm-d { display: block; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .ico { width: 18px; text-align: center; opacity: .85; }
.nav a .cnt { margin-left: auto; font-size: 11.5px; font-weight: 650; min-width: 20px; text-align: center; padding: 1px 6px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.nav a .cnt.upd { background: var(--warning); color: #3d2a00; }
.nav a .cnt.err { background: var(--critical); color: #fff; }
.nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.side .foot { margin-top: auto; padding: 8px 6px 0; display: grid; gap: 8px; }
/* Hell/Dunkel-Schalter (Pille mit Sonne/Mond, identisch zu Schatteria Companion) */
.theme-toggle { position: relative; flex: none; width: 54px; height: 28px; padding: 0; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle .knob { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(15,23,42,.18); display: grid; place-items: center; transition: transform .35s cubic-bezier(.34,1.56,.64,1); }
.theme-toggle svg { position: absolute; width: 13px; height: 13px; transition: opacity .25s, transform .35s cubic-bezier(.34,1.56,.64,1); }
.theme-toggle .sun { color: #d97706; } .theme-toggle .moon { color: #8b7cff; opacity: 0; transform: rotate(-90deg) scale(.6); }
.dark .theme-toggle .knob { transform: translateX(26px); }
.dark .theme-toggle .sun { opacity: 0; transform: rotate(90deg) scale(.6); }
.dark .theme-toggle .moon { opacity: 1; transform: none; }
.content { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 650; }
.topbar .sub { color: var(--text-2); font-size: 13px; }
.topbar .spacer { flex: 1; }
.page { padding: 20px 24px 60px; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 20px; }
.mod-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); text-decoration: none; display: grid; gap: 6px; }
.mod-card:hover { border-color: var(--accent); }
.mod-card .t { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; }
.mod-card .nums { display: flex; gap: 18px; }
.mod-card .nums div { display: grid; }
.mod-card .nums b { font-size: 22px; font-variant-numeric: tabular-nums; }
.mod-card .nums span { font-size: 12px; color: var(--text-2); }
.mod-card .line { font-size: 12.5px; color: var(--muted); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; }
.plan-list { padding: 10px 16px 14px; display: grid; gap: 6px; }
.plan-list div { display: flex; gap: 8px; align-items: baseline; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 6; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 8px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 8px; white-space: nowrap; }
  .nav { display: flex; gap: 2px; } .nav a { white-space: nowrap; padding: 6px 9px; } .nav .sep { display: none; }
  .side .foot { margin: 0 0 0 auto; padding: 0; display: flex; }
  .topbar { position: static; padding: 10px 16px; } .page { padding: 16px 16px 50px; }
  .two { grid-template-columns: 1fr; }
}

.meter { display: grid; grid-template-columns: 38px 1fr 44px; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.meter span { color: var(--text-2); } .meter b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.meter .bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter .bar i { display: block; height: 100%; border-radius: 99px; }

/* Uptime-Verlauf im Kuma-Stil */
.hb-list { padding: 6px 12px 8px; display: grid; gap: 4px; }
.hb-row { display: grid; grid-template-columns: 64px minmax(160px, 1fr) 110px minmax(240px, 420px); gap: 12px; align-items: center; padding: 8px 6px; border-radius: 8px; }
.hb-row:hover { background: var(--surface-2); }
.hb-pct { font-size: 12px; font-weight: 700; text-align: center; padding: 3px 0; border-radius: 99px; color: #fff; background: var(--muted); }
.hb-pct.up { background: var(--good); } .hb-pct.warn { background: var(--warning); color: #3d2a00; } .hb-pct.down { background: var(--critical); }
.hb-name { display: grid; line-height: 1.3; min-width: 0; } .hb-name span { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-bar { display: flex; gap: 2px; justify-content: flex-end; height: 22px; }
.hb-bar i { flex: 0 0 4px; border-radius: 2px; background: var(--good); opacity: .95; }
.hb-bar i.down { background: var(--critical); } .hb-bar i.pend { background: var(--warning); } .hb-bar i.maint { background: var(--accent); }
.hb-bar i.none { background: var(--line); opacity: .6; }
.hb-bar i:hover { transform: scaleY(1.25); }
@media (max-width: 860px) { .hb-row { grid-template-columns: 56px 1fr; } .hb-state { display: none; } .hb-bar { grid-column: 1 / -1; justify-content: flex-start; overflow: hidden; } }

.job.running summary .st { color: var(--accent); }
.job pre { transition: none; }

.help { padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.help summary { cursor: pointer; color: var(--accent); font-weight: 550; }
.help p, .help ul { margin: 8px 0; } .help li { margin: 3px 0; } .help code { font-size: 12px; }

.tile-btn { text-align: left; cursor: pointer; font: inherit; color: var(--text); width: 100%; }
.tile-btn:hover { border-color: var(--accent); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: min(720px, 100%); max-height: 85vh; display: grid; grid-template-rows: auto 1fr; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 8px 16px 16px; overflow: auto; font-size: 13.5px; }
.modal-body h3 { font-size: 14px; margin: 14px 0 4px; } .modal-body h3 a { color: var(--text); text-decoration: none; } .modal-body h3 a:hover { color: var(--accent); }
.modal-body ul { margin: 0; padding-left: 18px; } .modal-body li { margin: 3px 0; }
.modal-body li.err-row b { color: var(--critical-ink); }

.btn-like{display:inline-block;padding:5px 10px;border:1px dashed var(--line, #888);border-radius:8px;font-size:12px;color:var(--text-2);text-decoration:none}
.btn-like:hover{color:var(--text)}

/* Prüflauf-Fortschritt */
details.check summary { list-style: none; cursor: pointer; }
details.check summary::-webkit-details-marker { display: none; }
details.check.running { border-color: var(--accent, #3b82f6); }
details.check .steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; padding: 0 16px 10px; }
details.check .step { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-size: 13.5px; }
details.check .step .ico { width: 1.2em; text-align: center; }
details.check .step.läuft .ico { display: inline-block; animation: spin 1.2s linear infinite; }
details.check .step.fehler .ico { color: var(--critical-ink, #e5484d); }
details.check .step.fertig .ico { color: var(--good-ink, #30a46c); }
details.check .step .err-row { flex-basis: 100%; }
details.check pre { margin: 0 16px 14px; background: var(--surface-2); padding: 10px; border-radius: 7px; max-height: 260px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
@keyframes spin { to { transform: rotate(360deg); } }

tr.row-dim td:not(.flags) { opacity: .55; }
td.flags label { font-size: 12px; cursor: pointer; }
