/* Admin-Dashboard – Grundlage für alle Seiten.
   Farben in OKLCH, Neutraltöne leicht warm getönt. Die Familien-Seite ergänzt family.css.
   Hell/Dunkel hängt an data-mode am <html> (setzt templates/_mode.html: fest gewählt oder wie das Gerät). */
:root {
  color-scheme: light;
  --bg: oklch(0.966 0.006 85); --surface: oklch(0.995 0.003 85); --surface-2: oklch(0.94 0.008 85);
  --text: oklch(0.25 0.012 70); --muted: oklch(0.5 0.012 70);
  --border: oklch(0.895 0.008 85);
  --primary: oklch(0.27 0.014 70); --primary-text: oklch(0.985 0.004 85);
  --link: oklch(0.47 0.14 256); --focus: oklch(0.6 0.16 256);
  --ok-bg: oklch(0.95 0.04 150); --ok: oklch(0.44 0.11 150);
  --warn-bg: oklch(0.95 0.05 85); --warn: oklch(0.46 0.1 70);
  --err-bg: oklch(0.95 0.03 25); --err: oklch(0.5 0.17 27);
  --hl: oklch(0.935 0.012 85);
  --radius: 12px; --shadow: 0 1px 2px oklch(0.25 0.01 70 / .05), 0 4px 14px oklch(0.25 0.01 70 / .04);
}
:root[data-mode="dark"] {
  color-scheme: dark;
  --bg: oklch(0.165 0.006 70); --surface: oklch(0.212 0.007 70); --surface-2: oklch(0.255 0.008 70);
  --text: oklch(0.93 0.008 85); --muted: oklch(0.69 0.012 80);
  --border: oklch(0.3 0.008 70);
  --primary: oklch(0.93 0.008 85); --primary-text: oklch(0.2 0.01 70);
  --link: oklch(0.78 0.1 250); --focus: oklch(0.72 0.13 250);
  --ok-bg: oklch(0.28 0.05 150); --ok: oklch(0.82 0.13 150);
  --warn-bg: oklch(0.3 0.05 80); --warn: oklch(0.85 0.11 85);
  --err-bg: oklch(0.29 0.07 25); --err: oklch(0.8 0.12 25);
  --hl: oklch(0.27 0.01 75);
  --shadow: none;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
       background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2rem 0 1.2rem; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; margin: .6rem 0 .5rem; } h3.mt { margin-top: 1.4rem; }
code, .mono { font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.right { text-align: right; } .error-text { color: var(--err); } .warn-text { color: var(--warn); }


.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 1.5rem 1rem 3rem; flex: 1; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 1.2rem 1.3rem; margin-bottom: 1.2rem; }
.card.highlight { background: var(--hl); border-color: color-mix(in oklch, var(--text) 25%, var(--border)); }
.card.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
details.card summary { cursor: pointer; list-style: none; }
details.card summary h2 { display: inline; margin: 0; }
details.card summary::before { content: "▸ "; color: var(--muted); }
details[open].card summary::before { content: "▾ "; }
details[open].card summary { margin-bottom: 1rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 1rem; }
.tool-card { display: flex; gap: 1rem; color: var(--text); transition: transform .1s, border-color .1s; }
.tool-card:hover { text-decoration: none; border-color: color-mix(in oklch, var(--text) 40%, var(--border)); transform: translateY(-1px); }
.tool-card p { margin: .2rem 0; }
.tool-icon { font-size: 2rem; line-height: 1; }
.status { font-size: .85rem; font-weight: 550; }

.row { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 200px; }
.row.spread { justify-content: space-between; margin: 0; }
.stack { display: flex; flex-direction: column; gap: .8rem; max-width: 520px; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 550; }
input[type=text], input[type=password], input:not([type]) {
  font: inherit; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; }
:where(a, button, summary, [tabindex]):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input[readonly] { background: var(--bg); }

.btn { font: inherit; font-weight: 550; padding: .5rem .95rem; border-radius: 9px; cursor: pointer;
       border: 1px solid var(--border); background: var(--surface); color: var(--text); white-space: nowrap;
       display: inline-block; }
.btn:hover { border-color: color-mix(in oklch, var(--text) 45%, var(--border)); text-decoration: none; }
.btn:active, .linkbtn:active, .check-btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.error { background: var(--err-bg); color: var(--err); }

.table { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
            color: var(--muted); font-weight: 600; padding: .4rem .5rem; border-bottom: 1px solid var(--border); }
