:root {
  --bg: #0f1216; --panel: #171c22; --tile: #1d232b; --tileOn: #243447; --line: #2a313a; --fg: #e8eaed;
  --muted: #9aa3ad; --accent: #2f81f7; --on: #f5b83d; --ok: #3fb950; --warn: #f0883e; --bad: #f85149;
  --navW: 220px; --gap: 12px; --radius: 18px;
  --safeB: env(safe-area-inset-bottom, 0px); --safeT: env(safe-area-inset-top, 0px);
  color-scheme: dark;
  /* chart series (fixed order, steps for the dark surface) */
  --c1: #338ced; --c2: #e76624; --c3: #00a888; --c4: #d28e05; --c5: #e24d8b; --c6: #0aac23; --c7: #9887ef; --c8: #eb6263;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f5; --panel: #ffffff; --tile: #ffffff; --tileOn: #fff4d6; --line: #d8dde4; --fg: #1f2328;
  --muted: #6b7280; --accent: #1f6feb; --on: #d18d00;
  --c1: #257de0; --c2: #f47230; --c3: #00b894; --c4: #f2a600; --c5: #ee7fac; --c6: #008a17; --c7: #6a4ce2; --c8: #ec4647;
}
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    color-scheme: light;
    --bg: #eef1f5; --panel: #ffffff; --tile: #ffffff; --tileOn: #fff4d6; --line: #d8dde4; --fg: #1f2328;
    --muted: #6b7280; --accent: #1f6feb; --on: #d18d00;
  --c1: #257de0; --c2: #f47230; --c3: #00b894; --c4: #f2a600; --c5: #ee7fac; --c6: #008a17; --c7: #6a4ce2; --c8: #ec4647;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; background: var(--tile); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; }
.iconbtn { background: none; border: none; padding: 6px; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.ic { width: 24px; height: 24px; flex: none; }
[hidden] { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--muted); }

#app { display: grid; height: 100%; grid-template-columns: var(--navW) 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "top top" "edit edit" "nav main"; }
#top { grid-area: top; min-width: 0; display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safeT)) 16px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
#titleBox { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
#title { flex: none; }
#title { font-size: 20px; font-weight: 700; white-space: nowrap; }
#pageTitle { color: var(--muted); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dndMark { font-size: 18px; }
#clock { font-size: 22px; font-variant-numeric: tabular-nums; color: var(--muted); }
#hvals { flex: 0 1 auto; min-width: 0; display: flex; gap: 14px; align-items: baseline; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
#hvals .hv[hidden] { display: none; }
#hvals .hv { font-size: 18px; font-weight: 600; }
#hvals .hv small { font-size: 12px; font-weight: 400; color: var(--muted); margin-right: 4px; }
#conn { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
#conn.ok { background: var(--ok); }
#editBar { grid-area: edit; display: flex; gap: 8px; align-items: center; padding: 8px 16px; background: #3a2f12; color: #ffe2a3; flex-wrap: wrap; }
html[data-theme="light"] #editBar { background: #fff1c7; color: #6b4e00; }
#nav { grid-area: nav; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 4px; }
#nav .navitem { display: flex; align-items: center; gap: 12px; padding: 12px 12px; border-radius: 12px; border: none; background: none; text-align: left; width: 100%; font-size: 16px; }
#nav .navitem.active { background: var(--tileOn); color: var(--on); font-weight: 600; }
#nav .navitem .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nav .navitem .cfg { opacity: .7; padding: 2px; }
#nav .navadd { color: var(--accent); }
#main { grid-area: main; min-width: 0; overflow-y: auto; padding: 16px; padding-bottom: calc(16px + var(--safeB)); }

