/* Smart Dashboard - Oberflaeche
   Laeuft auch auf dem Wand-iPad (iOS 12.5.7 / Safari 12.1): deshalb kein gap in
   Flexbox (nur in Grid), kein inset, kein aspect-ratio, sticky mit -webkit-Praefix,
   Eingabefelder mit min. 16px (sonst zoomt iOS beim Antippen).
   Keine Inline-Styles im Markup - die Content-Security-Policy verbietet sie. */

:root {
  --bg: #0b0f15;
  --bg-2: #10151d;
  --card: #151b25;
  --card-2: #1c2330;
  --card-3: #252e3d;
  --line: #273142;
  --line-soft: #1d2533;
  --text: #e8edf6;
  --text-2: #a3aec3;
  --text-3: #6f7b91;
  --accent: #4da3ff;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --violet: #a78bfa;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 32px -18px rgba(0,0,0,.7);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: rgba(0,0,0,0); }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: #0b0f15; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.45; min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--accent); }

/* ------------------------------------------------------------ Laden ------ */
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
        color: var(--text-3); text-align: center; padding: 24px; }
.boot-logo { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 18px;
             background: linear-gradient(140deg, #4da3ff, #7c6bff); position: relative; }
.boot-logo:after { content: ""; position: absolute; left: 22px; top: 12px; width: 20px; height: 40px;
                   background: #0b0f15; -webkit-clip-path: polygon(60% 0, 0 58%, 42% 58%, 30% 100%, 100% 36%, 56% 36%);
                   clip-path: polygon(60% 0, 0 58%, 42% 58%, 30% 100%, 100% 36%, 56% 36%); }
.boot-error { color: var(--danger); max-width: 460px; margin-top: 14px; font-size: 14px; }

/* ----------------------------------------------------------- Rahmen ------ */
.topbar {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center;
  padding: 12px 20px; padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(11,15,21,.92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar .back {
  width: 42px; height: 42px; margin-right: 12px; flex: 0 0 auto; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font-size: 24px; line-height: 1; touch-action: manipulation;
}
.topbar .back:active { background: var(--card-2); }
.topbar .back { display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.note.first { margin-top: 0; }
.totp-qr { text-align: center; margin: 6px 0 12px; }
.totp-qr img { width: 220px; height: 220px; background: #fff; border-radius: 8px; }
.totp-key { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; word-break: break-all; }
.topbar .titles { min-width: 0; flex: 1 1 auto; }
.topbar h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap;
             overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .right { display: flex; align-items: center; margin-left: 12px; flex: 0 0 auto; }
.pill { display: inline-flex; align-items: center; height: 32px; padding: 0 11px; margin-left: 8px;
        border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 13px;
        color: var(--text-2); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 7px; }
.pill.off .dot { background: var(--danger); }
.pill.power b { color: var(--text); margin-left: 5px; }
.pill.admin { background: rgba(167,139,250,.14); border-color: rgba(167,139,250,.45); color: #d8ceff; }
button.pill { font: inherit; font-size: 13px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
            color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; margin-left: 8px;
            touch-action: manipulation; }
.icon-btn:active { background: var(--card-2); }

.tabs { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 10px 20px 0;
        border-bottom: 1px solid var(--line-soft); background: var(--bg); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; padding: 10px 14px 12px; margin-right: 4px; border: 0; background: none; color: var(--text-3);
       font-weight: 650; font-size: 14.5px; border-bottom: 2px solid transparent; touch-action: manipulation; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .badge { margin-left: 6px; font-size: 11.5px; color: var(--text-3); font-weight: 700; }

.page { padding: 20px 20px 60px; padding-bottom: calc(60px + env(safe-area-inset-bottom)); max-width: 1400px; margin: 0 auto; }
.page h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3);
           font-weight: 750; margin: 26px 0 12px; display: flex; align-items: baseline; }
.page h2:first-child { margin-top: 4px; }
.page h2 .hint { margin-left: 10px; text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 600; color: var(--text-2); }
.page h2 .right { margin-left: auto; text-transform: none; letter-spacing: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
        box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid > .card + .card, .kpis > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; flex-wrap: wrap; margin: -4px 0 12px; }
.card-head h3 { margin: 4px 12px 4px 0; font-size: 16px; font-weight: 700; }
.card-head .sub { font-size: 13px; color: var(--text-3); margin: 4px 12px 4px 0; }
.card-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.note { font-size: 13px; color: var(--text-3); line-height: 1.55; margin-top: 12px; }
.empty { color: var(--text-3); font-size: 14px; padding: 14px 0; text-align: center; }
.row-flex { display: flex; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.mt { margin-top: 14px; }
.spark { margin-top: 8px; }

.grid { display: grid; grid-gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---------------------------------------------------------- Knoepfe ------ */
.btn {
  -webkit-appearance: none; appearance: none; display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px; margin: 4px 8px 4px 0; border-radius: 13px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text); font-weight: 650; font-size: 15px;
  text-decoration: none; touch-action: manipulation; white-space: nowrap;
}
.btn:active { opacity: .7; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.sm { min-height: 36px; padding: 6px 13px; font-size: 14px; border-radius: 10px; }
.btn.lg { min-height: 54px; padding: 14px 24px; font-size: 17px; }
.btn.primary { background: rgba(77,163,255,.16); border-color: rgba(77,163,255,.5); color: #b9dcff; }
.btn.good { background: rgba(52,211,153,.13); border-color: rgba(52,211,153,.45); color: #93f0cc; }
.btn.bad { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.42); color: #fdb0b0; }
.btn.violet { background: rgba(167,139,250,.15); border-color: rgba(167,139,250,.45); color: #ddd3ff; }
.btn.ghost { background: transparent; }
.btn.solid { background: var(--accent); border-color: var(--accent); color: #06121f; }
.btn .ico { margin-right: 8px; font-size: 17px; line-height: 1; }
.btns { display: flex; flex-wrap: wrap; margin: -4px 0; }

.chip { display: inline-flex; align-items: center; min-height: 34px; padding: 5px 12px; margin: 3px 6px 3px 0;
        border-radius: 999px; border: 1px solid var(--line); background: var(--card-2); color: var(--text-2);
        font-size: 13.5px; font-weight: 600; touch-action: manipulation; }
.chip.active { background: rgba(77,163,255,.16); border-color: rgba(77,163,255,.5); color: #b9dcff; }
.chip:disabled { opacity: .4; }
.chips { display: flex; flex-wrap: wrap; margin: -3px 0; }
.card > .chips:last-child { margin-top: 10px; }

.tag { display: inline-flex; align-items: center; padding: 6px 6px 6px 13px; margin: 4px 6px 4px 0; border-radius: 20px;
       background: var(--card-2); border: 1px solid var(--line); font-size: 14.5px; }
.tag.live { border-color: rgba(52,211,153,.55); color: #93f0cc; }
.tag.off { opacity: .55; }
.tag button { -webkit-appearance: none; appearance: none; border: 0; background: transparent; color: var(--text-3);
              font-size: 18px; line-height: 1; margin-left: 4px; padding: 4px 8px; border-radius: 8px; }
.tag button:active { color: var(--danger); background: rgba(248,113,113,.12); }

/* ---------------------------------------------------------- Formular ----- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase;
               letter-spacing: .06em; margin-bottom: 6px; }
.input, .select {
  -webkit-appearance: none; appearance: none; width: 100%; min-height: 46px; padding: 11px 14px;
  font-size: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); }
.check { display: flex; align-items: center; font-size: 15px; color: var(--text-2); margin: 6px 0 14px; }
.check input { width: 20px; height: 20px; margin: 0 10px 0 0; }
.addrow { display: flex; margin-top: 10px; }
.addrow .input { border-radius: 12px 0 0 12px; border-right: 0; min-width: 0; flex: 1 1 auto; }
.addrow .btn { border-radius: 0 12px 12px 0; margin: 0; }
.addrow + .btns { margin-top: 10px; }
.form-error { color: #fdb0b0; font-size: 14px; margin: 4px 0 10px; min-height: 20px; }
.form-ok { color: #93f0cc; font-size: 14px; margin: 4px 0 10px; }

/* ------------------------------------------------------------ Login ------ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login { width: 100%; max-width: 400px; }
.login .brand { display: flex; align-items: center; margin-bottom: 22px; }
.login .brand .logo { width: 46px; height: 46px; border-radius: 14px; margin-right: 14px;
                      background: linear-gradient(140deg, #4da3ff, #7c6bff); position: relative; flex: 0 0 auto; }
.login .brand .logo:after { content: ""; position: absolute; left: 15px; top: 8px; width: 16px; height: 30px; background: #0b0f15;
  -webkit-clip-path: polygon(60% 0, 0 58%, 42% 58%, 30% 100%, 100% 36%, 56% 36%);
  clip-path: polygon(60% 0, 0 58%, 42% 58%, 30% 100%, 100% 36%, 56% 36%); }
.login .brand b { display: block; font-size: 20px; }
.login .brand span { font-size: 13px; color: var(--text-3); }
.banner { border-radius: 12px; padding: 11px 13px; font-size: 13.5px; line-height: 1.5; margin-bottom: 14px; }
.banner.warn { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.4); color: #fde8a8; }
.banner.bad { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.4); color: #fdb0b0; }
.banner.info { background: rgba(77,163,255,.1); border: 1px solid rgba(77,163,255,.35); color: #b9dcff; }

/* ------------------------------------------------------ Startbildschirm -- */
.menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); grid-gap: 18px;
        max-width: 980px; margin: 7vh auto 0; }
.menu-tile {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; min-height: 250px; margin: 0;
  padding: 30px 28px; text-align: left; border-radius: 28px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); touch-action: manipulation; box-shadow: var(--shadow);
}
.menu-tile:active { background: var(--card-2); }
.menu-tile .icon { font-size: 50px; line-height: 1; margin-bottom: 22px; }
.menu-tile .label { font-size: 28px; font-weight: 750; letter-spacing: -.01em; }
.menu-tile .desc { font-size: 15px; color: var(--text-3); margin-top: 8px; line-height: 1.45; }
.menu-tile.automation { border-color: rgba(77,163,255,.42); }
.menu-tile.automation:active { background: rgba(77,163,255,.1); }
.menu-tile.admin { border-color: rgba(167,139,250,.42); }
.menu-tile.admin:active { background: rgba(167,139,250,.1); }
.menu-tile.claude { border-color: rgba(217,119,87,.45); }
.menu-tile.claude:active { background: rgba(217,119,87,.1); }
.menu-tile.monitor { border-color: rgba(57,135,229,.45); }
.menu-tile.monitor:active { background: rgba(57,135,229,.1); }
.menu-status { max-width: 980px; margin: 22px auto 0; text-align: center; color: var(--text-3); font-size: 14.5px; }
.menu-status b { color: var(--text-2); }
.menu-foot { max-width: 980px; margin: 30px auto 0; text-align: center; }

/* ----------------------------------------------------------- Kacheln ----- */
.tile {
  -webkit-appearance: none; appearance: none; position: relative; display: block; width: 100%; min-height: 118px;
  margin: 0; padding: 15px 15px 44px; text-align: left; border-radius: 17px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); touch-action: manipulation;
  /* langes Druecken = Lampe einstellen: kein iOS-Kontextmenue, keine Textauswahl */
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.tile:active { background: var(--card-3); }
/* Obere Zeile: Raum links, Schalter rechts. Darunter bekommt der Name die volle
   Kachelbreite - so passt auch "Sternenprojektor" auf schmale Kacheln. Keine
   automatische Silbentrennung: lange Namen brechen an Leerzeichen oder nach "/"
   (per <wbr>); nur ein einzelnes Wort, das nicht einmal allein passt, wird geteilt. */
.tile .top { display: flex; align-items: center; min-height: 27px; margin-bottom: 9px; }
.tile .sub { flex: 1 1 auto; min-width: 0; margin-right: 8px; font-size: 13px; color: var(--text-3);
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .name { display: block; font-size: 17px; font-weight: 650; line-height: 1.2;
              -webkit-hyphens: manual; hyphens: manual; overflow-wrap: break-word; word-wrap: break-word; }
.tile .name.long { font-size: 15.5px; }
.grid[data-group] .tile .sub { visibility: hidden; }   /* Raum steht schon als Ueberschrift darueber */
.tile .state { position: absolute; left: 15px; bottom: 13px; font-size: 14.5px; font-weight: 650; color: var(--text-2); }
.tile .watt { position: absolute; right: 15px; bottom: 13px; font-size: 13px; font-weight: 700; color: var(--text-3); }
.knob { position: relative; flex: 0 0 auto; width: 46px; height: 27px; margin-left: auto; border-radius: 14px;
        background: var(--card-3); border: 1px solid var(--line); }
.knob:after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%;
              background: var(--text-3); -webkit-transition: left .15s; transition: left .15s; }
.tile.on .knob:after { left: 22px; background: #fff; }
.tile.light.on { background: rgba(251,191,36,.13); border-color: rgba(251,191,36,.55); }
.tile.light.on .knob { background: var(--warn); border-color: var(--warn); }
.tile.light.on .state { color: var(--warn); }
.tile.plug.on { background: rgba(52,211,153,.11); border-color: rgba(52,211,153,.5); }
.tile.plug.on .knob { background: var(--ok); border-color: var(--ok); }
.tile.plug.on .state { color: var(--ok); }
/* PC-Menue (Herunterfahren / Hart / Startsignal): Knoepfe untereinander */
.pc-choices { margin-top: 4px; }
.pc-choices .pc-choice { display: block; width: 100%; margin: 0 0 10px; padding: 12px 14px; text-align: left; white-space: normal; height: auto; }
.pc-choices .pc-choice b { display: block; font-size: 15.5px; }
.pc-choices .pc-choice small { display: block; margin-top: 3px; font-size: 13px; font-weight: 500; opacity: .75; line-height: 1.35; }
.pc-choices .note { margin: 0 0 12px; }
/* PC (Wake on LAN): rundes Symbol wie im Grundriss statt Schiebeschalter, blau wenn online */
.tile .tico { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center;
              -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;
              flex: 0 0 auto; width: 34px; height: 34px; margin: -4px 0 -3px auto; border-radius: 50%;
              background: var(--card-3); border: 1px solid var(--line); color: var(--text-3); }
.tile.pc.on { background: rgba(96,165,250,.12); border-color: rgba(96,165,250,.55); }
.tile.pc.on .tico { background: #60a5fa; border-color: #bfdbfe; color: #061a33; }
.tile.pc.on .state { color: #93c5fd; }
.tile.dead { opacity: .45; }
.tile.pending { opacity: .6; }

/* ------------------------------------------------------------ Grundriss -- */
.fp-toolbar { display: flex; flex-wrap: wrap; align-items: center; margin: -4px 0 10px; }
.fp-toolbar .sep { width: 1px; height: 28px; background: var(--line); margin: 0 10px 0 2px; }
.fp-floors { display: flex; flex-wrap: wrap; margin: 0 0 10px; }
.fp-stage { position: relative; width: 100%; border-radius: var(--radius); border: 1px solid var(--line);
            background: #0d1219; overflow: hidden; }
.fp-stage.editing { border-color: rgba(167,139,250,.55); }
.fp-svg { display: block; width: 100%; height: 100%; -webkit-user-select: none; user-select: none;
          -webkit-touch-callout: none; touch-action: manipulation; }
.fp-stage.editing .fp-svg { touch-action: none; }
.fp-hint { position: absolute; left: 12px; bottom: 10px; right: 12px; font-size: 13px; color: var(--text-2);
           pointer-events: none; text-shadow: 0 1px 2px #000; }
.fp-grid-minor { stroke: rgba(255,255,255,.035); }
.fp-grid-major { stroke: rgba(255,255,255,.075); }
.fp-bounds { fill: none; stroke: rgba(255,255,255,.12); stroke-dasharray: 6 6; }
.fp-room { stroke-width: 2; stroke-linejoin: round; }
.fp-room.c-blue   { fill: rgba(77,163,255,.09);  stroke: rgba(77,163,255,.62); }
.fp-room.c-teal   { fill: rgba(45,212,191,.09);  stroke: rgba(45,212,191,.62); }
.fp-room.c-green  { fill: rgba(52,211,153,.09);  stroke: rgba(52,211,153,.62); }
.fp-room.c-amber  { fill: rgba(251,191,36,.08);  stroke: rgba(251,191,36,.62); }
.fp-room.c-rose   { fill: rgba(251,113,133,.09); stroke: rgba(251,113,133,.62); }
.fp-room.c-violet { fill: rgba(167,139,250,.10); stroke: rgba(167,139,250,.62); }
.fp-room.c-slate  { fill: rgba(148,163,184,.08); stroke: rgba(148,163,184,.55); }
.fp-room.lit      { fill: rgba(251,191,36,.10); }
.fp-room.selected { stroke: #fff; stroke-width: 2.5; }
/* Dunkler Rand hinter Beschriftungen (paint-order: erst Kontur, dann Fuellung):
   bleibt lesbar ueber Lichtschein, Raumkanten und Nachbarsymbolen. */
.fp-room-label, .fp-dev .lbl, .fp-dev .val { paint-order: stroke; stroke: #0d1219; stroke-linejoin: round; }
.fp-room-label { fill: var(--text-2); font-weight: 700; pointer-events: none; }
.fp-dev .hit { fill: transparent; }
.fp-dev { cursor: pointer; }
.fp-dev .bg { fill: #1f2734; stroke: #3b475b; stroke-width: 2; }
.fp-dev .ic { fill: none; stroke: #9aa6ba; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fp-dev .lbl { fill: var(--text-2); font-weight: 650; }
.fp-dev .val { fill: var(--text-3); font-weight: 700; }
.fp-dev.light.on .bg { fill: #fbbf24; stroke: #fde68a; }
.fp-dev.light.on .ic { stroke: #2a1f00; }
.fp-dev.light.on .lbl { fill: #fde68a; }
.fp-dev.plug.on .bg { fill: #34d399; stroke: #a7f3d0; }
.fp-dev.plug.on .ic { stroke: #032619; }
.fp-dev.plug.on .lbl { fill: #a7f3d0; }
.fp-dev.plug.on .val { fill: #6ee7b7; }
.fp-dev.pc.on .bg { fill: #60a5fa; stroke: #bfdbfe; }
.fp-dev.pc.on .ic { stroke: #061a33; }
.fp-dev.pc.on .lbl { fill: #bfdbfe; }
.fp-dev.dead { opacity: .45; }
.fp-dev.dead .bg { stroke-dasharray: 4 3; }
.fp-dev.critical .ring { fill: none; stroke: rgba(248,113,113,.75); stroke-width: 2; stroke-dasharray: 3 3; }
.fp-dev.pending { -webkit-animation: fp-pulse 0.9s ease-in-out infinite; animation: fp-pulse 0.9s ease-in-out infinite; }
.fp-dev.selected .bg { stroke: #fff; stroke-width: 3; }
.fp-glow { opacity: 0; -webkit-transition: opacity .25s; transition: opacity .25s; pointer-events: none; }
.fp-dev.light.on .fp-glow { opacity: 1; }
@-webkit-keyframes fp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes fp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.fp-handle { fill: #fff; stroke: var(--violet); stroke-width: 2; cursor: move; }
.fp-handle.active { fill: var(--violet); }
.fp-mid { fill: var(--violet); fill-opacity: .55; stroke: #fff; stroke-width: 1.5; cursor: copy; }
.fp-draft { fill: rgba(167,139,250,.12); stroke: var(--violet); stroke-width: 2; stroke-dasharray: 6 4; }
.fp-draft-point { fill: var(--violet); }
.fp-panel { margin-top: 12px; }
.fp-palette { display: flex; flex-wrap: wrap; margin: -3px 0; }
.fp-palette .chip .kind { margin-right: 6px; }
.swatches { display: flex; flex-wrap: wrap; margin: -4px 0; }
.swatch { width: 38px; height: 38px; border-radius: 11px; margin: 4px 8px 4px 0; border: 2px solid transparent; }
.swatch.active { border-color: #fff; }
.swatch.c-blue { background: #4da3ff; } .swatch.c-teal { background: #2dd4bf; } .swatch.c-green { background: #34d399; }
.swatch.c-amber { background: #fbbf24; } .swatch.c-rose { background: #fb7185; } .swatch.c-violet { background: #a78bfa; }
.swatch.c-slate { background: #94a3b8; }
/* Handy: Raumleiste ueber dem Plan (waagrecht wischbar) + Raumansicht */
.fp-roomnav { display: flex; align-items: center; margin: 0 0 10px; }
.fp-roomnav .rooms { display: flex; flex: 1 1 auto; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
                     scrollbar-width: none; }
.fp-roomnav .rooms::-webkit-scrollbar { display: none; }
.fp-roomnav .chip { flex: 0 0 auto; min-height: 38px; font-size: 14.5px; }
.fp-roomnav .chip.home { margin-right: 8px; }
.fp-roomcard { margin-top: 12px; }
.fp-roomtiles { margin-top: 12px; }
.fp-roomtiles .tile .sub { visibility: hidden; }   /* Raum steht schon darueber */
.room-open { -webkit-appearance: none; appearance: none; display: block; flex: 1 1 auto; min-width: 0; margin: 0; padding: 4px 0;
             border: 0; background: none; color: inherit; font: inherit; text-align: left; touch-action: manipulation; cursor: pointer; }
.room-open .rname:after { content: "  ›"; color: var(--text-3); font-weight: 700; }
.room-open:active .rname { color: var(--accent); }
.room-rows .room-row { display: flex; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.room-rows .room-row:first-child { border-top: 0; }
.room-row .rname { font-weight: 650; font-size: 15.5px; }
.room-row .rinfo { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.room-row .rinfo.lit { color: var(--warn); }
.room-row .btns { margin-left: auto; flex-wrap: nowrap; }

/* ----------------------------------------------------------- Listen ------ */
.rows > .r { display: flex; align-items: center; padding: 11px 0; border-top: 1px solid var(--line-soft); font-size: 14.5px; }
.rows > .r:first-child { border-top: 0; }
.rows .r .k { color: var(--text-3); }
.rows .r .v { margin-left: auto; font-weight: 650; text-align: right; overflow-wrap: anywhere; padding-left: 12px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); margin-right: 10px; flex: 0 0 auto; }
.dot.on { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--danger); }

.svc { display: flex; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.svc:first-child { border-top: 0; }
.svc .body { flex: 1 1 auto; min-width: 0; }
.svc .label { font-weight: 650; font-size: 15.5px; }
.svc .desc { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.svc .actions { flex: 0 0 auto; margin-left: 10px; }

.audit .r .ev { font-weight: 650; }
.audit .r .when { font-size: 12.5px; color: var(--text-3); min-width: 118px; }
.audit .r .who { font-size: 13px; color: var(--text-3); margin-left: auto; text-align: right; padding-left: 10px; }
.audit .r.bad .ev { color: #fdb0b0; }
.audit .r.good .ev { color: #93f0cc; }

/* ----------------------------------------------------------- Kameras ----- */
.cam-media { position: relative; background: #000; border-radius: 13px; overflow: hidden; margin-bottom: 12px; }
.cam-media img { display: block; width: 100%; height: auto; min-height: 120px; }
.cam-tag { position: absolute; left: 10px; top: 10px; padding: 4px 10px; border-radius: 8px;
           background: rgba(10,13,18,.78); font-size: 13px; font-weight: 650; }
.hist-row { display: flex; align-items: center; padding: 8px 0; font-size: 14px; color: var(--text-2);
            border-top: 1px solid var(--line-soft); }
.hist-row:first-child { border-top: 0; }
.hist-row .t { margin-left: auto; color: var(--text-3); font-size: 13px; }
.hist-row.clip { color: var(--text); }
.hist-row .play { margin-left: 10px; }

/* ---------------------------------------------------------- Energie ------ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); grid-gap: 14px; }
.kpi .lab { font-size: 12px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.kpi .val { font-size: 28px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 15px; font-weight: 650; color: var(--text-2); margin-left: 3px; }
.kpi .note2 { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.kpi .note2 b { color: var(--text-2); }
.kpi.accent .val { color: var(--accent); }
.kpi.warn .val { color: var(--warn); }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; }
.chart-empty { padding: 34px 10px; text-align: center; color: var(--text-3); font-size: 14px; }
.axis-line { stroke: var(--line); stroke-width: 1; }
.grid-line { stroke: var(--line-soft); stroke-width: 1; }
.axis-text { fill: var(--text-3); font-size: 10.5px; }
.chart-crosshair { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart-hit { fill: transparent; }
.chart-tip { position: absolute; top: 6px; left: 0; pointer-events: none; z-index: 5; min-width: 150px;
             background: rgba(11,15,21,.96); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
             font-size: 12.5px; opacity: 0; -webkit-transition: opacity .1s; transition: opacity .1s; }
.chart-tip.show { opacity: 1; }
.chart-tip .tt { color: var(--text-3); font-size: 12px; margin-bottom: 4px; }
.chart-tip .tr { display: flex; align-items: center; padding: 1px 0; }
.chart-tip .tr b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.chart-tip .tr.sum { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 7px; flex: 0 0 auto; }
.sw.c0 { background: #4da3ff; } .sw.c1 { background: #34d399; } .sw.c2 { background: #fbbf24; } .sw.c3 { background: #a78bfa; }
.sw.c4 { background: #f472b6; } .sw.c5 { background: #22d3ee; } .sw.c6 { background: #fb923c; }
.legend { display: flex; flex-wrap: wrap; margin: 10px -4px 0; }
.legend .li { display: inline-flex; align-items: center; margin: 3px 4px; padding: 5px 10px; border-radius: 9px;
              background: var(--card-2); border: 1px solid transparent; font-size: 13px; color: var(--text-2); touch-action: manipulation; }
.legend .li b { margin-left: 6px; color: var(--text); }
.legend .li.off { opacity: .4; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
table.data th { text-align: right; font-weight: 700; color: var(--text-3); font-size: 11.5px; text-transform: uppercase;
                letter-spacing: .05em; padding: 0 8px 8px; white-space: nowrap; }
table.data td { text-align: right; padding: 9px 8px; border-top: 1px solid var(--line-soft); white-space: nowrap;
                font-variant-numeric: tabular-nums; }
table.data th:first-child, table.data td:first-child { text-align: left; padding-left: 0; }
table.data tfoot td { font-weight: 750; border-top: 1px solid var(--line); }
.bar { height: 6px; border-radius: 3px; background: var(--card-3); overflow: hidden; margin-top: 4px; min-width: 70px; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar i.c0 { background: #4da3ff; } .bar i.c1 { background: #34d399; } .bar i.c2 { background: #fbbf24; } .bar i.c3 { background: #a78bfa; }
.bar i.c4 { background: #f472b6; } .bar i.c5 { background: #22d3ee; } .bar i.c6 { background: #fb923c; }
.bar i.warn { background: var(--warn); } .bar i.bad { background: var(--danger); }
.input.date { width: 172px; min-height: 36px; padding: 5px 10px; margin: 4px 8px 4px 0; }
.price { display: inline-flex; align-items: center; font-size: 13px; color: var(--text-3); margin-left: 6px; }
.price .input { width: 84px; min-height: 36px; padding: 6px 10px; margin: 0 6px; text-align: right; }

/* ---------------------------------------------------------- System ------- */
.guest { padding: 12px 14px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); }
.guest .gh { display: flex; align-items: center; font-weight: 650; }
.guest .gh .id { color: var(--text-3); font-size: 12.5px; margin-right: 8px; }
.guest .gh .kind { margin-left: auto; font-size: 11px; color: var(--text-3); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.guest .gs { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-3); margin-top: 8px; }
.guest.stopped { opacity: .55; }

/* ---------------------------------------------------------- Dialoge ------ */
.dialog-layer { position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 80; display: flex; align-items: center;
                justify-content: center; padding: 18px; background: rgba(4,6,10,.72); }
.dialog { width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
          background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px;
          box-shadow: 0 30px 70px -20px rgba(0,0,0,.9); }
.dialog.wide { max-width: 720px; }
.dialog h3 { margin: 0 0 8px; font-size: 19px; }
.dialog .dtext { color: var(--text-2); font-size: 15px; line-height: 1.55; margin-bottom: 16px; }
.dialog .dbtns { display: flex; flex-wrap: wrap; justify-content: flex-end; margin: 6px -8px -4px 0; }
.dialog h3 .dsub { display: block; font-size: 13px; font-weight: 600; color: var(--text-3); margin-top: 2px; }

/* ------------------------------------------------- Lampe einstellen ------ */
.lsheet .lrow { display: flex; align-items: baseline; margin: 16px 0 4px; }
.lsheet .lrow:first-child { margin-top: 6px; }
.lsheet .ltitle { font-size: 12.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.lsheet .lval { margin-left: auto; font-size: 17px; font-variant-numeric: tabular-nums; }
.lsheet .lquick { margin-top: 6px; }
.lsheet .lscale { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); }
.lsheet .lfoot { margin-top: 18px; }
.lcolors { display: flex; flex-wrap: wrap; margin: 2px -5px 0; }
.lcolor { -webkit-appearance: none; appearance: none; width: 42px; height: 42px; margin: 5px; padding: 0; border-radius: 50%;
          border: 2px solid rgba(255,255,255,.18); touch-action: manipulation; cursor: pointer; }
.lcolor.active { border-color: #fff; box-shadow: 0 0 0 3px rgba(77,163,255,.7); }
.lcolor.c-red { background: #ff3b30; } .lcolor.c-orange { background: #ff9500; } .lcolor.c-yellow { background: #ffd60a; }
.lcolor.c-green { background: #30d158; } .lcolor.c-cyan { background: #40e0d0; } .lcolor.c-blue { background: #0a84ff; }
.lcolor.c-purple { background: #bf5af2; } .lcolor.c-pink { background: #ff6fb5; } .lcolor.c-white { background: #f5f5f0; }
/* Regler mit grosser Griffflaeche. Jede Browser-Variante als eigene Regel: ein
   unbekanntes Pseudo-Element in einer Selektorliste machte die ganze Regel ungueltig. */
.range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 44px; margin: 0;
         background: transparent; touch-action: manipulation; cursor: pointer; }
.range:focus { outline: none; }
.range::-webkit-slider-runnable-track { height: 14px; border-radius: 7px; background: var(--card-3); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; margin-top: -9px; border-radius: 50%;
                               background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.55); }
.range::-moz-range-track { height: 14px; border-radius: 7px; background: var(--card-3); }
.range::-moz-range-thumb { width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 0; }
.range.bri::-webkit-slider-runnable-track { background: linear-gradient(90deg, #3b3322, #fbbf24); }
.range.bri::-moz-range-track { background: linear-gradient(90deg, #3b3322, #fbbf24); }
.range.ct::-webkit-slider-runnable-track { background: linear-gradient(90deg, #ff9f43, #fff3dc, #cfe3ff); }
.range.ct::-moz-range-track { background: linear-gradient(90deg, #ff9f43, #fff3dc, #cfe3ff); }

.clip-layer { position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 90; background: rgba(0,0,0,.94);
              display: flex; align-items: center; justify-content: center; }
.clip-layer img { max-width: 96vw; max-height: 86vh; border-radius: 10px; }
.clip-layer .close { position: absolute; top: 16px; top: calc(16px + env(safe-area-inset-top)); right: 16px;
                     width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--card-2); font-size: 22px; }

.toast { position: fixed; left: 50%; bottom: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100;
         -webkit-transform: translate(-50%, 220%); transform: translate(-50%, 220%);
         -webkit-transition: -webkit-transform .25s; transition: transform .25s;
         max-width: 92%; padding: 13px 22px; border-radius: 999px; text-align: center;
         background: var(--card-2); border: 1px solid var(--line); font-weight: 650; font-size: 15px;
         box-shadow: 0 14px 34px -12px rgba(0,0,0,.9); }
.toast.show { -webkit-transform: translate(-50%, 0); transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(52,211,153,.55); color: #93f0cc; }
.toast.err { border-color: rgba(248,113,113,.55); color: #fdb0b0; }

@media (max-width: 700px) {
  .topbar { padding-left: 14px; padding-right: 14px; }
  .topbar h1 { font-size: 18px; }
  .pill.power, .pill.conn .txt { display: none; }
  .page { padding: 14px 14px 60px; }
  .tabs { padding-left: 10px; padding-right: 10px; }
  .grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); grid-gap: 10px; }
  /* Einstellfenster als Blatt von unten (Daumenreichweite) */
  .dialog-layer.sheet { align-items: flex-end; padding: 0; }
  .dialog-layer.sheet .dialog { max-width: none; max-height: 88vh; border-radius: 22px 22px 0 0;
                                padding-bottom: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  /* Werkzeugzeile in eine Zeile, damit der geoeffnete Raum samt Kacheln ins Bild passt */
  .fp-toolbar .btn.sm { padding: 6px 10px; margin-right: 6px; font-size: 13.5px; }
  .fp-toolbar .btn .ico { margin-right: 5px; font-size: 15px; }
  /* Grundriss randlos: jede Bildschirmbreite zaehlt fuer die Groesse des Plans */
  .fp-stage { width: auto; margin-left: -14px; margin-right: -14px; border-radius: 0; border-left: 0; border-right: 0; }
  .tile { padding: 13px 13px 42px; }
  .tile .state { left: 13px; } .tile .watt { right: 13px; }
  .menu-tile { min-height: 190px; padding: 24px 22px; }
  .menu-tile .label { font-size: 24px; }
  .kpi .val { font-size: 24px; }
}