.table td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table form { margin: 0; }
.count { background: var(--bg); color: var(--muted); border-radius: 999px; padding: 0 .55rem; font-size: .8rem; margin-left: .3rem; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; margin: 0 .2rem; }
.tag.add { background: var(--ok-bg); color: var(--ok); }
.tag.rem { background: var(--err-bg); color: var(--err); }

.login-wrap { flex: 1; display: grid; place-items: center; padding: 1rem; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 1rem; }
.login h1 { font-size: 1.3rem; margin: 0; text-align: center; }

@media (max-width: 600px) {
  #domains th:nth-child(2), #domains td.ip { display: none; }
}

select { font: inherit; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 7px;
         background: var(--surface); color: var(--text); }
label.check { flex-direction: row; align-items: flex-start; gap: .5rem; font-weight: 450; }
label.check input { margin-top: .3rem; }
.fritz-status { font-weight: 550; padding: .5rem .75rem; border-radius: 7px; margin-bottom: .8rem; background: var(--bg); }
.fritz-status.good { background: var(--ok-bg); color: var(--ok); }
.fritz-status.bad { background: var(--warn-bg); color: var(--warn); }

/* --- v0.3: gemeinsame Bausteine für alle Tools --- */
.container.wide { max-width: 1280px; }
.table-wrap { overflow-x: auto; }
.table.compact td { padding: .3rem .4rem; }
.nowrap { white-space: nowrap; }
form.inline { display: inline-block; margin: 0; }
.row.tight { gap: .3rem; margin: 0; flex-wrap: nowrap; }
label.grow, .grow { flex: 1; min-width: 180px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
ul.tight { margin: .3rem 0 0; padding-left: 1.2rem; }
.tag.muted-tag { background: var(--bg); color: var(--muted); font-weight: 500; }
.tags { margin-top: .15rem; } .tags .tag { margin: 0 .2rem 0 0; font-size: .72rem; }
.help { margin-bottom: 1rem; } .help summary { cursor: pointer; } .help ol { margin: .5rem 0; padding-left: 1.3rem; }

.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: var(--muted); }
.dot.up { background: #22a559; box-shadow: 0 0 0 3px color-mix(in srgb, #22a559 20%, transparent); }
.dot.bad { background: #e5484d; box-shadow: 0 0 0 3px color-mix(in srgb, #e5484d 25%, transparent); }
.dot.off { background: color-mix(in srgb, var(--muted) 45%, transparent); }
.dot.unknown { background: transparent; border: 2px dashed var(--muted); }

.meter { flex: 1; height: .5rem; background: var(--bg); border-radius: 999px; overflow: hidden; min-width: 60px; }
.meter i { display: block; height: 100%; background: var(--link); border-radius: 999px; max-width: 100%; }
.meter.mid i { background: #e5a000; } .meter.bad i { background: #e5484d; }
.meter.small { height: .3rem; margin-bottom: .2rem; max-width: 90px; }
.meter-row { display: flex; align-items: center; gap: .7rem; margin: .4rem 0; font-size: .88rem; }
.meter-row > span:first-child { width: 3rem; color: var(--muted); }
.meter-row > span:last-child { min-width: 9rem; text-align: right; }
.meter-row.wide-label > span:first-child { width: 16rem; color: var(--text); }
.stat-card p { margin: .3rem 0; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: .85rem; border: 0; background: var(--surface); color: var(--muted); padding: .3rem .7rem; cursor: pointer; }
.seg button.active { background: var(--hl); color: var(--text); font-weight: 600; }

.spark { display: flex; gap: 1px; align-items: flex-end; height: 18px; }
.spark i { width: 4px; height: 100%; border-radius: 1px; background: #22a559; opacity: .85; }
.spark i.bad { background: #e5484d; }

.qr-card { text-align: center; max-width: 420px; margin: 0 auto; }
.qr svg { width: 260px; height: 260px; }
.qr-card .big { font-size: 1.4rem; font-weight: 650; margin: .5rem 0; }
.delete-form label.check { display: inline-flex; margin-right: .3rem; color: var(--muted); }
@media print { .sidebar, .mobilebar, .backdrop, .foot, .no-print, .flash { display: none !important; } body.with-nav { padding-left: 0; } .card { border: 0; box-shadow: none; } }
@media (max-width: 700px) { .meter-row.wide-label { flex-wrap: wrap; } .meter-row.wide-label > span:first-child { width: 100%; } }

/* --- v0.4: Sicherheit, Erinnerungen, Internet, Familie --- */
.seg a { font-size: .85rem; color: var(--muted); padding: .3rem .75rem; display: inline-block; }
.seg a.active { background: var(--hl); color: var(--text); font-weight: 600; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg.tabs { margin-bottom: 1rem; }
textarea { font: inherit; font-family: ui-monospace, monospace; font-size: .85rem; width: 100%; padding: .6rem;
           border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); }
.wide-stack { max-width: none; }

.grid.score { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1.2rem; }
.score-card { text-align: center; color: var(--muted); font-size: .85rem; margin: 0; }
.score-card .big { display: block; font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.score-card.bad .big { color: var(--err); } .score-card.mid .big { color: var(--warn); } .score-card.good .big { color: var(--ok); }
.finding { border-width: 1px; }
.finding h2 { margin: .3rem 0 0; font-size: 1rem; }
.finding p { margin: .5rem 0 0; }
.finding.sev-high { border-color: color-mix(in oklch, var(--err) 55%, var(--border)); } .finding.sev-high .tag.sev { background: var(--err-bg); color: var(--err); }
.finding.sev-medium { border-color: color-mix(in oklch, var(--warn) 50%, var(--border)); } .finding.sev-medium .tag.sev { background: var(--warn-bg); color: var(--warn); }
.finding.sev-low .tag.sev, .finding.sev-info .tag.sev { background: var(--bg); color: var(--muted); }
.finding .tag.sev { margin-left: 0; }

.timeline-row { display: flex; gap: 1rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.timeline-row:last-child { border-bottom: 0; }
.timeline-row.soon .tl-date { background: var(--primary); color: var(--primary-text); }
.tl-date { min-width: 3.4rem; text-align: center; font-weight: 700; background: var(--bg); border-radius: 8px; padding: .25rem .3rem; line-height: 1.15; }
.timeline-row.soon .tl-date .muted { color: inherit; opacity: .8; }
.tl-main { flex: 1; } .tl-when { white-space: nowrap; font-size: .9rem; }

svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }
svg.chart .ref { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
svg.chart .line { fill: none; stroke: var(--link); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .dotm { fill: var(--link); }
svg.chart .hit circle:first-child { fill: transparent; }
svg.chart .hit .mk { fill: var(--link); stroke: var(--surface); stroke-width: 2; opacity: 0; }
svg.chart .hit:hover .mk { opacity: 1; }
svg.chart .hit.fail .mk { fill: var(--err); opacity: 1; }

.memory-tile { padding: 0; overflow: hidden; position: relative; max-height: 320px; }
.memory-tile img, .memory img { width: 100%; height: 100%; max-height: 320px; object-fit: cover; display: block; transition: opacity .4s; }
.mem-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: .7rem 1rem; color: #fff; font-weight: 600;
               background: linear-gradient(transparent, rgba(0,0,0,.65)); }

/* --- v0.4.1: Seitenleiste (Desktop) / ausklappbares Menü (Handy) --- */
:root { --sidebar-w: 232px; }
.mobilebar { display: none; }
body.with-nav { padding-left: var(--sidebar-w); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface);
           border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 40;
           overflow-y: auto; padding: .9rem .6rem; }
.sidebar .brand { font-weight: 650; color: var(--text); padding: .3rem .6rem .9rem; display: block; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.sidebar nav a, .sidebar-foot a, .linkbtn { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem;
           border-radius: 7px; color: var(--muted); font: inherit; font-size: .93rem; text-decoration: none; }
.sidebar nav a:hover, .sidebar-foot a:hover, .linkbtn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar nav a.active, .sidebar-foot a.active { background: var(--hl); color: var(--text); font-weight: 600; }
.sidebar .ico { width: 1.3rem; text-align: center; flex: none; }
.navgroup { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
            padding: .9rem .6rem .25rem; opacity: .8; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .5rem; }
.sidebar-foot form { margin: 0; }
.linkbtn { width: 100%; background: none; border: 0; cursor: pointer; text-align: left; }
.backdrop { display: none; }

@media (max-width: 900px) {
  body.with-nav { padding-left: 0; }
  .mobilebar { display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 30;
               background: var(--surface); border-bottom: 1px solid var(--border); padding: .5rem 1rem; }
  .mobilebar .brand { font-weight: 650; color: var(--text); }
  .navtoggle { font-size: 1.35rem; line-height: 1; background: none; border: 1px solid var(--border); color: var(--text);
               border-radius: 8px; padding: .3rem .6rem; cursor: pointer; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.25);
             width: min(80vw, 280px); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  body.nav-open { overflow: hidden; }
  .sidebar nav a, .sidebar-foot a, .linkbtn { padding: .65rem .6rem; font-size: 1rem; }  /* größere Tippflächen */
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* --- v0.4.1: Handy-Feinschliff --- */
select { max-width: 100%; }
.card { min-width: 0; }
@media (max-width: 700px) {
  .container { padding: 1rem .75rem 2.5rem; }
  h1 { font-size: 1.3rem; margin-bottom: .9rem; }
  .card { padding: 1rem; overflow-x: auto; }           /* breite Tabellen scrollen in ihrer Karte */
  .row, .row.tight, .row.spread { flex-wrap: wrap; }
  .row > input, .row.tight input { min-width: 0; flex: 1 1 160px; }
  .btn { white-space: normal; }
  .card-head { gap: .5rem; }
  .table th, .table td { padding: .4rem .35rem; font-size: .9rem; }
  .meter-row > span:last-child { min-width: 0; font-size: .8rem; }
  .meter-row.wide-label > span:last-child { width: 100%; text-align: left; }
  /* Startseite: kompakte Liste statt großer Karten */
  .tool-card { padding: .75rem .9rem; align-items: center; gap: .8rem; }
  .tool-card .tool-icon { font-size: 1.5rem; }
  .tool-card h2 { margin: 0; font-size: 1rem; }
  .tool-card p.muted { display: none; }
  .tool-card p.status { margin: .1rem 0 0; font-weight: 500; color: var(--muted); }
  .grid { gap: .6rem; }
  .grid.score { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .score-card .big { font-size: 1.6rem; }
  .timeline-row { gap: .7rem; }
}
.widget-toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: .5rem; }
.widget-toggle { border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; }
@media (max-width: 700px) { .hide-m { display: none !important; } }
.grid > .card { margin-bottom: 0; }

.cal-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; vertical-align: baseline; }
/* Familie → Einrichten: abonnierte Kalender (Name, Adresse, Farbe) */
.subs { list-style: none; margin: .6rem 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.subs:empty { display: none; }
.subs li { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .5rem; }
.subs input[name="sub_name"] { flex: 1 1 9rem; width: auto; min-width: 0; margin: 0; }
.subs input[name="sub_url"] { flex: 3 1 16rem; width: auto; min-width: 0; margin: 0; }
.subs input[type="color"] { flex: none; width: 44px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
/* Familie → Einrichten: Geräte aus Home Assistant auswählen */
.ha-picked { list-style: none; margin: .6rem 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.ha-picked:empty { display: none; }
.ha-picked li { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .6rem; }
.ha-picked input[name="ha_label"] { flex: 1 1 12rem; width: auto; min-width: 0; margin: 0; }
.ha-picked code { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
.ha-results { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.ha-results:empty { display: none; }
.ha-results p { margin: 0; }
.ha-hit { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: left; line-height: 1.25; padding-block: .35rem; }
.ha-hit span { font-size: .78rem; font-weight: 400; color: var(--muted); }
.ha-hit:disabled { opacity: .45; }

/* --- Touch: alles mit dem Finger bedienbar ------------------------------------ */
html { -webkit-text-size-adjust: 100%; }
a, button, .btn, summary, label, select, input { touch-action: manipulation; }
@media (hover: none) {
  a:hover { text-decoration: none; }
  .tool-card:hover { transform: none; border-color: var(--border); }
}
@media (pointer: coarse) {
  .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: .55rem 1rem; }
  .btn.small { min-height: 38px; padding: .4rem .8rem; font-size: .9rem; }
  input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input:not([type]),
  select, textarea { min-height: 44px; font-size: 16px; }      /* 16px: iOS zoomt beim Antippen nicht hinein */
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; flex: none; }
  label.check { align-items: center; gap: .6rem; min-height: 40px; }
  label.check input { margin-top: 0; }
  .seg a, .seg button { padding: .6rem .9rem; }
  summary { padding-block: .55rem; }
  .table td, .table th { padding-block: .6rem; }
  .sidebar nav a, .sidebar-foot a, .linkbtn { padding: .7rem .6rem; }
  .navtoggle { min-width: 44px; min-height: 44px; }
  [title]:not(a, button, input, select, textarea, label, summary), svg.chart .hit { cursor: help; }
}
/* Tooltip-Ersatz auf Touch-Geräten: Antippen zeigt den Hinweistext (siehe base.html) */
.tip-bubble { position: fixed; z-index: 1000; max-width: min(320px, calc(100vw - 24px)); padding: .45rem .7rem; border-radius: 10px;
              background: var(--text); color: var(--bg); font-size: .85rem; line-height: 1.35; pointer-events: none;
              box-shadow: 0 6px 20px oklch(0 0 0 / .25); }
