/* Farben aus Dominiks Website (Blau/Navy) */
:root {
  --bg: #F0F5FA;
  --card: #ffffff;
  --text: #1E1E1E;
  --muted: #4A5B6B;
  --line: #D9E4EE;
  --accent: #086397;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --ok: #2e7d32;
  --warn: #b26a00;
  --bar: #DCE8F2;
  --top: #0B2E4E;
  --top-text: #ffffff;
  --top-muted: #A6BACB;
  --top-on: #163655;
  --radius: 14px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #07182A;
  --card: #0F2A43;
  --text: #E4ECF4;
  --muted: #A6BACB;
  --line: #1D3C59;
  --accent: #6FBFF2;
  --accent-text: #07182A;
  --danger: #ff8a80;
  --ok: #81c784;
  --warn: #ffb74d;
  --bar: #1D3C59;
  --top: #0B2136;
  --top-on: #163655;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07182A; --card: #0F2A43; --text: #E4ECF4; --muted: #A6BACB; --line: #1D3C59;
    --accent: #6FBFF2; --accent-text: #07182A; --danger: #ff8a80; --ok: #81c784; --warn: #ffb74d; --bar: #1D3C59;
    --top: #0B2136; --top-on: #163655;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .7rem 16px; background: var(--top); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--top-text); }
nav { display: flex; gap: .25rem; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--top-muted); padding: .35rem .6rem; border-radius: 999px; }
nav a.on { background: var(--top-on); color: var(--top-text); }
.badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .8rem; }

main { max-width: 960px; margin: 0 auto; padding: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid .card + .card { margin-top: 0; }
.muted { color: var(--muted); }
.small-text { font-size: .875rem; }

.device { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .8rem; }
.device-head { display: flex; align-items: center; gap: .5rem; justify-content: space-between; flex-wrap: wrap; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); margin-right: .35rem; }
.dot.on { background: var(--ok); }
.bar { height: .55rem; background: var(--bar); border-radius: 999px; overflow: hidden; margin: .5rem 0 .25rem; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.full > span { background: var(--danger); }
.buttons { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }

.btn {
  font: inherit; font-size: .95rem; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  padding: .45rem .8rem; border-radius: 10px; min-height: 40px;
  text-decoration: none; display: inline-flex; align-items: center;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn.danger { color: #1a0b0a; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; margin: .6rem 0; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: .45rem .6rem; min-height: 40px;
}
input[type="text"], input[type="password"] { width: 100%; }
input[type="number"] { width: 6rem; }
input[type="time"] { width: 7.5rem; }
input[type="checkbox"] { width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: var(--accent); flex-shrink: 0; }
.row:has(> input[type="checkbox"]) { flex-wrap: nowrap; }

.sched { border: 1px solid var(--line); border-radius: 10px; padding: .6rem; margin: .5rem 0; }
.days { display: flex; gap: .25rem; flex-wrap: wrap; margin: .4rem 0; }
.days label { margin: 0; display: flex; align-items: center; gap: .2rem; font-size: .9rem; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
td, th { text-align: left; padding: .35rem .25rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num { text-align: right; white-space: nowrap; }

.code { font-size: 2rem; letter-spacing: .3rem; font-weight: 700; font-variant-numeric: tabular-nums; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 16px; max-width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog.small { width: 360px; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.live { width: 1000px; }
.live-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.live-screen { background: #000; border-radius: 10px; min-height: 180px; display: grid; place-items: center; overflow: hidden; }
.live-screen img { max-width: 100%; display: block; }
.live-screen img:not([src]) { display: none; }
.live-screen p { color: #ccc; }
.live-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.windows { margin: .6rem 0 0; padding-left: 1.1rem; font-size: .9rem; color: var(--muted); max-height: 140px; overflow: auto; }

/* ---------- Kind-Seite: Menü + Bereiche ---------- */
.kid-head { margin-bottom: 20px; }
.kid-head h1 { margin: .3rem 0 0; }
.kid-head .age { font-weight: 400; font-size: 1rem; }
.back { text-decoration: none; font-size: .95rem; }
.kid-layout { display: grid; gap: 24px; grid-template-columns: 230px minmax(0, 1fr); align-items: start; }
.side {
  position: sticky; top: 76px; display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
}
.side button {
  font: inherit; text-align: left; cursor: pointer; border: 0; background: transparent; color: var(--text);
  padding: .7rem .9rem; border-radius: 10px; min-height: 44px;
}
.side button:hover { background: var(--bar); }
.side button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.panel .card { padding: 24px; }
.panel h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.group { border-top: 1px solid var(--line); padding: 18px 0 6px; }
.group:first-of-type { border-top: 0; padding-top: 4px; }
.group h3 { margin: 0 0 .6rem; font-size: 1.02rem; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .2rem; }
.group-tools { font-size: .875rem; color: var(--muted); }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }
.opt {
  display: flex; align-items: flex-start; gap: .85rem; margin: 0; padding: .8rem .2rem;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.opt:last-child { border-bottom: 0; }
.opt input { margin-top: .15rem; }
.opt-label { display: block; }
.opt-hint { display: block; color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.field { display: block; margin: .9rem 0; }
.field input[type="text"], .field textarea { margin-top: .35rem; width: 100%; display: block; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .6rem 0; margin: 0; }
.note { background: var(--bar); border-radius: 10px; padding: .8rem 1rem; margin: 0 0 1rem; font-size: .92rem; }
.danger-zone .btn { border-color: var(--danger); color: var(--danger); }
.savebar {
  position: sticky; bottom: 0; z-index: 4; margin-top: 16px;
  display: flex; align-items: center; justify-content: flex-end; gap: 1rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px;
  box-shadow: 0 -6px 20px rgba(0,0,0,.08);
}
.savebar .warn { color: var(--warn); font-weight: 600; }
@media (max-width: 820px) {
  .kid-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .side { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; }
  .side button { padding: .55rem .7rem; font-size: .92rem; text-align: center; background: var(--bar); }
  .side button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .panel .card { padding: 16px; }
  .top { position: static; }
}

.map-bar { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.map-bar .seg { margin-top: 0; }
.map { height: min(60vh, 520px); min-height: 300px; border-radius: 10px; border: 1px solid var(--line); isolation: isolate; z-index: 0; }
.map .leaflet-popup-content { font: .9rem/1.4 system-ui, sans-serif; }
/* dunkle Karte im Dunkel-Modus */
:root[data-theme="dark"] .map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
}
#locList td:first-child { white-space: nowrap; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; z-index: 20; max-width: calc(100vw - 32px);
}
.err { color: var(--danger); }
.login { max-width: 420px; margin: 8vh auto 0; }