#app.nonav { grid-template-columns: 1fr; grid-template-areas: "top" "edit" "main"; }
/* optional split screen (touch PC): panels on the right */
#app.split { grid-template-columns: var(--navW) minmax(0, 1fr) minmax(360px, 42%); grid-template-areas: "top top top" "edit edit edit" "nav main side"; }
#app.split.nonav { grid-template-columns: minmax(0, 1fr) minmax(360px, 45%); grid-template-areas: "top top" "edit edit" "main side"; }
#side { grid-area: side; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.sidebox { flex: 1; min-height: 0; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
.sidebox:last-child { border-bottom: none; }
.sidetabs { display: flex; overflow-x: auto; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.sidetabs button { flex: 1; min-width: 110px; border: none; border-radius: 0; background: none; padding: 12px 10px; font-size: 16px; white-space: nowrap; color: var(--muted); }
.sidetabs button.active { color: var(--fg); background: var(--tile); box-shadow: inset 0 -3px 0 var(--accent); }
.sidecontent { flex: 1; overflow-y: auto; padding: 12px; min-height: 0; }
.sidecontent .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.sidecontent .planwrap { max-height: none; }
.sidecontent .tile.camera { grid-column: 1 / -1; height: auto; aspect-ratio: 16 / 9; }
#backBtn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px 6px 4px; }
#backBtn .ic { width: 22px; height: 22px; }
#clock { white-space: pre; }

/* menu button tile (page link) */
.tile.page { justify-content: space-between; }
.tile.page .pname { font-size: 17px; line-height: 1.25; }
.tile.page .pic { align-self: flex-end; color: var(--fg); }
.tile.page .pic .ic { width: 46px; height: 46px; stroke-width: 1.4; }

/* several values in one tile */
.tile.multirow .mhead { display: flex; align-items: center; gap: 8px; }
.tile.multirow .mhead .tic .ic { width: 24px; height: 24px; }
.mlabel { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrows { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.mrow { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; border-bottom: 1px solid var(--line); padding: 2px 0; }
.mrow:last-child { border-bottom: none; }
.mrow span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow b { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheetrows .mrow { font-size: 18px; padding: 10px 0; }

/* list page */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--tile); }
.lrow { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--line); position: relative; }
.lrow:last-child { border-bottom: none; }
.lrow.heading { min-height: 0; padding: 14px 14px 6px; background: var(--bg); color: var(--muted); font-weight: 600; font-size: 16px; }
.lrow .lic { color: var(--muted); display: flex; }
.lrow.on .lic { color: var(--on); }
.lrow.alert .lic, .lrow.alert .lval { color: var(--bad); }
.lrow .lname { flex: 1; min-width: 0; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .lctl { display: flex; align-items: center; gap: 6px; flex: none; }
.lrow .lctl button { min-width: 64px; height: 44px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; font-weight: 600; }
.lrow .lctl button.lon { background: #6b8f12; border-color: #6b8f12; color: #fff; }
.lrow .lctl button.loff { background: #9b2226; border-color: #9b2226; color: #fff; }
.lrow .lamp { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); margin: 0 8px; }
.lrow .lamp.on { border-color: var(--on); background: var(--on); box-shadow: 0 0 10px var(--on); }
.lrow .lamp.off { border-color: var(--bad); }
.lrow .lbar { width: 90px; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.lrow .lbar span { display: block; height: 100%; background: var(--fg); }
.lrow .lval { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.lrow .lval.big { font-size: 20px; font-weight: 600; }
.lrow .lsub { color: var(--muted); font-size: 13px; margin-right: 6px; }
.lrow .lmulti { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: flex-end; font-variant-numeric: tabular-nums; }
.lrow .lmulti small { color: var(--muted); }
.lrow.camera { flex-wrap: wrap; }
.lrow img.lcam { width: 100%; max-height: 260px; object-fit: contain; background: #000; border-radius: 10px; }
.lrow.addrow { justify-content: center; color: var(--muted); cursor: pointer; gap: 6px; }
.editing .lrow:not(.addrow) { outline: 2px dashed var(--accent); outline-offset: -3px; cursor: pointer; }
@media (max-width: 699px) {
  .lrow { gap: 6px 8px; padding: 6px 8px 6px 10px; flex-wrap: wrap; }
  .lrow .lname { font-size: 16px; white-space: normal; flex: 1 1 120px; }
  .lrow .lctl { margin-left: auto; }
  .lrow .lctl button { min-width: 48px; height: 42px; padding: 0 6px; }
  .lrow .lbar, .lrow .lsub { display: none; }
  .lrow .lamp { margin: 0 2px; width: 20px; height: 20px; }
  .lrow .lval { min-width: 0; }
}

/* phone: bottom tabs */
@media (max-width: 699px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; grid-template-areas: "top" "edit" "main" "nav"; }
  #backBtn:not([hidden]) ~ #titleBox #title { display: none; }
  #clock, #hvals { display: none; }
  #title { font-size: 18px; }
  #nav { flex-direction: row; border-right: none; border-top: 1px solid var(--line); padding: 4px 4px calc(4px + var(--safeB)); overflow-x: auto; overflow-y: hidden; gap: 0; }
  #nav .navitem { flex-direction: column; gap: 2px; padding: 6px 8px; min-width: 68px; font-size: 11px; text-align: center; }
  #nav .navitem .lbl { max-width: 76px; }
  #nav .navitem .cfg { display: none; }
  #main { padding: 12px; }
  .tile { padding: 10px 12px; }
  .tile .tic .ic { width: 26px; height: 26px; }
  .tile .big { font-size: 25px; }
  .tile .lbl { font-size: 14px; }
  #app.nonav { grid-template-rows: auto auto 1fr; }
  :root { --gap: 10px; --radius: 16px; }
}

/* tiles */
.grid { --th: 132px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--gap); align-items: start; }
@media (max-width: 699px) { .grid { --th: 124px; grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .grid { --th: 150px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }
.tile { height: var(--th); position: relative; background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; overflow: hidden; user-select: none; touch-action: manipulation; transition: background .15s; }
.tile.size-w { grid-column: span 2; }
.tile.size-l { grid-column: span 2; grid-row: span 2; height: calc(2 * var(--th) + var(--gap)); }
.tile.heading { grid-column: 1 / -1; height: auto; background: none; border: none; padding: 10px 4px 0; font-size: 18px; font-weight: 600; color: var(--muted); }
.grid > .tile.heading:first-child { padding-top: 0; }
.tile.tap { cursor: pointer; }
.tile.tap:active { transform: scale(.98); }
.tile.on { background: var(--tileOn); border-color: transparent; }
.tile.on .tic { color: var(--on); }
.tile.alert { border-color: var(--bad); }
.tile.alert .tic, .tile.alert .tval { color: var(--bad); }
.tile.pending { opacity: .75; }
.tile .row1 { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.tile .tic { color: var(--muted); }
.tile .tic .ic { width: 30px; height: 30px; }
.tile .tval { font-size: 15px; font-weight: 600; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .big { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .big small { font-size: 16px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.tile .lbl { margin-top: auto; font-size: 15px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile .ctl { display: flex; gap: 6px; margin-top: 8px; }
.tile .ctl button { flex: 1; padding: 6px 0; display: flex; justify-content: center; border-radius: 10px; }
.tile .ctl button .ic { width: 22px; height: 22px; }
.tile input[type=range] { width: 100%; margin: 8px 0 0; }
.tile.missing { opacity: .55; }
.tile .warnmark { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: var(--warn); }
.warnmark[data-missing] { cursor: help; padding: 4px; margin: -4px; }
.statename.missing { color: var(--bad); font-weight: 600; }

/* camera tile */
.tile.camera { padding: 0; background: #000; }
.tile.camera img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.camera .camlbl { position: absolute; left: 10px; bottom: 8px; color: #fff; text-shadow: 0 1px 3px #000; font-weight: 600; }

/* sliders */
input[type=range] { -webkit-appearance: none; appearance: none; height: 30px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px; border-radius: 50%; background: var(--fg); border: none; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
input[type=range]::-moz-range-track { height: 8px; border-radius: 4px; background: var(--line); }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--fg); border: none; }

/* floor plan */
.planwrap { position: relative; overflow: auto; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); max-height: calc(100vh - 120px); }
.plan { position: relative; margin: 0 auto; }
.plan img.planimg { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.planempty { padding: 40px 16px; text-align: center; color: var(--muted); }
.marker { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; touch-action: none; user-select: none; }
.marker .dot { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--tile); border: 2px solid var(--line); color: var(--muted); box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.marker .dot .ic { width: 24px; height: 24px; }
.marker.on .dot { background: var(--on); border-color: var(--on); color: #1b1300; box-shadow: 0 0 14px var(--on); }
.marker.alert .dot { border-color: var(--bad); color: var(--bad); }
.marker .mval { font-size: 12px; font-weight: 600; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; white-space: nowrap; }
.marker.cam .dot { color: var(--accent); }
.plantools { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
.layerbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.plantools .layerbar { margin-left: auto; }
.lchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--fg); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.lchip .ic { width: 16px; height: 16px; }
.lchip.off { border-color: var(--line); background: transparent; color: var(--muted); text-decoration: line-through; }
.lchip.off .ic { opacity: .5; }
.layerbar.small { position: absolute; top: 8px; right: 8px; z-index: 3; background: color-mix(in srgb, var(--panel) 85%, transparent); border-radius: 999px; padding: 3px; gap: 3px; }
.layerbar.small .lchip { padding: 4px; }
.layerbar.small .lchip .ic { width: 15px; height: 15px; }
/* a hidden layer still shows a marker that is in alarm (fire, intrusion, open window …) */
.marker.lhidden:not(.alert) { display: none; }
.marker.chide { display: none; }
.marker.warn .dot { border-color: var(--warn); color: var(--warn); }
.marker.alert.contact .dot, .marker.warn.contact .dot { color: #fff; }
.marker.alert.contact .dot { background: var(--bad); }
.marker.warn.contact .dot { background: var(--warn); }
.tile.warn { border-color: var(--warn); }
.tile.warn .tic, .tile.warn .tval, .tile.warn .big { color: var(--warn); }
.tile.alert.contact .big { color: var(--bad); }
.lrow.warn .lic, .lrow.warn .lval { color: var(--warn); }
.campop { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 8px 28px rgba(0,0,0,.45); pointer-events: none; }
.campop img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; display: block; background: #000; }
.campop span { display: block; font-size: 13px; padding: 5px 4px 1px; color: var(--muted); }
.editing .marker .dot { outline: 2px dashed var(--accent); outline-offset: 2px; }

/* sheet (controls of a tile in large) */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; width: min(420px, 100%); max-height: 90vh; overflow-y: auto; padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.sheet h3 { margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.sheet h3 .grow { flex: 1; }
.sheet .bigval { font-size: 40px; font-weight: 600; text-align: center; margin: 6px 0 12px; font-variant-numeric: tabular-nums; }
.sheet .row { display: flex; gap: 10px; margin: 10px 0; }
.sheet .row button { flex: 1; padding: 14px 0; display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 16px; border-radius: 14px; }
.sheet input[type=range] { width: 100%; height: 44px; }
.sheet input[type=range]::-webkit-slider-runnable-track { height: 14px; border-radius: 7px; }
.sheet input[type=range]::-webkit-slider-thumb { width: 36px; height: 36px; margin-top: -11px; }
@media (max-width: 699px) {
  .overlay.bottom { align-items: flex-end; padding: 0; }
  .overlay.bottom .sheet { border-radius: 22px 22px 0 0; width: 100%; padding-bottom: calc(18px + var(--safeB)); }
}

/* camera full screen, ring */
.camfull { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.camfull img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.camfull .bar { display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safeB)); background: #000; color: #fff; align-items: center; }
.camfull .bar .name { flex: 1; font-size: 18px; font-weight: 600; }
.camfull .bar button { background: #222; border-color: #333; color: #fff; padding: 12px 18px; font-size: 16px; }
.camfull .bar button.door { background: var(--ok); border-color: var(--ok); }
.camfull.ring .bar .name::before { content: '🔔 '; }
.camfull.ring { animation: ringpulse 1.2s ease-in-out infinite alternate; }
@keyframes ringpulse { from { box-shadow: inset 0 0 0 0 var(--on); } to { box-shadow: inset 0 0 0 6px var(--on); } }
.linkfull iframe { flex: 1; border: none; background: #fff; width: 100%; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(80px + var(--safeB)); transform: translateX(-50%); background: #333; color: #fff; padding: 10px 16px; border-radius: 12px; display: none; z-index: 100; max-width: 90vw; text-align: center; }
#toast.error { background: var(--bad); }

/* menu */
.menu .item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; margin: 6px 0; border-radius: 14px; }
.menu .hint { font-size: 13px; color: var(--muted); margin: 4px 2px 10px; }

/* editor forms */
.form label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 14px; }
.form input[type=text], .form input[type=password], .form input[type=number], .form input[type=time], .form select, .form textarea { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); font: inherit; }
.form .help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.form details.guide { margin: 10px 0 4px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(47, 129, 247, .08); font-size: 14px; }
.form details.guide summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.form details.guide ol { margin: 6px 0; padding-left: 22px; }
.form details.guide li { margin: 4px 0; }
.form details.guide p { margin: 6px 0; }
.form details.guide a { color: var(--accent); }
.form details.guide code { font-size: 12px; word-break: break-all; }
.form .staterow { display: flex; gap: 6px; }
.form .staterow input { flex: 1; min-width: 0; }
.form .staterow button { white-space: nowrap; padding: 8px 10px; }
.form .staterow .clearbtn { padding: 8px 12px; color: var(--bad); }
.form .statename { font-size: 12px; color: var(--muted); margin-top: 3px; }
.form .check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form .buttons { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.form .buttons .grow { flex: 1; }
.iconpick { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: 6px; }
.iconpick button { width: 44px; height: 44px; padding: 0; display: flex; align-items: center; justify-content: center; }
.iconpick button.sel { border-color: var(--accent); color: var(--accent); background: var(--tileOn); }
.editing .tile:not(.addtile) { outline: 2px dashed var(--accent); outline-offset: -2px; cursor: pointer; }
.addtile { border: 2px dashed var(--line); background: none; color: var(--muted); align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.rules .rule { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; }
.rules .rule .head { display: flex; gap: 8px; align-items: center; }
.sheet.wide { width: min(640px, 100%); }

/* data point picker (shared with the logic editor) */
.picker { background: var(--panel); color: var(--fg); width: min(1100px, 96vw); height: min(760px, 92vh); border-radius: 14px; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.picker button { padding: 6px 12px; }
.phead { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 15px; }
.pclose { border: none; background: none; font-size: 16px; }
.ptools { display: flex; gap: 8px; align-items: center; padding: 8px 14px; }
.ptools input[type=search] { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; }
.ptools .switch { display: flex; gap: 4px; align-items: center; white-space: nowrap; font-size: 13px; }
.ptable { flex: 1; overflow: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.prow { display: grid; grid-template-columns: minmax(200px, 2.2fr) minmax(140px, 2fr) 100px 120px minmax(70px, 1fr); gap: 8px; padding: 6px 14px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; font-size: 14px; }
@media (max-width: 699px) { .prow { grid-template-columns: minmax(150px, 1.5fr) minmax(110px, 1fr) 70px; } .prow > span:nth-child(4), .prow > span:nth-child(5) { display: none; } }
.prow > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow:hover { background: var(--tile); }
.prow.sel { background: var(--accent); color: #fff; }
.prow.sel .muted, .prow.sel .ptype, .prow.sel .prole { color: #fff; }
.prow.readonly .pseg, .prow.readonly .pname { opacity: .7; }
.phdr { position: sticky; top: 0; background: var(--panel); font-weight: 600; cursor: default; z-index: 1; }
.phdr:hover { background: var(--panel); }
.ptog { display: inline-block; width: 16px; color: var(--muted); }
.pfolder { font-weight: 600; }
.ptype, .prole { color: var(--muted); font-size: 12px; }
.pval, .pidcol { font-family: ui-monospace, monospace; font-size: 12px; }
.pmsg { padding: 16px; }
.pmsg.error { color: var(--bad); }
.pfoot { display: flex; gap: 8px; align-items: center; padding: 10px 14px; }
.pinfo { flex: 1; min-width: 0; }
.pid { font-family: ui-monospace, monospace; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* door intercom (livecam) */
.camfull.call .bar { flex-wrap: wrap; }
.camfull.call .callbtns { display: flex; gap: 10px; flex-wrap: wrap; }
.item .emo { display: inline-block; width: 22px; text-align: center; font-size: 18px; }
.camfull .callvol { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 0 16px 14px; background: #000; color: #fff; }
.camfull .callvol[hidden] { display: none; }
.camfull .callvol label { display: flex; align-items: center; gap: 10px; flex: 1 1 240px; font-size: 22px; }
.camfull .callvol input[type=range] { flex: 1; height: 36px; accent-color: var(--ok); }
.camfull .callvol b { font-size: 15px; font-weight: 600; min-width: 52px; text-align: right; }
.camfull.call .callbtns button { padding: 14px 22px; font-size: 18px; border-radius: 14px; }
.camfull.call .callbtns button.answer { background: var(--ok); border-color: var(--ok); }
.camfull.call .callbtns button.hangup { background: var(--bad); border-color: var(--bad); }
.camfull.call .callbtns button.door { background: #2f81f7; border-color: #2f81f7; }
#missedBtn { background: var(--bad); border-color: var(--bad); color: #fff; padding: 6px 12px; font-weight: 600; }
.photoview { position: fixed; inset: 0; z-index: 900; background: #000; display: flex; flex-direction: column; touch-action: none; }
.photoview img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.photoview .pvbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: rgba(0, 0, 0, .7); color: #fff; }
.photoview .pvbar .iconbtn { font-size: 28px; min-width: 52px; min-height: 52px; color: #fff; }
.photoview .pvbar .iconbtn:disabled { opacity: .3; }
.photoview .pvcap { font-size: 16px; }
.calllist img { cursor: zoom-in; }
.calllist { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.callitem { display: flex; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
.callitem img { width: 120px; height: 68px; object-fit: cover; border-radius: 8px; background: #000; flex: none; }
.callitem.missed b { color: var(--bad); }
.callitem.answered b { color: var(--ok); }
.callitem.new { border-color: var(--bad); }

/* time switches */
.tbadge { position: absolute; right: 10px; bottom: 8px; font-size: 13px; opacity: .85; pointer-events: none; }
.marker .tbadge { right: -6px; top: -6px; bottom: auto; font-size: 12px; }
.lrow .tbadge { position: static; margin-left: 4px; }
.timers .tentry.off { opacity: .55; }
.timers .days { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.timers .days button { min-width: 42px; padding: 8px 0; border-radius: 10px; }
.timers .days button.sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.timers .days select { width: auto; margin-left: 6px; padding: 7px; }
.timers .trow { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.timers .trow select, .timers .trow input[type=time] { width: auto; flex: 0 1 auto; }
.timers .trow input[type=number] { width: 90px; }
.timers .ttime { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.timers .ttime select.tpart { width: auto; min-width: 64px; }
.timers .trow.season input[type=text] { width: 5.5em; flex: none; }
.timers .trow .grow { flex: 1; }
.timers .check.cond.dis { opacity: 0.4; }
.timers .tentry { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 10px 0; background: var(--bg); }
/* room controller */
.tile .tsub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet .row.modes { flex-wrap: wrap; }
.sheet .row.modes button { flex: 1 1 40%; padding: 11px 0; font-size: 15px; }
.sheet .bigval.sm { font-size: 24px; margin: 0; align-self: center; min-width: 90px; }
.bad, .mrow b .bad { color: var(--bad); }
.mrow b .ok { color: var(--ok); }
/* users */
.sheet.login { margin: 8vh auto 0; width: min(380px, 100%); }
.sheet.login .row button { padding: 14px 0; }
.sheet.login .osktoggle { margin-top: 10px; width: 100%; padding: 10px; }
.osk { width: min(760px, 100%); margin: 10px auto 0; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.osk .oskrow { display: flex; gap: 6px; margin: 6px 0; }
.osk button { flex: 1 1 0; min-width: 0; height: 52px; font-size: 1.25rem; padding: 0; border-radius: 10px; }
.osk button.wide { flex: 1.5 1 0; }
.osk button.space { flex: 4 1 0; font-size: 0.95rem; }
.osk button.on, .osk button.enter { background: var(--accent); color: #fff; }
.twofa .qr { background: #fff; padding: 10px; border-radius: 12px; width: min(240px, 70vw); margin: 6px auto; }
.twofa .qr svg { display: block; width: 100%; height: auto; }
.twofa code.secret { user-select: all; font-size: 0.95em; word-break: break-all; }
.twofa .hint.ok, .remote .hint.ok { color: var(--ok, #4caf50); }
.remote .hint.bad { color: var(--bad); }
.remote .qr { background: #fff; padding: 10px; border-radius: 12px; width: min(220px, 70vw); margin: 6px auto; }
.remote .qr svg { display: block; width: 100%; height: auto; }
.remote code.secret { user-select: all; word-break: break-all; }
.remote a.btn { display: inline-block; padding: 10px 16px; border-radius: 10px; text-decoration: none; background: var(--accent); color: #fff; }
.remote .guide li { margin: 4px 0; }
pre.reccodes { user-select: all; background: var(--card, rgba(127,127,127,.12)); border-radius: 10px; padding: 10px 12px; font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.login button.link { background: none; border: 0; padding: 4px 0; color: var(--accent); text-decoration: underline; font-size: 13px; text-align: left; }
.users .ubox { border: 1px solid var(--line); border-radius: 14px; margin: 8px 0; overflow: hidden; }
.users .uhead { display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer; }
.users .uhead small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.users .uhead .chev { color: var(--muted); font-size: 12px; }
.users .ubody { padding: 0 12px 8px; border-top: 1px solid var(--line); }
.users .pagelist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 10px; }
.users .buttons { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.users .buttons .grow { flex: 1; }
.form .chanrow { display: flex; gap: 16px; flex-wrap: wrap; }
/* HTML display (e.g. a table from a script) */
.tile.html { grid-column: 1 / -1; height: auto; min-height: 60px; overflow: visible; max-width: 720px; }
.tile.html.size-l { max-width: none; }
.tile.html.size-w { grid-column: span 2; }
.tile.html.size-l { grid-column: 1 / -1; grid-row: auto; height: auto; }
.tile.html .hlabel, .lrow .hlabel { font-weight: 600; margin-bottom: 8px; }
.tile.html .htmlhost { overflow-x: auto; }
.lrow.htmlrow { display: block; }
.sheet .sheethtml { overflow-x: auto; }
/* window overview */
.tile.windows, .tile.appliances { grid-column: 1 / -1; height: auto; overflow: visible; }
.tile.appliances.size-w { grid-column: span 2; }
.tile.waste { grid-column: span 2; height: auto; overflow: visible; }
.tile.waste.size-l { grid-column: 1 / -1; }
.lrow.waste.htmlrow { display: block; }
.tile.appliances.size-l { grid-row: auto; height: auto; }
.lrow.appliances.htmlrow { display: block; }
/* household appliances: off = quiet, running = like "on", finished = orange until tapped */
.win.app.off, .win.app.unknown { background: none; border-color: var(--line); }
.win.app.off .wic, .win.app.unknown .wic { color: var(--muted); }
.win.app.run { background: var(--tileOn); border-color: var(--on); }
.win.app.run .wic { color: var(--on); }
.win.app.done { background: rgba(240, 136, 62, .22); border-color: var(--warn); border-width: 2px; cursor: pointer; }
.win.app.done .wic, .win.app.done .wst { color: var(--warn); font-weight: 600; }
.win.app .wname { flex: 1; }
.tile.windows.size-w { grid-column: span 2; }
.tile.windows.size-l { grid-row: auto; height: auto; }
.lrow.windows.htmlrow { display: block; }
.whead { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 8px; }
.whead .grow { flex: 1; }
.wsum { font-size: 14px; color: var(--ok); }
.wsum.bad { color: var(--bad); }
.wsum.warn { color: var(--warn); }
.wblim { color: var(--warn) !important; font-weight: 600; }
.wlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); gap: 6px; }
.win { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(63, 185, 80, .16); border: 1px solid rgba(63, 185, 80, .5); }
.win.open { background: rgba(248, 81, 73, .2); border-color: var(--bad); }
.win.tilt { background: rgba(240, 136, 62, .2); border-color: var(--warn); }
.win.unknown { background: none; border-color: var(--line); opacity: .7; }
.win .wic { color: var(--ok); display: flex; }
.win.open .wic { color: var(--bad); }
.win.tilt .wic { color: var(--warn); }
.wsum.onc { color: var(--on); }
.wastelist { display: flex; flex-direction: column; gap: 4px; }
.wday { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, .04); }
.wday.tomorrow, .wday.today { background: rgba(245, 184, 61, .16); border: 1px solid rgba(245, 184, 61, .5); }
.wday .wdate { min-width: 5.6em; font-weight: 600; white-space: nowrap; }
.wday.today .wdate, .wday.tomorrow .wdate { color: var(--on); }
.wday .witems { display: flex; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.wbin { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.wbin i { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid rgba(255, 255, 255, .35); }
.wbin small { color: var(--muted); }
.wasteerr { margin-top: 6px; font-size: 13px; color: var(--warn); }
.win.open.calm { background: var(--tileOn); border-color: var(--on); }
.win.open.calm .wic { color: var(--on); }
.win .wname { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win .wst { margin-left: auto; text-align: right; font-size: 14px; white-space: nowrap; }
.win .wst small { display: block; color: var(--muted); font-size: 12px; }
.winsheet .wlist { grid-template-columns: 1fr; }
.win .wname small.wdetail { display: block; font-weight: 400; font-size: 13px; color: var(--muted); white-space: normal; }
.win.long, .win.warnnow { background: rgba(248, 81, 73, .32); border-color: var(--bad); border-width: 2px; }
.win.long .wst small { color: var(--bad); font-weight: 600; }
.wwarn { font-size: 13px; font-weight: 700; color: #fff; background: var(--bad); border-radius: 8px; padding: 2px 8px; margin-right: 8px; }
.win .wic .ic { width: 30px; height: 30px; }

/* edit mode: move tiles / list rows by dragging */
.editing .tile:not(.addtile), .editing .lrow:not(.addrow) { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.list.sorting { overflow: visible; }
.dragging { position: relative; z-index: 50; pointer-events: none; opacity: .85; box-shadow: 0 12px 30px rgba(0,0,0,.45); transition: none !important; }
.hkbox { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.hkimport { width: 100%; margin-bottom: 6px; }

/* energy flow (energie adapter) */
.tile.energy { grid-column: span 2; height: auto; min-height: 120px; overflow: visible; max-width: 560px; }
.tile.energy.size-l { grid-column: 1 / -1; grid-row: auto; height: auto; max-width: 820px; }
.tile.energy .eflow { max-width: 440px; margin: 0 auto; width: 100%; }
.tile.energy .estats { margin-top: 8px; }
.lrow.energy .eflow { max-width: 420px; margin: 0 auto; }
.sheet.energy { width: min(1000px, 100%); }
.sheet.energy .egrid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 820px) { .sheet.energy .egrid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }
.sheet.energy .echead { display: flex; align-items: center; gap: 6px; margin: 14px 0 4px; }
.sheet.energy .iconbtn:disabled { opacity: .3; }
:root { --ef-fg: var(--fg); --ef-muted: var(--muted); --ef-node: var(--bg); --ef-line: var(--line); --ef-accent: var(--accent); }

/* floor plan: symbol size per page */
.plan.ms-xs .marker .dot { width: 24px; height: 24px; border-width: 1.5px; }
.plan.ms-xs .marker .dot .ic { width: 14px; height: 14px; }
.plan.ms-xs .marker .mval { font-size: 9px; padding: 0 3px; border-radius: 5px; }
.plan.ms-s .marker .dot { width: 32px; height: 32px; }
.plan.ms-s .marker .dot .ic { width: 18px; height: 18px; }
.plan.ms-s .marker .mval { font-size: 10px; padding: 0 4px; }
.plan.ms-l .marker .dot { width: 58px; height: 58px; }
.plan.ms-l .marker .dot .ic { width: 32px; height: 32px; }
.plan.ms-l .marker .mval { font-size: 14px; }
.iconpick .sel .ic { transform: rotate(var(--rot, 0deg)); }
.ic { transition: transform .15s; }

/* free grid: tiles at fixed cells, empty cells allowed */
.list.fit { margin: 0 auto; }
.grid.fit { --th: 150px; margin: 0 auto; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); max-width: none; }
.grid.free { grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); grid-auto-rows: minmax(var(--th), auto); }
.grid.free > .tile { max-width: none; }
.grid.free > .tile:not(.size-l):not(.html):not(.windows):not(.energy) { height: var(--th); }
.grid.free > .cell { border: 2px dashed var(--line); border-radius: var(--radius); min-height: var(--th); opacity: .45; }
.grid.free > .cell.over, .grid.free > .tile.over { opacity: 1; border-color: var(--accent); outline: 2px solid var(--accent); }
.tile.energy.eonly { max-width: none; }
.tile.energy .echart { width: 100%; }
.tile.energy .echart .ef-chart { max-height: 300px; }

/* edit mode: grip to move a tile (works at once with finger and mouse) */
.dragh { position: absolute; top: 6px; right: 6px; z-index: 3; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--accent); color: #fff; font-size: 22px; line-height: 1; cursor: grab; touch-action: none; user-select: none; opacity: .9; }
.lrow { position: relative; }
.lrow .dragh { top: 50%; transform: translateY(-50%); left: 8px; right: auto; }
.editing .lrow:not(.addrow) { padding-left: 54px; }
.dragging .dragh { cursor: grabbing; }
/* edit mode: controls and pictures inside tiles do not catch the mouse - the whole tile is dragged or edited */
.editing .tile:not(.addtile) input, .editing .tile:not(.addtile) button, .editing .tile img, .editing .tile .ef-flow,
.editing .lrow input, .editing .lrow button, .editing .lrow img { pointer-events: none; }
.editing .tile img, .editing .lrow img { -webkit-user-drag: none; user-select: none; }
.rule .andbox { border-left: 3px solid var(--accent); padding-left: 10px; margin: 4px 0 6px; }

/* size grip (edit mode, bottom right) */
.sizeh { position: absolute; right: 4px; bottom: 4px; z-index: 3; width: 30px; height: 30px; display: flex; align-items: flex-end; justify-content: flex-end;
  color: var(--accent); font-size: 20px; line-height: 1; cursor: nwse-resize; touch-action: none; user-select: none; }
.tile.resizing { outline: 2px solid var(--accent); z-index: 5; }
/* floor plan as a tile */
.tile.planview { height: auto; overflow: hidden; padding: 10px; }
.tile.planview .pvbox { flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; }
.tile.planview .plan { position: relative; width: 100%; }
.tile.planview .planimg { width: 100%; display: block; border-radius: 10px; }
.editing .tile.planview .marker { pointer-events: none; }
.tile.planview[style*='height: calc'] .pvbox { overflow: hidden; }

.wintable { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; align-items: center; padding: 6px 10px; border-left: 3px solid var(--accent); margin: 4px 0 8px; }

.tile .circsw { display: flex; align-items: center; gap: 4px; margin-top: auto; }
.tile .circsw span { flex: 1; min-width: 0; text-align: center; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .circsw button { width: 30px; height: 26px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--fg); font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }
.sheet .circs { flex-wrap: wrap; margin-bottom: 6px; }

/* content tiles with an own height: fixed, content scrolls or is scaled */
.tile.fixh { overflow: hidden !important; display: flex; flex-direction: column; }
.tile.fixh .wastelist, .tile.fixh .htmlhost, .tile.fixh .wlist, .tile.appliances.fixh .wlist { flex: 1; min-height: 0; overflow: auto; }
.tile.energy.fixh .eflow { flex: 1; min-height: 0; max-width: none; display: flex; justify-content: center; }
.tile.energy.fixh .eflow svg { width: 100%; height: 100%; max-height: 100%; display: block; }
.tile.energy.fixh .echart { flex: 1; min-height: 0; }

/* screen off (touch PC): black above everything, the first touch only wakes */
.screenoff { position: fixed; inset: 0; z-index: 1000; background: #000; cursor: none; }

/* PIN pad */
.pinov { z-index: 1100; }
.pinpad { max-width: 320px; margin: auto; }
.pindots { text-align: center; font-size: 28px; letter-spacing: 8px; min-height: 40px; margin: 6px 0 12px; }
.pinkeys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinkeys button { font-size: 24px; padding: 14px 0; border-radius: 14px; }
/* alarm system */
.alarmtxt { color: var(--bad) !important; font-weight: 700; animation: alarmblink 1s steps(2, start) infinite; }
@keyframes alarmblink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .alarmtxt { animation: none; } }
.pinmark { position: absolute; right: 10px; bottom: 10px; display: flex; opacity: .55; pointer-events: none; }
.pinmark .ic { width: 16px; height: 16px; }
.tile.alarm .big { font-size: 22px; line-height: 1.15; white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.okline { color: var(--ok) !important; }
.tile.alarm .tsub { white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12px; }
.dethead { margin: 14px 0 4px; font-size: 14px; color: var(--muted); font-weight: 600; }
.detlist { max-height: 42vh; overflow: auto; }
.mrow.det { align-items: center; gap: 10px; }
.mrow.det > span { flex: 1; }
.mrow.det button { padding: 6px 10px; font-size: 13px; }
.mrow.det.off > span { opacity: .7; }
.warnc, .mrow b .warnc { color: var(--warn); }

/* alarm sheet: open detectors on top, highlighted */
.mrow.det.open { background: rgba(248, 81, 73, .14); border-radius: 8px; }

/* appliances: shrink to fit an own tile height (fitApps) */
.tile.appliances.c1 .whead { margin-bottom: 4px; }
.tile.appliances.c1 .wlist { gap: 4px; }
.tile.appliances.c1 .win.app { padding: 4px 8px; gap: 8px; }
.tile.appliances.c1 .win.app .wic .ic { width: 22px; height: 22px; }
.tile.appliances.c2 .win.app .wst small { display: none; }
.tile.appliances.c3 .wlist { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow-x: hidden; }
.tile.appliances .win.app { min-width: 0; }
.tile.appliances .win.app .wname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.appliances.c3 .win.app { padding: 3px 6px; gap: 6px; }
.tile.appliances.c3 .win.app .wname { font-size: 13px; }

/* color light: presets in the sheet, rainbow symbol while the color changer runs */
.cpresets { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.cpresets .cpre { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; }
.cpresets .cpre.active { outline: 2px solid var(--accent, #4a9eff); }
.cdot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, .5); flex: none; }
.cown { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.cown input[type=color] { width: 48px; height: 34px; border: none; background: none; padding: 0; }
.tic.cfx { animation: cfx 6s linear infinite; }
@keyframes cfx { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(360deg); } }

/* robot: buttons, work areas, map (adapter page, map image or GPS on an own picture) */
.robbtns { flex-wrap: wrap; }
.robareas { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.robmap { position: relative; margin-top: 12px; }
.robmap iframe { width: 100%; height: min(60vh, 520px); border: 0; border-radius: 12px; background: #000; }
.robmap .robimg { display: block; width: 100%; height: auto; border-radius: 12px; }
.robmap .btnlink { display: inline-block; margin-top: 6px; color: var(--accent); }
.robmap .hint { color: var(--muted); font-size: 13px; }
.robmap.gps .robtrack { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.robmap.gps .robtrack polyline { fill: none; stroke: #ffd54a; stroke-width: 2px; vector-effect: non-scaling-stroke; opacity: .85; }
.robmap.gps .robdot { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px rgba(255, 255, 255, .8); }
.robmap.gps .robdot .ic { width: 18px; height: 18px; }
.bigval.bad, .tsub.bad, .lval.bad { color: var(--bad); }
.tsub.warn, .lsub.warn, .warntxt { color: var(--warn); }
.robmap.calib { cursor: crosshair; margin-top: 8px; }
.robmap.calib .robdot { font-weight: 700; font-size: 14px; }
.robzones { margin: 8px 0; }
.robzones .mrow button { padding: 4px 12px; min-width: 70px; }
.robwarn { color: var(--bad); text-align: center; margin: -4px 0 10px; font-weight: 600; }
.tile .pend { font-size: 12px; color: var(--accent); margin-top: 2px; }

/* car: charge level bar, target mark */
.carbar { position: relative; height: 6px; border-radius: 3px; background: rgba(128, 128, 128, .25); margin: 4px 0 2px; overflow: hidden; }
.carbar span { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.carbar.big { height: 12px; border-radius: 6px; margin: 0 0 12px; overflow: visible; }
.carbar.big i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text, #ddd); }
.tile .tsub.wbcar { color: var(--ok); }
.wbcarbtn { width: 100%; }

/* push button switch (sendMode push): pressed while held */
[data-push] { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tile[data-push].pressed, .marker[data-push].pressed, button[data-push].pressed { filter: brightness(1.25); transform: scale(0.97); }
.sheet .hint { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }

/* several entries in one tile (central functions, scenes) */
.entries { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; max-height: 60vh; overflow-y: auto; }
.entry { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--tile); border: 1px solid var(--line); }
.entry.on { background: var(--tileOn); }
.entry .ename { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.entry .ename small { color: var(--muted); font-size: 12px; }
.entry .ebtns { display: flex; gap: 6px; flex-shrink: 0; }
.entry .ebtns button { min-width: 52px; padding: 8px 10px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.entry .ebtns button svg { width: 20px; height: 20px; }
.trow.targets { flex-wrap: wrap; gap: 6px 14px; }

/* single fire detectors / sounders (FC20) on floor plans: alarm red + pulsing, pre-alarm orange, fault yellow, off grey crossed */
.marker.firedet .dot { color: var(--fg); }
.marker.firedet.alert .dot { background: var(--bad); border-color: var(--bad); color: #fff; animation: fdpulse 1s ease-in-out infinite alternate; }
.marker.firedet.warn .dot { background: var(--warn); border-color: var(--warn); color: #fff; }
.marker.fault .dot { border-color: #d4a72c; color: #d4a72c; }
.marker.detoff .dot { opacity: .55; position: relative; }
.marker.detoff .dot::after { content: ''; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; background: var(--muted); transform: rotate(-45deg); }
@keyframes fdpulse { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 70%, transparent); } to { box-shadow: 0 0 0 10px color-mix(in srgb, var(--bad) 0%, transparent); } }
@media (prefers-reduced-motion: reduce) { .marker.firedet.alert .dot { animation: none; } }
.tile.fault { border-color: #d4a72c; }
.tile.fault .tic, .tile.fault .tval, .lrow.fault .lic, .lrow.fault .lval { color: #d4a72c; }
.tile.detoff .tic, .tile.detoff .tval, .lrow.detoff .lic, .lrow.detoff .lval { color: var(--muted); }

/* Meldungen (sent messages) */
#menuBtn { position: relative; }
#menuBtn[data-count]::after { content: attr(data-count); position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-sizing: border-box; }
.meldungen .loglist { display: flex; flex-direction: column; gap: 6px; max-height: 65vh; overflow-y: auto; }
.meldungen .logday { margin: 10px 0 2px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.logitem { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.logitem.new { border-color: var(--accent, var(--ok)); }
.logitem .logimg { flex: none; width: 96px; height: 64px; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: #000; }
.logitem.hl { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad) inset; }
.logitem .logtime { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 44px; }
.logitem .logtext { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.logitem button { flex: none; }
.logitem .logpage { display: flex; flex-direction: column; align-items: center; line-height: 1.2; padding: 6px 12px; }
.logitem .logpage small { font-size: 11px; color: var(--muted); }
.lognew { color: var(--bad); margin-left: 6px; }
.muted.small { font-size: 12px; margin-top: 2px; }

/* livecam AI detection over camera pictures */
.detov { position: absolute; pointer-events: none; overflow: hidden; }
.detbox { position: absolute; border: 2px solid #f85149; border-radius: 4px; box-sizing: border-box; }
.detbox.vehicle { border-color: #f0b429; }
.detbox.animal { border-color: #3fb950; }
.detbox span { position: absolute; left: -2px; top: -18px; font-size: 11px; line-height: 16px; padding: 0 4px; border-radius: 3px; background: #f85149; color: #fff; white-space: nowrap; }
.detbox.vehicle span { background: #f0b429; color: #000; }
.detbox.animal span { background: #3fb950; color: #000; }
.detbox.still { border: 2px dashed #9aa0a6; }
.detbox.still span { background: #9aa0a6; color: #000; }
.detbadge { position: absolute; right: 6px; top: 6px; padding: 2px 8px; border-radius: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; }
.detbadge:empty { display: none; }
.camfull .camwrap { flex: 1; min-height: 0; position: relative; }
.camfull .camwrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lcamwrap { position: relative; display: block; width: 100%; }

/* charts (www/chartview.js) */
.chartv { position: relative; min-width: 0; }
.chplot { position: relative; }
.chsvg { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chgrid { stroke: var(--line); stroke-width: 1; }
.chlab { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chstrip { fill: var(--line); opacity: .5; }
.chcross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chdot { stroke: var(--tile); stroke-width: 2; pointer-events: none; }
.chtip { position: absolute; top: 0; z-index: 5; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 9px; font-size: 13px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.chtip .chtime { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.chtip i, .chlegend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chlegend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.chlegend b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.chnote { font-size: 13px; margin: 6px 0 0; }
.tile.chart { display: block; grid-column: span 2; height: auto; min-height: 120px; overflow: visible; padding: 12px 12px 8px; }
.tile.chart.size-l { grid-column: 1 / -1; }
.tile.chart .hlabel { font-weight: 600; margin-bottom: 4px; }
.tile.chart .hlabel small { color: var(--muted); font-weight: 400; }
.tile.chart .chlegend { margin: 4px 0 0; font-size: 12px; }
.sheet.chartsheet { width: min(900px, 100%); }
.sheet:has(.histbox.small:not([hidden])) { width: min(640px, 100%); }
.robrooms .robfloor { font-size: 13px; margin: 8px 0 2px; }
.robrooms button:disabled { opacity: .55; }
.histbox .chtools { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.histbox .chranges { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.histbox .iconbtn:disabled { opacity: .3; }
.histbox .chranges button { padding: 6px 10px; font-size: 14px; }
.histbox .chperiod { font-size: 13px; margin-bottom: 4px; }
.histbox.small { margin-top: 12px; }
