:root {
  --bg: #050B17;
  --bg2: #0A1528;
  --card: #0D1B33;
  --card2: #112442;
  --line: #1C3358;
  --blue: #0098FB;
  --cyan: #05E0FC;
  --text: #E8F1FF;
  --muted: #8BA3C7;
  --ok: #3DDC97;
  --warn: #F5B83D;
  --bad: #FF5C7A;
  --pv: #F5B83D;
  --load: #05E0FC;
  --batt: #3DDC97;
  --grid: #FF6B8A;
  --soc: #A99BFF;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Montserrat, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; background: radial-gradient(1200px 600px at 80% -10%, rgba(0,152,251,.14), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(5,224,252,.08), transparent 60%), var(--bg); background-attachment: fixed; }
h1, h2, h3 { font-family: 'Exo 2', sans-serif; font-style: italic; font-weight: 700; margin: 0; letter-spacing: .01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--cyan); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.err { color: var(--bad); min-height: 1.2em; }
svg { fill: currentColor; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: 22px; padding: 32px 28px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.5), 0 0 0 1px rgba(5,224,252,.05) inset; }
.login-card img { border-radius: 18px; box-shadow: 0 0 40px rgba(0,152,251,.35); }
.login-card h1 { font-size: 2rem; margin-top: 12px; background: linear-gradient(90deg, var(--blue), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-card label { display: block; text-align: left; margin: 14px 0 0; font-size: .85rem; color: var(--muted); }
.login-card input { margin-top: 6px; }
.login-card .btn { width: 100%; margin-top: 20px; }

/* ---------- inputs & buttons ---------- */
input, select, textarea { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,152,251,.2); }
input[type=checkbox] { width: auto; }
input[type=range] { padding: 0; accent-color: var(--cyan); background: none; border: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card2); border-radius: 999px; padding: 9px 18px; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: linear-gradient(90deg, var(--blue), #00b8f5); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(0,152,251,.35); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { border-color: rgba(255,92,122,.5); color: #ffb3c1; }
.btn.small { padding: 5px 12px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .count { position: absolute; top: -5px; right: -5px; background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700; border-radius: 999px; padding: 0 6px; min-width: 18px; line-height: 18px; text-align: center; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.side { grid-row: 1 / 3; background: rgba(10,21,40,.7); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Exo 2'; font-style: italic; font-weight: 800; font-size: 1.35rem; }
.brand img { border-radius: 10px; }
.brand span { background: linear-gradient(90deg, var(--blue), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
#nav { margin-top: 26px; display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 600; border: 1px solid transparent; cursor: pointer; background: none; text-align: left; }
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item:hover { color: var(--text); background: var(--card); }
.nav-item.active { color: #fff; background: linear-gradient(90deg, rgba(0,152,251,.25), rgba(5,224,252,.06)); border-color: rgba(0,152,251,.35); }
.nav-item.active svg { color: var(--cyan); }
.side-foot { margin-top: auto; padding: 0 12px; }
.top { display: flex; align-items: center; gap: 16px; padding: 18px 28px; position: sticky; top: 0; z-index: 5; background: rgba(5,11,23,.75); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(28,51,88,.6); }
.top h1 { font-size: 1.5rem; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.badge { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.demo { color: var(--warn); border-color: rgba(245,184,61,.45); background: rgba(245,184,61,.08); }
.badge.live { color: var(--ok); border-color: rgba(61,220,151,.45); background: rgba(61,220,151,.08); }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px rgba(255,92,122,.15); }
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,151,.18), 0 0 12px var(--ok); }
.live-dot.poll { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,184,61,.18); }
main { padding: 24px 28px 40px; outline: none; max-width: 1400px; width: 100%; }
.tabbar { display: none; }
.mobile-only { display: none; }

/* ---------- layout pieces ---------- */
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.span2 { grid-column: span 2; }
.main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .main-side { grid-template-columns: 1fr; } }
.card { background: linear-gradient(180deg, rgba(17,36,66,.9), rgba(13,27,51,.9)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section { margin-top: 26px; }
.section > .card-h { margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.empty { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: rgba(61,220,151,.35); }
.pill.bad { color: var(--bad); border-color: rgba(255,92,122,.4); }
.pill.warn { color: var(--warn); border-color: rgba(245,184,61,.4); }
.stat { display: flex; flex-direction: column; }
.stat b { font-family: 'Exo 2'; font-style: italic; font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .78rem; }
.tabs { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: .85rem; }
.tabs button.on { background: var(--blue); color: #fff; }

/* ---------- toggle ---------- */
.toggle { position: relative; width: 50px; height: 28px; flex: none; border-radius: 999px; background: #233a5e; border: 0; cursor: pointer; transition: .2s; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #c5d4ea; transition: .2s; }
.toggle.on { background: linear-gradient(90deg, var(--blue), var(--cyan)); box-shadow: 0 0 14px rgba(5,224,252,.4); }
.toggle.on::after { left: 25px; background: #fff; }
.toggle:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- devices ---------- */
.dev { display: flex; flex-direction: column; gap: 12px; }
.dev.offline { opacity: .55; }
.dev-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); flex: none; }
.dev-ic svg { width: 22px; height: 22px; }
.dev-ic.on { color: var(--cyan); border-color: rgba(5,224,252,.4); box-shadow: 0 0 18px rgba(5,224,252,.18) inset; }
.ch { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid rgba(28,51,88,.6); }
.ch:first-child { border-top: 0; }
.metrics { display: flex; gap: 18px; flex-wrap: wrap; }
.metrics .stat b { font-size: 1.15rem; }

/* ---------- scenes ---------- */
.scenes { display: flex; gap: 12px; flex-wrap: wrap; }
.scene { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; }
.scene:hover { border-color: var(--cyan); box-shadow: 0 0 18px rgba(5,224,252,.15); }
.scene svg { width: 20px; height: 20px; color: var(--cyan); }

/* ---------- energy flow ---------- */
.flow svg { width: 100%; height: auto; max-height: 360px; display: block; }
.flow .node circle { fill: var(--bg2); stroke-width: 2; }
.flow .node text { fill: var(--text); font-family: Montserrat; text-anchor: middle; }
.flow .node .v { font-family: 'Exo 2'; font-style: italic; font-weight: 700; font-size: 17px; }
.flow .node .l { fill: var(--muted); font-size: 11px; }
.flow path.wire { fill: none; stroke: #1f3a63; stroke-width: 3; }
.flow path.dash { fill: none; stroke-width: 3; stroke-dasharray: 6 12; stroke-linecap: round; animation: flow 1s linear infinite; }
.flow path.dash.rev { animation-direction: reverse; }
.flow path.dash.idle { display: none; }
@keyframes flow { to { stroke-dashoffset: -18; } }
@media (prefers-reduced-motion: reduce) { .flow path.dash { animation: none; } }

/* ---------- charts ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: 280px; display: block; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .axis line { stroke: #1a2f52; }
.chart .tip { position: absolute; pointer-events: none; background: rgba(5,11,23,.95); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: .8rem; white-space: nowrap; transform: translate(-50%, -110%); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- cameras ---------- */
.cams { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.cam { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #000; cursor: pointer; aspect-ratio: 16 / 9; }
.cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 8px; background: linear-gradient(transparent, rgba(0,0,0,.8)); display: flex; justify-content: space-between; align-items: end; font-weight: 600; font-size: .9rem; }
.viewer img { width: 100%; border-radius: 12px; background: #000; display: block; aspect-ratio: 16/9; object-fit: contain; }
.events { display: flex; flex-direction: column; gap: 10px; }
.event { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); }
.event img { width: 112px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; flex: none; cursor: pointer; background: #000; }
.seg { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); cursor: pointer; }
.seg:hover, .seg.on { border-color: var(--cyan); }
.segs { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.item.unread { border-color: rgba(0,152,251,.5); }
.item .grow { flex: 1; min-width: 0; }
.item img { width: 140px; border-radius: 10px; aspect-ratio: 16/9; object-fit: cover; flex: none; background: #000; }
.lvl { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--blue); }
.lvl.warning { background: var(--warn); }
.lvl.alert { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.rule-sum { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.rule-sum b { color: var(--text); font-weight: 600; }

/* ---------- forms in modals ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { font-size: .82rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.form .inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: rgba(5,11,23,.4); }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days button { width: 38px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; font-size: .78rem; font-weight: 600; color: var(--muted); }
.days button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.diff { width: 100%; border-collapse: collapse; }
.diff td, .diff th { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
.diff .to { color: var(--cyan); font-weight: 700; }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(2,6,14,.75); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { position: relative; width: min(720px, 100%); max-height: 92vh; overflow: auto; background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: 0 30px 90px rgba(0,0,0,.6); }
.modal-card.wide { width: min(1000px, 100%); }
.modal-x { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg2); font-size: 22px; line-height: 1; cursor: pointer; z-index: 2; }
.modal h2 { margin: 0 40px 16px 0; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 60; max-width: min(380px, calc(100% - 32px)); }
.toast { background: var(--card2); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 12px; padding: 12px 14px; box-shadow: 0 14px 40px rgba(0,0,0,.5); animation: tin .25s ease-out; }
.toast.warning { border-left-color: var(--warn); }
.toast.alert, .toast.error { border-left-color: var(--bad); }
.toast b { display: block; font-size: .9rem; }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-only { display: flex; }
  .top { padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); gap: 10px; }
  .top h1 { display: none; }
  .badge { display: none; }
  main { padding: 16px 16px calc(90px + var(--safe-b)); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(8,17,33,.95); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); justify-content: space-around; }
  .tabbar .nav-item { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .66rem; flex: 1; align-items: center; border-radius: 10px; }
  .tabbar .nav-item svg { width: 22px; height: 22px; }
  .item img, .event img { width: 96px; }
  .toasts { left: 16px; right: 16px; bottom: calc(84px + var(--safe-b)); max-width: none; }
  .chart svg { height: 230px; }
  .card-h .right { margin-left: 0; width: 100%; flex-wrap: nowrap; }
  /* compact phone layout: 2 devices and 2 cameras per row */
  .grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card.dev { padding: 11px; gap: 8px; border-radius: 13px; }
  .dev > .row { gap: 8px; flex-wrap: nowrap; align-items: flex-start; }
  .dev-ic { width: 30px; height: 30px; border-radius: 9px; }
  .dev-ic svg { width: 17px; height: 17px; }
  .dev h3 { font-size: .86rem; line-height: 1.2; word-break: break-word; }
  .dev .small { font-size: .7rem; }
  .toggle { width: 40px; height: 23px; }
  .toggle::after { width: 17px; height: 17px; }
  .toggle.on::after { left: 20px; }
  .ch { padding: 5px 0; font-size: .8rem; gap: 6px; }
  .ch span { min-width: 0; word-break: break-word; }
  .metrics { gap: 10px; }
  .metrics .stat b { font-size: .92rem; }
  .metrics .stat span { font-size: .65rem; }
  .dev .btn.small { padding: 4px 9px; font-size: .72rem; }
  .dev .btn.small svg { width: 13px; height: 13px; }
  .dev .tl { display: none; } /* phones: clock icon + count only */
  .dev .btn.small { gap: 4px; }
  .cams { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cam { border-radius: 10px; }
  .cam .cap { padding: 14px 7px 5px; font-size: .74rem; }
  .cam .cap .pill { font-size: .6rem; padding: 1px 6px; }
  .cam .cap .pill:not(.ok):not(.bad) { display: none; } /* hide the source label on phones */
  .scene { padding: 9px 12px; font-size: .85rem; }
  .card-h .right input[type=search] { max-width: none !important; flex: 1; min-width: 0; }
  .card-h .right .pill { white-space: nowrap; }
  .card-h h2 { font-size: 1.05rem; }
}
.cam .cap span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; margin-right: 8px; }

/* placeholder camera spots (home agent offline) */
.cam.ph { cursor: default; background: repeating-linear-gradient(135deg, rgba(0,152,251,.06) 0 12px, rgba(5,224,252,.03) 12px 24px); border-style: dashed; border-color: rgba(0,152,251,.35); }
.cam.ph .ph-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding-bottom: 28px; }
.cam.ph .ph-ico { font-size: 1.6rem; opacity: .55; }

/* Home: clickable, expandable blocks */
.blk { padding: 0; overflow: hidden; }
.blk-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; user-select: none; }
.blk-h:hover { background: rgba(0,152,251,.06); }
.blk-h:focus-visible { outline: 2px solid var(--cyan, #05E0FC); outline-offset: -2px; }
.blk-h h2 { margin: 0; }
.blk-h .right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.blk-ico { font-size: 1.15rem; width: 1.6rem; text-align: center; }
.blk-chev { display: inline-block; transition: transform .2s; color: var(--muted); font-size: 1.1rem; }
.blk.open .blk-chev { transform: rotate(180deg); }
.blk-body { display: none; padding: 0 18px 18px; }
.blk.open .blk-body { display: block; }
.blk-body > .card.flow { border: 0; padding: 0; background: none; box-shadow: none; }
@media (max-width: 700px) { .blk-h { padding: 12px; flex-wrap: wrap; } .blk-h .right { width: 100%; justify-content: flex-start; margin-left: 2.6rem; } .blk-body { padding: 0 10px 12px; } }
.grp-h { margin: 8px 0 -6px; font-size: 1.35rem; }

/* Smaller device tiles; click a tile for its settings */
.grid.cards.mini { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card.dev.mini { padding: 12px 14px; gap: 6px; cursor: pointer; transition: border-color .15s, background .15s; }
.card.dev.mini:hover { border-color: rgba(0,152,251,.55); background: rgba(0,152,251,.05); }
.dev.mini .dev-ic { width: 32px; height: 32px; border-radius: 9px; }
.dev.mini .dev-ic svg { width: 17px; height: 17px; }
.dev.mini h3 { font-size: .92rem; }
.dev.mini .ch { padding: 4px 0; font-size: .85rem; }
.dev.mini .toggle { width: 40px; height: 23px; }
.dev.mini .metrics { gap: 6px; }
.dev-gear { color: var(--muted); font-size: .8em; opacity: .7; }
.dev.mini .toggle::after { width: 17px; height: 17px; }
.dev.mini .toggle.on::after { left: 20px; }

/* Alerts: select to delete */
.nsel-l { display: flex; align-items: center; padding-right: 2px; cursor: pointer; }
input.nsel { width: 18px; height: 18px; accent-color: #0098FB; cursor: pointer; flex: none; }
a.brand { text-decoration: none; color: inherit; cursor: pointer; }

/* Home: at-a-glance tiles (click to drill down) */
.glances { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.glance { background: var(--card, #0d1b33); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; transition: border-color .15s, transform .15s; min-width: 0; }
.glance:hover { border-color: rgba(0,152,251,.6); transform: translateY(-1px); }
.glance:focus-visible { outline: 2px solid #05E0FC; outline-offset: 2px; }
.glance .g-top { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .78rem; }
.glance .g-ico { font-size: 1rem; }
.glance b { display: block; font-family: 'Exo 2'; font-style: italic; font-size: 1.45rem; margin: 4px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.glance.sun b { color: #f5b83d; }
.glance.warn { border-color: rgba(245,184,61,.45); }
.glance.bad { border-color: rgba(255,92,122,.5); }
.glance.bad b { color: #ff5c7a; }
@media (max-width: 700px) { .glances { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .glance { padding: 10px; } .glance b { font-size: 1.2rem; } }

/* iotlinx cloud additions */
#setpwCancel { margin-top: 8px; }
.scene:disabled { opacity: .45; cursor: not-allowed; }
.side-foot b { color: var(--text); font-weight: 600; }
.form h3 { margin: 6px 0 -4px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
/* Small square device tiles (tap for the control window) */
.dtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.dtile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-height: 128px; display: flex; flex-direction: column; cursor: pointer; transition: border-color .15s, transform .15s, background .15s; min-width: 0; }
.dtile:hover { border-color: rgba(0,152,251,.6); transform: translateY(-1px); }
.dtile:focus-visible { outline: 2px solid #05E0FC; outline-offset: 2px; }
.dtile.on { border-color: rgba(5,224,252,.35); background: linear-gradient(180deg, rgba(5,224,252,.07), var(--card)); }
.dtile.offline { opacity: .5; }
.dtile .dt-top { display: flex; justify-content: space-between; align-items: flex-start; }
.dtile .dev-ic { width: 40px; height: 40px; }
.dtile .dt-off { color: var(--muted); font-size: .9rem; }
.dtile .dt-name { margin-top: auto; padding-top: 12px; font-weight: 700; font-size: .95rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtile .dt-st { color: var(--muted); font-size: .8rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dtile.on .dt-st { color: #05E0FC; }
.dtile .dt-st.temp { color: #2ecc8f; }
/* Control window */
.dctl-h { display: flex; align-items: center; gap: 10px; padding-right: 96px; min-height: 36px; }
.dctl-gear { position: absolute; top: 12px; right: 58px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg2); color: inherit; font-size: 20px; line-height: 1; cursor: pointer; z-index: 2; display: grid; place-items: center; padding: 0; }
.dctl-gear:hover, .modal-x:hover { border-color: rgba(0,152,251,.6); }
.dctl-h h2 { margin: 0; }
.bigs { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px; margin: 22px 0 8px; }
.bigw { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.bigsw { width: 86px; height: 180px; border-radius: 22px; border: 1px solid var(--line); background: #0a1630; position: relative; cursor: pointer; padding: 0; color: var(--muted); font-weight: 700; }
.bigsw span { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 80px; border-radius: 16px; background: #233a5e; display: grid; place-items: center; transition: bottom .2s, background .2s; }
.bigsw.on { border-color: rgba(5,224,252,.5); box-shadow: 0 0 24px rgba(5,224,252,.15); color: #fff; }
.bigsw.on span { bottom: calc(100% - 86px); background: linear-gradient(180deg, #05E0FC, #0098FB); }
.bigsw.press span { bottom: 50px; background: #0098FB; color: #fff; }
.bigsw.ro { cursor: default; }
.bigsw:disabled { opacity: .5; cursor: not-allowed; }
.bign { font-weight: 600; font-size: .9rem; max-width: 120px; text-align: center; }
@media (max-width: 700px) { .dtiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } .dtile { padding: 10px; min-height: 104px; border-radius: 12px; } .dtile .dev-ic { width: 32px; height: 32px; } .dtile .dt-name { font-size: .82rem; } .dtile .dt-st { font-size: .7rem; } .bigs { gap: 16px; } .bigsw { width: 72px; height: 150px; } .bigsw span { height: 66px; } .bigsw.on span { bottom: calc(100% - 72px); } }

/* Scenes page */
.scards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.scard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-height: 112px; display: flex; flex-direction: column; cursor: pointer; transition: border-color .15s, transform .15s; min-width: 0; }
.scard:hover { border-color: rgba(0,152,251,.6); transform: translateY(-1px); }
.scard.off { opacity: .65; }
.scard .sc-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scard .sc-sub { color: var(--muted); font-size: .8rem; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scard .sc-foot { margin-top: auto; padding-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.scard .sc-foot:only-child, .scard .sc-foot > .sc-play:only-child { margin-left: auto; }
.sc-play { margin-left: auto; width: 36px; height: 36px; border-radius: 50%; border: 0; background: linear-gradient(135deg, #0098FB, #05E0FC); color: #031022; font-size: .9rem; cursor: pointer; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,152,251,.35); }
.sc-play:hover { filter: brightness(1.1); }
.tabs { display: flex; gap: 4px; background: #0a1630; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tab { border: 0; background: none; color: var(--muted); padding: 5px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: .8rem; }
.tab.on { background: #0098FB; color: #fff; }
.tlist { display: flex; flex-direction: column; gap: 8px; border-left: 2px dashed rgba(0,152,251,.3); padding-left: 14px; }
.trow { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.trow:hover { border-color: rgba(0,152,251,.6); }
.trow.off { opacity: .55; }
.trow .t-time { font-family: 'Exo 2'; font-style: italic; font-size: 1.15rem; width: 52px; }
.trow .t-ico { color: #0098FB; width: 18px; text-align: center; }
.trow .t-dev { font-weight: 600; }
.t-act { min-width: 74px; text-align: center; padding: 7px 0; border-radius: 9px; font-weight: 700; font-size: .85rem; background: #233a5e; color: #c5d4ea; }
.t-act.on { background: #0098FB; color: #fff; }
@media (max-width: 700px) { .scards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .scard { padding: 12px; min-height: 100px; } .trow { gap: 8px; padding: 9px 10px; } .t-act { min-width: 54px; } }

/* Top bar: Home / Business switch */
.site-tabs { display: flex; gap: 4px; margin-left: 0; background: #0a1630; border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.site-tabs:empty { display: none; }
.site-tab { border: 0; background: none; color: var(--muted); padding: 6px 14px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: .85rem; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.site-tab:hover { color: #fff; }
.site-tab.on { background: linear-gradient(135deg, #0098FB, #05E0FC); color: #031022; }
@media (max-width: 700px) { .site-tabs { margin-left: 8px; } .site-tab { padding: 5px 9px; font-size: .75rem; max-width: 110px; } }
/* cloud: many sites -> the switch scrolls sideways on phones */
.site-tabs { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.site-tabs::-webkit-scrollbar { display: none; }
.top h1[hidden] { display: none; }
#pageTitle:not([hidden]) + .site-tabs { margin-left: 16px; }

/* One card per area: summary in the header, drill down on click */
.blk-t { min-width: 0; }
.blk-sub { color: var(--muted); font-size: .8rem; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk-big { font-family: 'Exo 2'; font-style: italic; font-size: 1.45rem; margin-right: 6px; white-space: nowrap; }
.blk-big.sun { color: #f5b83d; } .blk-big.bad { color: #ff5c7a; } .blk-big.warn { color: #f5b83d; }
.blk-h { padding: 16px 18px; }
.cam-part { margin-bottom: 18px; }
.cam-part:last-child { margin-bottom: 0; }
.cam-part-h { display: flex; align-items: center; gap: 10px; font-weight: 700; margin: 4px 0 10px; }
@media (max-width: 700px) { .blk-big { font-size: 1.15rem; } .blk-sub { white-space: normal; } }

/* Scenes as a sub-item under Devices in the left menu */
.nav-item.nav-sub { margin: -2px 0 2px 26px; padding: 7px 12px; font-size: .9rem; border-left: 2px solid rgba(0,152,251,.3); border-radius: 0 10px 10px 0; }
.nav-item.nav-sub svg { width: 16px; height: 16px; }
/* Home: area tiles (Cameras, Devices, Solar) in the device-tile style; contents open below */
.atiles { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.atile { min-height: 132px; }
.atile .dev-ic { font-size: 1.1rem; display: grid; place-items: center; }
.atile .dt-name { margin-top: 10px; padding-top: 0; }
.atile .a-big { font-family: 'Exo 2'; font-style: italic; font-size: 1.35rem; line-height: 1.15; margin-top: 2px; }
.atile .a-big.sun, .atile .a-big.warn { color: #f5b83d; } .atile .a-big.bad { color: #ff5c7a; }
.atile .dt-st { color: var(--muted); }
.atile.sel { border-color: #05E0FC; box-shadow: 0 0 0 1px rgba(5,224,252,.35), 0 0 22px rgba(5,224,252,.12); }
.a-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; }
.a-dot.ok { background: #2ecc8f; box-shadow: 0 0 8px rgba(46,204,143,.6); } .a-dot.bad { background: #ff5c7a; }
.area-panel { background: var(--card); border: 1px solid rgba(5,224,252,.35); border-radius: 14px; padding: 14px 16px; }
.area-panel[hidden] { display: none; }
.ap-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ap-h h2 { margin: 0; }
@media (max-width: 700px) { .atiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } .atile { min-height: 112px; } .atile .a-big { font-size: 1.1rem; } .area-panel { padding: 10px; } }

/* Honeywell aircons + Devices page (Alexa style) */
/* Aircons (Honeywell): name + inside temp, mode, and ▼ setting ▲ like the Honeywell app */
.ac-list { display: flex; flex-direction: column; gap: 8px; }
.ac-row { display: flex; align-items: center; gap: 14px; background: #0a1630; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.ac-row.offline { opacity: .5; }
.ac-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ac-name { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-in { color: var(--muted); font-size: .85rem; }
.ac-mode { width: auto; align-self: flex-start; padding: 4px 8px; font-size: .82rem; margin-top: 4px; }
.ac-ctl { display: flex; align-items: center; gap: 10px; }
.ac-btn { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg2); color: inherit; font-size: 1.5rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.ac-btn:hover:not(:disabled) { border-color: #0098FB; }
.ac-btn:disabled { opacity: .35; cursor: not-allowed; }
.ac-set { font-family: 'Exo 2'; font-style: italic; font-size: 2rem; color: #05E0FC; min-width: 52px; text-align: center; }
.ac-set.heat { color: #f5b83d; }
@media (max-width: 700px) { .ac-row { gap: 8px; padding: 10px; } .ac-btn { width: 40px; height: 40px; font-size: 1.2rem; } .ac-set { font-size: 1.6rem; min-width: 40px; } }

/* Devices page, Alexa-style: filters across the top, dense tiles, filled blue when on */
.cat-chips { display: flex; flex-wrap: wrap; gap: 4px 2px; align-items: center; }
.cat { border: 0; background: none; color: var(--muted); font-weight: 700; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; padding: 6px 10px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.cat + .cat::before { content: '•'; color: #0098FB; margin: 0 6px 0 -8px; }
.cat:hover { color: #fff; }
.cat.on { color: #05E0FC; }
.cat-n { font-size: .7rem; color: var(--muted); font-weight: 600; }
.dtiles.dense { grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 10px; }
.dtiles.dense .dtile { min-height: 108px; padding: 11px 12px; border-radius: 12px; }
.dtiles.dense .dev-ic { width: 32px; height: 32px; }
.dtiles.dense .dt-name { font-size: .86rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dtiles.dense .dt-st { font-size: .74rem; }
.dtile.on { background: linear-gradient(160deg, #0a8ee6, #0b6fc0); border-color: #33b6ff; }
.dtile.on .dt-name, .dtile.on .dt-st { color: #fff; }
.dtile.on .dev-ic { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); color: #fff; box-shadow: none; }
.dtile.offline { opacity: 1; background: #1a2638; }
.dtile.offline .dt-name { color: #9fb0c6; }
.dtile.offline .dt-st { color: #ff6b85; }
@media (max-width: 700px) { .dtiles.dense { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } .dtiles.dense .dtile { min-height: 94px; padding: 9px; } .cat { font-size: .7rem; padding: 5px 7px; } }

/* Alexas (Echo devices) */
.ec-row { display: flex; align-items: center; gap: 12px; background: #0a1630; border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; flex-wrap: wrap; }
.ec-row.offline { opacity: .5; }
.ec-info { flex: 1; min-width: 140px; }
.ec-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ec-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg2); color: inherit; cursor: pointer; display: grid; place-items: center; font-size: 1rem; padding: 0; }
.ec-btn:hover:not(:disabled) { border-color: #0098FB; }
.ec-btn:disabled { opacity: .35; cursor: not-allowed; }
.ec-vol { display: inline-flex; align-items: center; gap: 6px; }
.ec-vol input { width: 110px; accent-color: #05E0FC; }
.ec-rt { gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }

/* Home: all sites one after the other */
.site-sec { display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 80px; }
.site-sec + .site-sec { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.site-sec:last-child { min-height: calc(100vh - 140px); }

/* Area tiles on Home: same size as the device tiles */
.atiles { grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 10px; }
.atile { min-height: 108px; padding: 11px 12px; border-radius: 12px; }
.atile .dev-ic { width: 32px; height: 32px; font-size: 1rem; }
.atile .dt-name { font-size: .86rem; margin-top: 8px; }
.atile .a-big { font-size: 1.15rem; }
.atile .dt-st { font-size: .72rem; }
@media (max-width: 700px) { .atiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } .atile { min-height: 94px; padding: 9px; } }

/* brand label on tiles */
.brand-tag { font-size: .6rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; line-height: 1.5; white-space: nowrap; }
.dtile.on .brand-tag { color: #fff; border-color: rgba(255,255,255,.4); }

/* Settings: eWeLink sign-in folded away */
.ew-box { margin-top: 6px; }
.ew-box > summary { cursor: pointer; color: var(--muted); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.ew-box > summary::-webkit-details-marker { display: none; }
.ew-box > summary::before { content: '▸'; transition: transform .15s; }
.ew-box[open] > summary::before { transform: rotate(90deg); }
.ew-box > summary:hover { color: #fff; }
/* cloud: the camera brand pill also shows on phones */
@media (max-width: 760px) { .cam .cap .pill.brand { display: inline-flex; } }

/* iotlinx logo (from the iotlinx.com homepage picture) in the middle of the top bar */
.top-logo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); line-height: 0; }
.top-logo img { height: 56px; width: auto; display: block; -webkit-mask-image: radial-gradient(ellipse 72% 80% at 50% 50%, #000 62%, transparent 100%); mask-image: radial-gradient(ellipse 72% 80% at 50% 50%, #000 62%, transparent 100%); }
@media (max-width: 1100px) { .top-logo { display: none; } }
/* cloud: a company can have many sites; keep their buttons clear of the logo (they scroll sideways) */
@media (min-width: 1101px) { .site-tabs { max-width: calc(50% - 140px); } #pageTitle:not([hidden]) + .site-tabs { max-width: calc(50% - 300px); } }

/* Previous / next section arrows (as on realvid.com / iotlinx.com) */
.sec-nav{display:flex;flex-direction:column;gap:10px;position:fixed;right:max(22px,env(safe-area-inset-right,0px));bottom:calc(22px + env(safe-area-inset-bottom,0px));z-index:65;transition:opacity .6s,transform .6s;opacity:0;pointer-events:none;transform:translateY(8px)}
.sec-nav.on{opacity:1;pointer-events:auto;transform:none}
.sec-nav button{user-select:none;touch-action:manipulation;width:46px;height:46px;border:0;border-radius:50%;background:linear-gradient(135deg,#0098FB,#05E0FC);color:#fff;display:grid;place-items:center;box-shadow:0 6px 18px rgba(0,0,0,.5);cursor:pointer;transition:transform .2s,filter .2s}
.sec-nav button:hover{filter:brightness(1.12)}
.sec-nav button[hidden]{display:none}
.sec-nav button:active{transform:scale(.92)}
.sec-nav svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
.sec-nav .sn-up{background:rgba(11,22,42,.92);border:1px solid rgba(255,255,255,.18)}
@media (max-width:700px){.sec-nav{right:14px;bottom:calc(84px + env(safe-area-inset-bottom,0px))}}
@media (prefers-reduced-motion:reduce){.sec-nav,.sec-nav button{transition:none}}

/* Help: little ? per page, ? at the top, and the help window */
.page-help { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0,152,251,.6); background: rgba(0,152,251,.12); color: #05E0FC; font-weight: 800; font-size: .85rem; cursor: pointer; display: grid; place-items: center; padding: 0; flex: none; }
.page-help:hover { background: rgba(0,152,251,.3); color: #fff; }
.q-ico { font-weight: 800; font-size: 1.05rem; line-height: 1; }
.help-wrap input[type=search] { margin: 6px 0 10px; }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.help-body { max-height: 58vh; overflow: auto; padding-right: 4px; }
.help-sec + .help-sec { margin-top: 14px; }
.help-sec h3 { margin: 0 0 4px; color: #05E0FC; font-family: 'Exo 2'; font-style: italic; }
.help-q { border-top: 1px solid var(--line); }
.help-q summary { list-style: none; cursor: pointer; padding: 9px 2px 9px 22px; position: relative; font-weight: 600; }
.help-q summary::-webkit-details-marker { display: none; }
.help-q summary::before { content: '\25B8'; position: absolute; left: 4px; top: 9px; color: #0098FB; transition: transform .15s; }
.help-q[open] summary::before { transform: rotate(90deg); }
.help-q p { margin: 0 0 10px 22px; color: var(--muted); line-height: 1.5; }
/* Chat (like realvid.com), in iotlinx blue; opens under the header at the right */
.chat-panel { position: fixed; right: 16px; top: 80px; z-index: 70; width: 380px; height: 560px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; background: #0b1730; color: var(--text); border: 1px solid rgba(0,152,251,.35); border-radius: 14px; overflow: hidden; box-shadow: 0 18px 50px rgba(0,0,0,.55); font-size: 14px; line-height: 1.45; animation: chat-in .18s ease-out; }
@keyframes chat-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: linear-gradient(135deg, #0077d0, #0098FB); color: #fff; }
.chat-avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }
.chat-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat-title b { font-size: 15px; } .chat-title small { font-size: 12px; opacity: .85; }
.chat-close { width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.chat-close:hover { background: rgba(255,255,255,.16); }
.chat-more { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; max-height: 128px; overflow: auto; border-bottom: 1px solid rgba(255,255,255,.08); }
.chat-chip { min-height: 30px; padding: 4px 12px; border-radius: 999px; border: 1px solid rgba(0,152,251,.55); background: rgba(0,152,251,.14); color: #dcebff; font: inherit; font-size: 12.5px; cursor: pointer; text-align: left; }
.chat-chip:hover { background: rgba(0,152,251,.32); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 86%; padding: 9px 12px; border-radius: 12px; overflow-wrap: anywhere; }
.chat-msg.bot { align-self: flex-start; background: #15264a; border-bottom-left-radius: 4px; }
.chat-msg.me { align-self: flex-end; background: #0098FB; color: #fff; border-bottom-right-radius: 4px; }
.chat-link { color: #05E0FC; font-weight: 700; text-decoration: none; display: inline-block; margin-top: 6px; }
.chat-form { display: flex; align-items: center; gap: 8px; padding: 10px 12px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.chat-form input { flex: 1; min-width: 0; height: 34px; padding: 0 14px; border-radius: 999px; }
.chat-send { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 0; background: #0098FB; color: #fff; display: grid; place-items: center; cursor: pointer; }
.chat-note { margin: 0; padding: 4px 12px 10px; font-size: 11px; color: var(--muted); text-align: center; }
@media (max-width: 520px) { .chat-panel { left: 8px; right: 8px; width: auto; top: 70px; height: calc(100vh - 160px); } }

/* What's at each site chooser */
.pick-list { max-height: 55vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.pick-row:hover { border-color: rgba(0,152,251,.6); }
.pick-row input { width: 18px; height: 18px; accent-color: #0098FB; flex: none; }
.pick-row.here { border-color: rgba(5,224,252,.5); background: rgba(5,224,252,.06); }

/* Phones: the top bar in two rows (logo + buttons, then the site buttons) so the page never gets wider than the screen */
@media (max-width: 700px) {
  .top { flex-wrap: wrap; gap: 8px 8px; padding: 10px 12px; min-width: 0; max-width: 100vw; box-sizing: border-box; }
  .top h1 { display: none; }
  .top .top-brand { order: 1; }
  .top-right { order: 2; margin-left: auto; gap: 6px; min-width: 0; }
  .site-tabs { order: 3; flex: 1 1 calc(100% - 40px); min-width: 0; max-width: none; } /* a row of their own; many sites scroll sideways */
  .page-help { order: 4; }
  .site-tab { flex: 1 0 auto; text-align: center; padding: 6px 8px; }
  #modeBadge { display: none; } /* the ? stays: it is the only help button on phones */
  .top-right .icon-btn { width: 34px; height: 34px; }
  html, body { overflow-x: clip; } /* clip, not hidden: hidden would stop the top bar from staying at the top */
}

/* Each site has its own colour on Home and in the site buttons */
[data-site] { --site: #0098FB; --site-rgb: 0,152,251; }
[data-site="purple"] { --site: #9B7BFF; --site-rgb: 155,123,255; }
[data-site="amber"] { --site: #F5A623; --site-rgb: 245,166,35; }
[data-site="green"] { --site: #2ECC8F; --site-rgb: 46,204,143; }
[data-site="pink"] { --site: #FF6FA8; --site-rgb: 255,111,168; }
[data-site="teal"] { --site: #14C8B4; --site-rgb: 20,200,180; }
[data-site="orange"] { --site: #FF7A45; --site-rgb: 255,122,69; }
[data-site="sky"] { --site: #05E0FC; --site-rgb: 5,224,252; }
.site-sec { background: linear-gradient(180deg, rgba(var(--site-rgb), .10), rgba(var(--site-rgb), .03)); border: 1px solid rgba(var(--site-rgb), .35); border-left: 4px solid var(--site); border-radius: 16px; padding: 14px 16px 16px; }
.site-sec + .site-sec { border-top: 1px solid rgba(var(--site-rgb), .35); padding-top: 14px; }
.site-sec .grp-h { color: var(--site); margin-top: 0; }
.site-sec .atile.sel { border-color: var(--site); box-shadow: 0 0 0 1px rgba(var(--site-rgb), .45), 0 0 22px rgba(var(--site-rgb), .18); }
.site-sec .area-panel { border-color: rgba(var(--site-rgb), .45); }
.site-tab[data-site].on { background: var(--site); color: #031022; }
.site-tab[data-site]:not(.on) { box-shadow: inset 0 -2px 0 rgba(var(--site-rgb), .55); }
.col-sel[data-site] { color: var(--site); }
.col-sel option { color: initial; }
@media (max-width: 700px) { .site-sec { padding: 10px 10px 12px; border-radius: 12px; } }

/* Top-bar logo: transparent PNG, no fade needed */
.top-logo img { mix-blend-mode: normal; -webkit-mask-image: none; mask-image: none; }

/* ✅ / ⚠️ / ○ next to a section's name */
.acc-st { font-size: .95em; margin-left: 4px; }
.acc-st.off { color: var(--muted); }

/* 👁 show / hide password */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap input { width: 100%; padding-right: 44px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 0; border-radius: 8px; }
.pw-eye:hover { color: #fff; background: rgba(255,255,255,.06); }
.pw-eye.on { color: #05E0FC; }
.pw-eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pw-eye.on svg path { stroke-dasharray: none; }

/* What's at each site: grid of items x sites (like Home screen settings) */
.sg-scroll { max-height: 56vh; overflow: auto; border-top: 1px solid var(--line); }
.site-grid thead th { position: sticky; top: 0; background: #0f1d38; z-index: 1; text-align: center; color: var(--site, var(--muted)); }
.site-grid thead th:first-child { text-align: left; }
.site-grid td { vertical-align: middle; }
.sg-name { font-weight: 600; }
.sg-cell { text-align: center; width: 18%; }
.sg-pick { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(var(--site-rgb), .45); cursor: pointer; transition: background .15s, border-color .15s; }
.sg-pick input { appearance: none; -webkit-appearance: none; width: 14px; height: 14px; margin: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.sg-pick.on { border-color: var(--site); background: rgba(var(--site-rgb), .18); }
.sg-pick.on input { background: var(--site); box-shadow: 0 0 10px rgba(var(--site-rgb), .7); }
.sg-pick:hover { border-color: var(--site); }

/* Expanded area: the header (with ✕ Close) stays in view while scrolling; a close bar at the bottom too */
.area-panel .ap-h { position: sticky; top: var(--top-h, 90px); z-index: 4; margin: -14px -16px 12px; padding: 12px 16px; background: rgba(13,27,52,.96); backdrop-filter: blur(8px); border-radius: 14px 14px 0 0; border-bottom: 1px solid rgba(var(--site-rgb, 5,224,252), .25); }
.ap-close { margin-left: auto; font-weight: 700; }
.ap-foot { display: block; width: 100%; margin-top: 14px; padding: 10px; border: 1px dashed rgba(var(--site-rgb, 5,224,252), .45); border-radius: 10px; background: rgba(var(--site-rgb, 5,224,252), .06); color: var(--site, #05E0FC); font-weight: 700; cursor: pointer; }
.ap-foot:hover { background: rgba(var(--site-rgb, 5,224,252), .14); }
@media (max-width: 700px) { .area-panel .ap-h { margin: -10px -10px 10px; padding: 10px; } }

/* Cameras: brand menu (All / Office NVR / Hikvision / Ring / UniFi) */
.cam-brands { margin: 0 0 4px; position: sticky; top: var(--top-h, 90px); z-index: 3; background: rgba(5,11,23,.9); backdrop-filter: blur(8px); padding: 8px 0; }

/* Phone: hamburger menu (the side menu slides in from the left) */
.burger { display: none; }
.drawer-back { position: fixed; inset: 0; z-index: 40; background: rgba(2,6,14,.6); backdrop-filter: blur(2px); }
.drawer-back[hidden] { display: none; }
@media (max-width: 900px) {
  .burger { display: inline-grid; flex: none; }
  .shell.drawer-open .side { display: flex; position: fixed; left: 0; top: 0; bottom: 0; height: 100%; width: min(280px, 82vw); z-index: 50; background: #08142a; box-shadow: 8px 0 30px rgba(0,0,0,.5); animation: drawerIn .2s ease-out; padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
  .shell.drawer-open .side .nav-item { padding: 14px 12px; font-size: 1rem; }
}
@keyframes drawerIn { from { transform: translateX(-100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .shell.drawer-open .side { animation: none; } }

/* Minimise (−) / open (+) on every box */
.card-h { position: relative; }
.min-btn { flex: none; margin-left: 8px; width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--muted); font-size: 1.1rem; font-weight: 700; line-height: 1; cursor: pointer; display: inline-grid; place-items: center; }
.min-btn:hover { color: #fff; border-color: #05E0FC; }
.card.min > :not(.card-h) { display: none !important; }
.card.min > .card-h { margin-bottom: 0; }
.card.min { padding-bottom: 14px; }
@media (max-width: 700px) { .top .burger { order: 0; width: 34px; height: 34px; } }

/* Amazon sign-in progress */
.aw-box { margin-top: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(5,224,252,.35); background: rgba(5,224,252,.06); }
.aw-box.ok { border-color: rgba(46,204,113,.55); background: rgba(46,204,113,.08); }
.aw-box.bad { border-color: rgba(255,92,122,.55); background: rgba(255,92,122,.08); }
.aw-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.aw-steps { margin: 10px 0 0; padding-left: 20px; line-height: 1.7; }
.aw-steps code { background: #0098FB; color: #fff; padding: 1px 6px; border-radius: 5px; }
.aw-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(5,224,252,.25); border-top-color: #05E0FC; animation: awspin .8s linear infinite; flex: none; }
@keyframes awspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .aw-spin { animation: none; } }

/* Accounts & passwords: menu of accounts, one shown at a time */
.acc-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; margin: 4px 0 6px; }
.acc-m { display: flex; align-items: center; gap: 8px; text-align: left; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--muted); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.acc-m:hover { color: #fff; border-color: rgba(5,224,252,.5); }
.acc-m.on { color: #031022; background: linear-gradient(135deg, #0098FB, #05E0FC); border-color: transparent; }
.acc-m-st { width: 18px; text-align: center; flex: none; }
.box[hidden] { display: none !important; }
@media (max-width: 700px) { .acc-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Sign-in steps (SMS code, forgot password) */
.login-step a { color: #05E0FC; }
#forgotP a { color: #05E0FC; font-weight: 600; }

/* Settings: menu across the top */
.set-tabs { display: flex; gap: 4px; margin: -4px 40px 16px 0; padding: 4px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.set-tab { flex: none; border: 0; background: none; color: var(--muted); padding: 8px 14px; border-radius: 9px; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.set-tab:hover { color: #fff; background: rgba(255,255,255,.05); }
.set-tab.on { color: #031022; background: linear-gradient(135deg, #0098FB, #05E0FC); }
@media (max-width: 700px) { .set-tabs { margin-right: 36px; } .set-tab { padding: 7px 10px; font-size: .78rem; } }

/* Two parts inside one section (e.g. Aircons: Resideo + Honeywell) */
.sub-box { margin-top: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; display: grid; gap: 8px; }
.sub-box > b { font-size: .9rem; }

/* Home: an empty slot where a site has no tile of that kind, so the columns line up */
.atile-gap { min-height: 1px; }

/* Home > Routines */
.rt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.rt-btn { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); color: #fff; font: inherit; font-weight: 600; text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.rt-btn:hover:not(:disabled) { border-color: rgba(var(--site-rgb, 5,224,252), .6); background: rgba(var(--site-rgb, 5,224,252), .08); }
.rt-btn:disabled { opacity: .5; cursor: default; }
.rt-btn.busy { opacity: .6; }
.rt-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: rgba(var(--site-rgb, 5,224,252), .18); color: var(--site, #05E0FC); font-size: .75rem; }
@media (max-width: 700px) { .rt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Sign-in: keep me signed in */
.keep-row { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.keep-row input { width: 18px; height: 18px; accent-color: #0098FB; }

/* One Echo's page */
.ec-open { cursor: pointer; border-radius: 8px; }
.ec-open:hover .ac-name { color: #05E0FC; }
.ec-chev { color: var(--muted); font-weight: 400; }
.ed { display: grid; gap: 14px; }
.ed-now { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.03); border: 1px solid var(--line); }
.ed-art { width: 84px; height: 84px; border-radius: 12px; flex: none; display: grid; place-items: center; font-size: 2rem; background: rgba(5,224,252,.08); overflow: hidden; }
.ed-art img { width: 100%; height: 100%; object-fit: cover; }
.ed-meta { min-width: 0; }
.ed-title { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-ctl { display: flex; justify-content: center; align-items: center; gap: 18px; }
.ed-btn, .ed-play { border: 1px solid var(--line); background: rgba(255,255,255,.04); color: #fff; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.ed-btn { width: 48px; height: 48px; font-size: 1.1rem; }
.ed-play { width: 64px; height: 64px; font-size: 1.5rem; background: linear-gradient(135deg, #0098FB, #05E0FC); color: #031022; border: 0; }
.ed-btn:disabled, .ed-play:disabled { opacity: .4; cursor: default; }
.ed-row { display: flex; align-items: center; gap: 12px; }
.ed-row input[type=range] { flex: 1; }
.ed-vnum { min-width: 32px; text-align: right; }

/* ===================== Light version (☀️ in the top bar; remembered per device) ===================== */
html[data-theme="light"] {
  --bg: #EEF3FA; --bg2: #E4ECF7; --card: #FFFFFF; --card2: #F5F8FD; --line: #D3DEEE;
  --blue: #0077D9; --cyan: #0091C2; --text: #0B1A33; --muted: #566A88;
  --ok: #12A36B; --warn: #C98400; --bad: #E0335A; --pv: #D99000; --load: #0091C2; --batt: #12A36B; --grid: #E0466B; --soc: #6C5CE0;
  color-scheme: light;
}
html[data-theme="light"] body { background: radial-gradient(1200px 600px at 80% -10%, rgba(0,152,251,.10), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(5,224,252,.08), transparent 60%), var(--bg); }
html[data-theme="light"] .side, html[data-theme="light"] .shell.drawer-open .side { background: rgba(255,255,255,.85); }
html[data-theme="light"] .top { background: rgba(255,255,255,.82); border-bottom-color: var(--line); }
html[data-theme="light"] .tabbar { background: rgba(255,255,255,.96); }
html[data-theme="light"] .card { background: linear-gradient(180deg, #FFFFFF, #F7FAFE); box-shadow: 0 1px 3px rgba(11,26,51,.06); }
html[data-theme="light"] .box, html[data-theme="light"] .chart .tip, html[data-theme="light"] .dbg-out { background: #F5F8FD; }
html[data-theme="light"] .modal { background: rgba(20,35,60,.35); }
html[data-theme="light"] .drawer-back { background: rgba(20,35,60,.3); }
html[data-theme="light"] .glance, html[data-theme="light"] .dtile, html[data-theme="light"] .atile { background: #FFFFFF; box-shadow: 0 1px 3px rgba(11,26,51,.06); }
html[data-theme="light"] .dtile.offline { background: #EEF1F6; }
html[data-theme="light"] .dtile.on { background: linear-gradient(160deg, #0a8ee6, #0b6fc0); }
html[data-theme="light"] .bigsw, html[data-theme="light"] .tabs, html[data-theme="light"] .site-tabs, html[data-theme="light"] .ac-row, html[data-theme="light"] .ec-row { background: #EAF0F8; }
html[data-theme="light"] .site-grid thead th { background: #F5F8FD; }
html[data-theme="light"] .area-panel .ap-h { background: rgba(255,255,255,.96); }
html[data-theme="light"] .cam-brands { background: rgba(238,243,250,.94); }
html[data-theme="light"] .chat-msg.bot { background: #E8EFF9; color: var(--text); }
html[data-theme="light"] .chat-panel { background: #FFFFFF; box-shadow: 0 18px 50px rgba(11,26,51,.2); }
html[data-theme="light"] .cam.ph { background: repeating-linear-gradient(135deg, rgba(0,119,217,.05) 0 12px, rgba(0,119,217,.09) 12px 24px); }
/* white text that sat on a dark background */
html[data-theme="light"] :is(.site-tab:hover, .cat:hover, .ew-box > summary:hover, .page-help:hover, .pw-eye:hover, .min-btn:hover, .acc-m:hover, .link-btn:hover, .set-tab:hover, .rt-btn, .ed-btn, .set-tab:hover) { color: var(--text); }
html[data-theme="light"] .link-btn { color: var(--blue); }
html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { background: #FFFFFF; color: var(--text); border-color: var(--line); }
html[data-theme="light"] .rt-btn, html[data-theme="light"] .acc-m, html[data-theme="light"] .u-row, html[data-theme="light"] .ed-now { background: #F7FAFE; }
html[data-theme="light"] .btn:not(.primary):not(.danger) { background: #FFFFFF; color: var(--text); border-color: var(--line); }
html[data-theme="light"] .icon-btn { background: #FFFFFF; }
html[data-theme="light"] .login-card { background: #FFFFFF; box-shadow: 0 30px 80px rgba(11,26,51,.15); }
html[data-theme="light"] .top-logo img { filter: drop-shadow(0 1px 1px rgba(11,26,51,.25)); }
/* the theme button */
.theme-btn .t-sun { display: none; }
html[data-theme="light"] .theme-btn .t-sun { display: inline; }
html[data-theme="light"] .theme-btn .t-moon { display: none; }
/* cloud-only surfaces */
html[data-theme="light"] .pick-row, html[data-theme="light"] .sub-box, html[data-theme="light"] .aw-box { background: #F7FAFE; }
html[data-theme="light"] .acc-menu .acc-m.on, html[data-theme="light"] .set-tab.on { color: #031022; }

/* The top bar never jumps: no page title once signed in (see app.js), and room for the scroll bar is always kept */
html { scrollbar-gutter: stable; }

/* Start-up: shown while the sites load */
.boot-load { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 60px 16px; color: var(--muted); font-weight: 600; }

/* Group chips with nothing at this site: shown, but dimmed */
.cat.empty { opacity: .35; cursor: default; }

/* Cameras: each camera system in its own band, alternating */
.cam-sec { padding: 14px 16px 16px; border-radius: 16px; border: 1px solid transparent; }
.cam-sec.cam-main { background: rgba(0,152,251,.045); border-color: rgba(0,152,251,.12); }
.cam-sec.cam-alt { background: rgba(255,255,255,.015); border-color: rgba(255,255,255,.05); }
.cam-sec > .card-h { margin-bottom: 10px; }
html[data-theme="light"] .cam-sec.cam-main { background: rgba(0,119,217,.05); border-color: rgba(0,119,217,.14); }
html[data-theme="light"] .cam-sec.cam-alt { background: #FFFFFF; border-color: var(--line); }
@media (max-width: 700px) { .cam-sec { padding: 10px; } }

/* Light version: the white-on-dark top-bar logo sits on its own dark badge */
html[data-theme="light"] .top-logo { background: radial-gradient(120% 140% at 50% 30%, #0D1B33, #050B17); padding: 3px 18px; border-radius: 14px; box-shadow: 0 4px 14px rgba(11,26,51,.18); }
html[data-theme="light"] .top-logo img { height: 50px; filter: none; mix-blend-mode: normal; -webkit-mask-image: none; mask-image: none; }

/* The top-bar logo is centred over the page content (main is at most 1400 px wide and sits left), not the whole bar */
.top-logo { left: min(50%, 700px); }

/* The top-menu row is not used (the left menu is back on desktop); its elements stay in the page, hidden */
.top-row2 { display: contents; }
.top-nav { display: none !important; }

/* Phones: with many pages the bottom bar scrolls sideways instead of cutting labels off */
@media (max-width: 900px) {
  .tabbar { overflow-x: auto; scrollbar-width: none; }
  .tabbar::-webkit-scrollbar { display: none; }
  .tabbar .nav-item { flex: 1 0 auto; min-width: 56px; white-space: nowrap; }
}

/* Sign-in card: step headings, notes, test mode */
.login-card h1 { margin-bottom: 2px; }
.login-sub { margin-top: 0; }
.login-note { margin: 0; padding: 8px 12px; border-radius: 10px; background: rgba(46,204,143,.12); border: 1px solid rgba(46,204,143,.4); color: var(--text); font-size: .9rem; }
.login-test { padding: 8px 12px; border-radius: 10px; background: rgba(245,184,61,.14); border: 1px solid rgba(245,184,61,.5); color: var(--text); font-size: .88rem; }

/* Set-up wizard */
.setup select { max-width: 100%; }
.setup .box + .box { margin-top: 8px; }

/* Sign-up and set-up steps (the same look as the sales walkthrough) */
.reg-steps { display: flex; justify-content: center; gap: 8px; margin: 6px 0; }
.reg-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; border: 1px solid var(--line); color: var(--muted); }
.reg-dot.on { background: linear-gradient(135deg, #0098FB, #05E0FC); color: #031022; border-color: transparent; }
.reg-dot.done { border-color: var(--ok); color: var(--ok); }
.reg-sites { display: grid; gap: 8px; margin: 8px 0; }
.reg-site { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; }
.reg-connect { display: grid; gap: 8px; margin: 8px 0; padding: 10px; border: 1px dashed var(--line); border-radius: 12px; text-align: left; }
.reg-done { display: grid; gap: 4px; margin: 8px 0; text-align: left; font-size: .85rem; }
.reg-devs { display: grid; gap: 6px; margin: 8px 0; max-height: 260px; overflow: auto; text-align: left; }
.reg-dev { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; font-size: .85rem; }
.reg-dev select { width: auto; padding: 4px 6px; }
.setup .reg-devs { max-height: 50vh; }

/* "🌐 All" site button */
.site-tab.site-all.on { background: linear-gradient(135deg, #0098FB, #05E0FC); color: #031022; }

/* Sign-in and sign-up: the animated iotlinx.com banner above the card (window lights fade on and off) */
.login { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0; padding-top: 12px;
  background: radial-gradient(70% 45% at 50% 18%, rgba(0,152,251,.20), transparent 70%), radial-gradient(60% 50% at 85% 85%, rgba(0,152,251,.12), transparent 70%), #020713; }
.login-hero { position: relative; width: min(94vw, 760px); aspect-ratio: 1240 / 905; background: url("img/login-top.jpg") center / 100% 100% no-repeat; flex: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%), linear-gradient(to bottom, transparent 0, #000 6%, #000 78%, transparent 100%);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%), linear-gradient(to bottom, transparent 0, #000 6%, #000 78%, transparent 100%); mask-composite: intersect;
  filter: drop-shadow(0 18px 40px rgba(0,152,251,.25)); margin-bottom: -9%; }
.login-hero .win { position: absolute; inset: 0; display: block; background: url("img/login-top-off.jpg") center / 100% 100% no-repeat; opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) { .login-hero .win { animation: loginLights var(--d) ease-in-out var(--dl) infinite; } }
@keyframes loginLights { 0%, 38% { opacity: 0; } 46%, 70% { opacity: 1; } 78%, 100% { opacity: 0; } }
.login .login-card { position: relative; z-index: 1; }
/* the banner already shows the logo and "from sensor to cloud" */
.login .login-card > img { display: none; }
.login .login-card .login-step { margin-top: 0; }
@media (max-width: 520px) { .login-hero { margin-bottom: -6%; } }
html[data-theme="light"] .login { background: radial-gradient(70% 45% at 50% 18%, rgba(0,152,251,.25), transparent 70%), #020713; }

/* Login fits one screen: banner beside the card on wide screens, smaller banner and a tighter card on phones */
.login .login-card { padding: 22px 24px 18px; }
.login .login-card label { margin-top: 10px; }
.login .login-card .btn.primary { margin-top: 12px; }
.login .login-note { margin-top: 10px; font-size: .78rem; }
.login .login-card > p.muted.small:last-child { margin: 8px 0 0; }
.login-hero { width: min(94vw, 760px, calc(36vh * 1240 / 905)); margin-bottom: -4%; }
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .login { flex-direction: row; justify-content: center; align-items: center; gap: clamp(16px, 3vw, 48px); padding: 16px 24px; }
  .login-hero { width: min(56vw, 820px, calc(88vh * 1240 / 905)); margin-bottom: 0; }
  .login .login-card { width: min(380px, 34vw); }
}

/* The All button gets the iotlinx cyan (the sites have their own colours) */
[data-site="all"] { --site: #05E0FC; --site-rgb: 5,224,252; }
html[data-theme="light"] [data-site="all"] { --site: #0091C2; --site-rgb: 0,145,194; }

/* Login banner: the whole logo shows (only the outer edge fades), with room at the top */
.login { padding-top: max(16px, env(safe-area-inset-top)); }
.login-hero {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 3%, #000 97%, transparent 100%), linear-gradient(to bottom, #000 0, #000 88%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 3%, #000 97%, transparent 100%), linear-gradient(to bottom, #000 0, #000 88%, transparent 100%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
.login-hero { border-radius: 20px; overflow: hidden; }
/* cloud: the sign-up and wizard cards are longer; they scroll inside the screen on small heights */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) { .login .login-step { max-height: calc(100vh - 32px); overflow: auto; } }

/* Phones: no empty error line, a slightly smaller heading, so sign-in fits one screen */
.login .login-card .err:empty { display: none; }
@media (max-width: 520px) { .login .login-card h1 { font-size: 1.6rem; margin-top: 0; } .login .login-card .login-sub { margin-bottom: 4px; } }

/* Devices page: the "x of y online" pill stays on the same line as the search box */
.card-h .right.dev-search { flex-wrap: nowrap; }
.dev-search .pill { white-space: nowrap; flex: none; }
.dev-search input { min-width: 0; }

/* Devices page: one band per site */
.dev-sites { display: grid; gap: 14px; }
.dev-sec .card-h h2 { color: var(--site); }

/* A minimised box shows only its heading and + (not the controls on the right of its heading) */
.card.min > .card-h > .right { display: none; }

/* Cameras: each camera system in its own soft colour (Hikvision red, Ring teal, UniFi violet, a business NVR amber) */
.cam-sec[data-src] { --src: 0,152,251; background: rgba(var(--src), .07) !important; border: 1px solid rgba(var(--src), .32) !important; }
.cam-sec[data-src] > .card-h h2 { color: rgb(var(--src)); }
.cam-sec[data-src="hikvision"] { --src: 239,83,80; }
.cam-sec[data-src="ring"] { --src: 38,198,218; }
.cam-sec[data-src="unifi"] { --src: 149,117,255; }
.cam-sec[data-src="business"] { --src: 245,166,35; }
html[data-theme="light"] .cam-sec[data-src] { background: rgba(var(--src), .06) !important; }
html[data-theme="light"] .cam-sec[data-src] > .card-h h2 { filter: brightness(.75); }

/* Colour bands: the Devices / Alexa site bands in the site colour, and the other boxes in six soft colours in turn */
.dev-sec[data-site] { background: rgba(var(--site-rgb), .07) !important; border: 1px solid rgba(var(--site-rgb), .32) !important; }
.dev-sec[data-site] > .card-h h2 { color: var(--site); }
/* other pages: each block its own soft colour in turn */
[data-band] { --band: 0,152,251; background: rgba(var(--band), .07) !important; border: 1px solid rgba(var(--band), .30) !important; border-radius: 16px; }
[data-band]:not(.card) { padding: 14px 16px 16px; }
[data-band] > .card-h h2 { color: rgb(var(--band)); }
[data-band="1"] { --band: 38,198,218; }
[data-band="2"] { --band: 149,117,255; }
[data-band="3"] { --band: 245,166,35; }
[data-band="4"] { --band: 61,220,151; }
[data-band="5"] { --band: 255,107,138; }
html[data-theme="light"] [data-band] > .card-h h2, html[data-theme="light"] .dev-sec[data-site] > .card-h h2 { filter: brightness(.75); }

/* Devices / Alexa: each site's section is clearly its own colour */
.dev-sec[data-site] { background: rgba(var(--site-rgb), .10) !important; border: 1px solid rgba(var(--site-rgb), .45) !important; }

/* Home > a site > Cameras: each camera system its own colour band, like the Cameras page */
.cam-part[data-src] { --src: 0,152,251; background: rgba(var(--src), .08); border: 1px solid rgba(var(--src), .35); border-radius: 14px; padding: 12px 14px 14px; }
.cam-part[data-src] > .cam-part-h { color: rgb(var(--src)); }
.cam-part[data-src="hikvision"] { --src: 239,83,80; }
.cam-part[data-src="ring"] { --src: 38,198,218; }
.cam-part[data-src="unifi"] { --src: 149,117,255; }
.cam-part[data-src="business"] { --src: 245,166,35; }
html[data-theme="light"] .cam-part[data-src] > .cam-part-h { filter: brightness(.75); }
/* Under All: each band also shows its site (in the site colour) down its left edge */
.cam-sec[data-site][data-src] { border-left: 5px solid var(--site) !important; }

/* Whole boxes alternate colour (not the tiles inside): each site / camera system / section box is clearly its own colour */
.dev-sec[data-site] { background: rgba(var(--site-rgb), .13) !important; border: 1px solid rgba(var(--site-rgb), .55) !important; border-left: 5px solid var(--site) !important; }
.cam-sec[data-src], .cam-part[data-src] { background: rgba(var(--src), .12) !important; border-color: rgba(var(--src), .55) !important; }
[data-band] { background: rgba(var(--band), .11) !important; border-color: rgba(var(--band), .5) !important; }
html[data-theme="light"] .dev-sec[data-site] { background: rgba(var(--site-rgb), .09) !important; }
html[data-theme="light"] :is(.cam-sec, .cam-part)[data-src] { background: rgba(var(--src), .08) !important; }

/* Rename an Echo or an Amazon device */
.rename-row { flex-wrap: wrap; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }

/* Echo window: the music player is one small box */
.ed-mini { display: block; padding: 10px 12px; }
.ed-mini-top { display: flex; align-items: center; gap: 10px; }
.ed-mini .ed-art { width: 40px; height: 40px; border-radius: 9px; font-size: 1.1rem; }
.ed-mini .ed-meta { flex: 1; min-width: 0; }
.ed-mini .ed-title { font-size: .9rem; }
.ed-mini .ed-meta .small { font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-mini .ed-ctl { gap: 6px; flex: none; }
.ed-mini .ed-btn { width: 32px; height: 32px; font-size: .8rem; }
.ed-mini .ed-play { width: 38px; height: 38px; font-size: .95rem; }
.ed-mini-vol { margin-top: 8px; gap: 8px; font-size: .85rem; }
.ed-mini-vol .ed-vnum { font-size: .8rem; min-width: 26px; }

/* ⚙️ Echo settings (inside an Echo's window) */
.es { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.es-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: rgba(255,255,255,.03); border: 0; color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.es-toggle:hover { background: rgba(0,152,251,.08); }
.es-body { padding: 4px 14px 14px; }
.es-sec { margin: 14px 0 4px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.es-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.es-row:last-child { border-bottom: 0; }
.es-l { flex: 1; min-width: 0; }
.es-l .small { overflow-wrap: anywhere; }
.es-slide input[type=range] { flex: 2; }
.es-slide .es-l { flex: 1; }
.es-num { min-width: 42px; text-align: right; font-size: .85rem; }
.es-sw { position: relative; width: 44px; height: 26px; flex: none; }
.es-sw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.es-sw span { position: absolute; inset: 0; border-radius: 13px; background: #2a3a55; transition: background .2s; }
.es-sw span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.es-sw input:checked + span { background: linear-gradient(135deg, #0098FB, #05E0FC); }
.es-sw input:checked + span::after { transform: translateX(18px); }
.es-sw input:disabled { cursor: default; }
.es-sw input:disabled + span { opacity: .5; }
html[data-theme="light"] .es-toggle { background: #F4F7FB; }
html[data-theme="light"] .es-row { border-bottom-color: rgba(11,26,51,.08); }
html[data-theme="light"] .es-sw span { background: #C9D3E2; }

/* Echo window: small routine buttons */
.ed-rt-h { margin: 6px 0 0; font-size: .9rem; }
.rt-grid.rt-small { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.rt-small .rt-btn { padding: 7px 9px; gap: 7px; font-size: .8rem; border-radius: 10px; line-height: 1.2; }
.rt-small .rt-ic { width: 20px; height: 20px; font-size: .6rem; }
@media (max-width: 700px) { .rt-grid.rt-small { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Long routine names wrap inside their small tile instead of spilling out */
.rt-grid.rt-small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.rt-small .rt-btn > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.rt-small .rt-btn { min-width: 0; }
@media (max-width: 700px) { .rt-grid.rt-small { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Home overview: summary line, Needs attention, graphs */
.ov { display: grid; gap: 14px; margin-bottom: 18px; }
.ov-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.ov-chip { display: flex; align-items: baseline; gap: 7px; padding: 10px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.ov-chip b { font-size: 1.15rem; font-family: 'Exo 2', sans-serif; font-style: italic; }
.ov-chip span:last-child { color: var(--muted); font-size: .82rem; }
.ov-chip.warn { border-color: rgba(245,166,35,.5); } .ov-chip.warn b { color: #F5A623; }
.ov-chip.bad { border-color: rgba(255,107,138,.55); } .ov-chip.bad b { color: #FF6B8A; }
.ov-att { border-radius: 14px; padding: 12px 14px; background: rgba(255,107,138,.07); border: 1px solid rgba(255,107,138,.35); }
.ov-att.ok { background: rgba(61,220,151,.07); border-color: rgba(61,220,151,.35); }
.ov-att-h { font-weight: 700; }
.ov-issues { display: grid; gap: 6px; margin-top: 8px; }
.ov-issue { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; font-size: .9rem; padding: 4px 0; }
a.ov-issue:hover { color: #05E0FC; }
.ov-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #F5A623; }
.ov-issue.bad .ov-dot { background: #FF6B8A; }
.ov-gwrap > summary { cursor: pointer; font-weight: 700; padding: 4px 0 10px; list-style: none; }
.ov-gwrap > summary::-webkit-details-marker { display: none; }
.ov-gwrap > summary::after { content: ' ▾'; color: var(--muted); }
.ov-gwrap:not([open]) > summary::after { content: ' ▸'; }
.ov-graphs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 12px; }
.ov-g { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.ov-g-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.ov-g-body { position: relative; min-height: 60px; }
.ov-g-body .chart, .ov-g-body svg { width: 100%; }
.ov-g-body > svg { height: 170px; }
.ov-svg { width: 100%; height: 150px; display: block; }
.ov-svg .axis line { stroke: rgba(255,255,255,.08); }
.ov-svg .axis text { fill: var(--muted); font-size: 11px; }
.ov-empty { padding: 26px 8px; text-align: center; }
.ov-strips { display: grid; gap: 8px; }
.ov-srow { display: flex; align-items: center; gap: 10px; }
.ov-slabel { width: 74px; flex: none; font-weight: 700; font-size: .85rem; }
.ov-cells { flex: 1; display: flex; gap: 1px; height: 18px; min-width: 0; }
.ov-cells i { flex: 1; border-radius: 2px; background: #2a3a55; }
.ov-cells i.up { background: #3DDC97; } .ov-cells i.part { background: #F5A623; } .ov-cells i.down { background: #FF6B8A; }
.ov-axis { display: flex; justify-content: space-between; padding-left: 84px; }
html[data-theme="light"] .ov-svg .axis line { stroke: rgba(11,26,51,.1); }
html[data-theme="light"] .ov-chip, html[data-theme="light"] .ov-g { background: #fff; }
.ov-slabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* site names are the company’s own and can be long */
.ov { margin: 18px 0 0; } /* the dashboard sits below the site tiles */


/* Needs attention as tabs: one per site, the full list of names underneath */
.ov-att-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.ov-att-tab { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.03); color: inherit; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; }
.ov-att-tab[data-site] { border-color: rgba(var(--site-rgb), .45); }
.ov-att-tab.on { background: rgba(var(--site-rgb, 245,166,35), .22); border-color: var(--site, #F5A623); }
.ov-att-n { min-width: 20px; padding: 0 6px; border-radius: 999px; background: #F5A623; color: #1a1300; font-size: .75rem; text-align: center; }
.ov-att-tab.bad .ov-att-n { background: #FF6B8A; color: #2a0010; }
.ov-att-panel { display: grid; gap: 10px; }
.ov-issue { display: block; padding: 0; }
.ov-issue-top { display: flex; align-items: center; gap: 9px; }
.ov-go { margin-left: auto; color: var(--cyan, #05E0FC); text-decoration: none; }
.ov-go:hover { text-decoration: underline; }
.ov-names { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 0 18px; }
.ov-name { padding: 3px 9px; border-radius: 8px; background: rgba(255,255,255,.05); border: 1px solid var(--line); font-size: .8rem; }
html[data-theme="light"] .ov-name, html[data-theme="light"] .ov-att-tab { background: #fff; }

/* Tiles inside a box take that box's colour (one shade, not alternating) */
:is(.dev-sec, .site-sec)[data-site] .dtile:not(.on):not(.offline):not(.sel) { background: rgba(var(--site-rgb), .14); border-color: rgba(var(--site-rgb), .40); }
:is(.dev-sec, .site-sec)[data-site] .dtile:not(.on):not(.offline):not(.sel):hover { border-color: rgb(var(--site-rgb)); }
[data-band] .dtile:not(.on):not(.offline) { background: rgba(var(--band), .14); border-color: rgba(var(--band), .40); }
:is(.cam-sec, .cam-part)[data-src] .cam { border-color: rgba(var(--src), .45); }
:is(.cam-sec, .cam-part)[data-src] .cam.ph { background: repeating-linear-gradient(135deg, rgba(var(--src), .14) 0 12px, rgba(var(--src), .06) 12px 24px); }
html[data-theme="light"] :is(.dev-sec, .site-sec)[data-site] .dtile:not(.on):not(.offline):not(.sel) { background: rgba(var(--site-rgb), .10); }
.ov-issue-top .ov-go { margin-left: 10px; padding: 3px 12px; font-size: .78rem; color: inherit; text-decoration: none; } /* a small button beside the issue */
.ov-issue-top .ov-go:hover { text-decoration: none; }

/* "For information" box: calm blue, not a warning */
.ov-boxes { display: grid; gap: 12px; }
.ov-att.info { background: rgba(0,152,251,.06); border-color: rgba(0,152,251,.3); }
.ov-att.info .ov-att-n { background: #0098FB; color: #fff; }
.ov-issue.info .ov-dot { background: #0098FB; }

/* Summary: cameras broken down per site and camera system */
.ov-cams { align-items: center; flex-wrap: wrap; flex-basis: 100%; }
.ov-cams .ov-cams-l { color: var(--muted); font-size: .82rem; }
.ov-cam-list { display: flex; flex-wrap: wrap; gap: 6px; margin-left: 4px; }
.ov-cam { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 999px; text-decoration: none; color: inherit; border: 1px solid rgba(var(--site-rgb), .45); background: rgba(var(--site-rgb), .12); font-size: .8rem; }
.ov-cam b { font-family: 'Exo 2', sans-serif; font-style: italic; }
.ov-cam.warn b { color: #F5A623; } .ov-cam.bad b { color: #FF6B8A; }
.ov-cam:hover { border-color: var(--site); }

/* Phones: the menu (hamburger) button sits on the right, after the settings cog, and the menu slides in from the right */
@media (max-width: 700px) {
  .top .burger { order: 3; }
  .site-tabs { order: 4; }
  .page-help { order: 5; }
  .shell.drawer-open .side { left: auto; right: 0; box-shadow: -8px 0 30px rgba(0,0,0,.5); animation-name: drawerInRight; }
  .top { column-gap: 6px; }
  .top-right { gap: 4px; }
  .top-right .icon-btn, .top .burger { width: 32px; height: 32px; }
}
@keyframes drawerInRight { from { transform: translateX(100%); } to { transform: none; } }
@media (max-width: 380px) { .top .top-brand span { font-size: .95rem; } }

/* Alerts and Help live in the side menu (the top-bar buttons stay hidden, kept for their handlers) */
#bellBtn, #helpBtn { display: none !important; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 6px; }
.nav-q { width: 20px; height: 20px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1.6px solid currentColor; font-size: .72rem; font-weight: 800; }
.nav-count { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: #FF6B8A; color: #fff; font-size: .72rem; text-align: center; }
button.nav-item { width: 100%; font: inherit; font-weight: 600; }

/* Home overview, compact: Online strips inside the status box; smaller graphs at the bottom */
.ov { gap: 10px; }
.ov-chip { padding: 7px 11px; }
.ov-chip b { font-size: 1rem; }
.ov-att { padding: 10px 12px; }
.ov-online-h { margin: 10px 0 6px; }
.ov-online .ov-cells { height: 14px; }
.ov-online .ov-srow { gap: 8px; }
.ov-online .ov-strips { gap: 5px; }
.ov-gwrap > summary { padding: 2px 0 8px; }
.ov-graphs { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.ov-g { padding: 9px 11px; }
.ov-g-h { margin-bottom: 2px; }
.ov-svg { height: 105px; }
.ov-g-body > svg, .ov-g-body .chart svg { height: 125px; }
.ov-g .legend { font-size: .72rem; margin-top: 2px; }
.ov-empty { padding: 10px 6px; }

/* eWeLink timers: the Add button on the same line as the day buttons */
.tm-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.tm-foot .days { margin: 0; }
.tm-foot .tm-add { margin-left: auto; }

/* Anything in "Needs attention" is red */
.ov-att:not(.ok):not(.info):not(.plain) { background: rgba(255,59,92,.12); border: 1.5px solid rgba(255,59,92,.75); }
.ov-att:not(.ok):not(.info):not(.plain) > .ov-att-h { color: #FF5C7A; }
.ov-att:not(.ok):not(.info):not(.plain) .ov-dot { background: #FF3B5C; }
.ov-att:not(.ok):not(.info):not(.plain) .ov-att-n { background: #FF3B5C; color: #fff; }
.ov-att:not(.ok):not(.info):not(.plain) .ov-att-tab.on { background: rgba(255,59,92,.22); border-color: #FF3B5C; }

/* Every summary chip reads: icon, name, number, then any extra */
.ov-chip .ov-lbl { color: var(--muted); font-size: .82rem; }
.ov-chip > span:last-child:not(.ov-lbl):not(.ov-ic) { color: var(--muted); font-size: .8rem; }

/* Devices page: a small search box */
input.dev-search { width: 150px; max-width: 150px; padding: 6px 10px; font-size: .82rem; border-radius: 10px; height: 32px; }

/* Unreachable devices, Alexas and cameras are greyed out (still tappable, to see details) */
.dtile.offline, :is(.dev-sec, .site-sec)[data-site] .dtile.offline { opacity: .45; filter: grayscale(1); background: #1a2638; border-color: var(--line); }
.dtile.offline:hover { opacity: .7; }
.cam.offline, .cam.ph { opacity: .45; filter: grayscale(1); }
.cam.offline:hover, .cam.ph:hover { opacity: .7; }
html[data-theme="light"] .dtile.offline { background: #EEF1F6; }

/* Timers as tiles, like the devices */
.tm-tile { min-height: 104px; }
.tm-tile .tm-time { font-family: 'Exo 2', sans-serif; font-style: italic; font-size: 1.35rem; line-height: 1; }
.tm-tile .tm-act { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted); }
.tm-tile .tm-act.on { background: linear-gradient(135deg, #0098FB, #05E0FC); color: #031022; }
.tm-tile .dt-st { white-space: normal; }
.tm-tile.paused { opacity: .5; }

/* eWeLink scenes note: one line (the explanation is in its tooltip) */
.ew-note { grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ew-note .link-btn { white-space: nowrap; }

/* Scenes: the eWeLink scenes sit under the iotlinx scenes in the one Scenes box */
.ew-inline { margin-top: 12px; }

/* Needs attention: an issue's details on the same line as the problem */
.ov-issue-top { flex-wrap: wrap; }
.ov-issue-top .ov-names { display: inline-flex; margin: 0 0 0 4px; }

/* Timers window: the Type, When and Action boxes are the same height */
.box.form .inline :is(select, input) { height: 46px; box-sizing: border-box; padding-top: 0; padding-bottom: 0; }

/* Timers window: unsaved changes */
.tm-dirty { margin-right: auto; color: #F5A623; font-size: .82rem; font-weight: 600; }

/* Paused timers say so */
.tm-tile .tm-act.paused { background: rgba(245,166,35,.18); color: #F5A623; }
.tm-paused-txt { color: #F5A623; font-weight: 600; }

/* Timers window: the bottom buttons stay in view while a long list scrolls (the -22px matches the window padding) */
.tm-footer { position: sticky; bottom: -22px; z-index: 3; margin: 16px -22px -22px !important; padding: 12px 22px 16px; background: linear-gradient(180deg, rgba(13,27,52,.85), #0d1b34 40%); border-top: 1px solid var(--line); border-radius: 0 0 20px 20px; }
html[data-theme="light"] .tm-footer { background: #fff; }

/* Needs attention: all tab pages share one cell, so switching tabs doesn't move the page */
.ov-att-panel { display: grid; }
.ov-att-page { grid-area: 1 / 1; display: grid; gap: 10px; align-content: start; }

/* Camera boxes: coloured by SITE like the rest of the app (in each site's own colour), neighbouring boxes alternate
   a lighter / darker shade; the camera system keeps its colour on the heading only */
.cam-sec[data-site][data-src] { background: rgba(var(--site-rgb), .12) !important; border: 1px solid rgba(var(--site-rgb), .5) !important; border-left: 5px solid var(--site) !important; }
.cam-sec[data-site][data-src].cam-alt { background: rgba(var(--site-rgb), .05) !important; border-color: rgba(var(--site-rgb), .3) !important; border-left-color: var(--site) !important; }
.cam-sec[data-site][data-src] .cam { border-color: rgba(var(--site-rgb), .4); }
.cam-sec[data-site][data-src] .cam.ph { background: repeating-linear-gradient(135deg, rgba(var(--site-rgb), .12) 0 12px, rgba(var(--site-rgb), .05) 12px 24px); border-color: rgba(var(--site-rgb), .35); }
html[data-theme="light"] .cam-sec[data-site][data-src] { background: rgba(var(--site-rgb), .08) !important; }
html[data-theme="light"] .cam-sec[data-site][data-src].cam-alt { background: rgba(var(--site-rgb), .03) !important; }
/* Home › a site › Cameras: the same, in that site's colour, alternating shades */
.site-sec .cam-part[data-src] { background: rgba(var(--site-rgb), .12) !important; border-color: rgba(var(--site-rgb), .45) !important; }
.site-sec .cam-part[data-src]:nth-of-type(even) { background: rgba(var(--site-rgb), .05) !important; border-color: rgba(var(--site-rgb), .28) !important; }
.site-sec .cam-part[data-src] .cam { border-color: rgba(var(--site-rgb), .4); }
.site-sec .cam-part[data-src] .cam.ph { background: repeating-linear-gradient(135deg, rgba(var(--site-rgb), .12) 0 12px, rgba(var(--site-rgb), .05) 12px 24px); border-color: rgba(var(--site-rgb), .35); }
html[data-theme="light"] .site-sec .cam-part[data-src] { background: rgba(var(--site-rgb), .08) !important; }
html[data-theme="light"] .site-sec .cam-part[data-src]:nth-of-type(even) { background: rgba(var(--site-rgb), .03) !important; }

/* Summary as tiles like the graphs */
.ov-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.ov-stat { display: flex; flex-direction: column; gap: 4px; }
.ov-stat .ov-g-h b { font-size: .9rem; }
.ov-stat-big { font-family: 'Exo 2', sans-serif; font-style: italic; font-weight: 800; font-size: 1.6rem; line-height: 1.1; }
.ov-stat.warn .ov-stat-big { color: #F5A623; }
.ov-stat.bad .ov-stat-big { color: #FF6B8A; }
.ov-stat.ov-cams { grid-column: 1 / -1; }
.ov-stat.ov-cams .ov-cam-list { margin: 4px 0 0; }
/* Needs attention: ▾ minimise like Graphs */
details.ov-att > summary { cursor: pointer; list-style: none; }
details.ov-att > summary::-webkit-details-marker { display: none; }
details.ov-att > summary::after { content: ' ▾'; color: var(--muted); }
details.ov-att:not([open]) > summary::after { content: ' ▸'; }

.ov-stat.ov-cams { align-items: stretch; }
.ov-stat.ov-cams .ov-g-h { justify-content: flex-start; }

/* The cameras tile: a normal tile, two wide with more than 2 pills (the full row on phones) */
.ov-stat.ov-cams { grid-column: auto; }
.ov-stat.ov-cams.wide { grid-column: span 2; }
@media (max-width: 700px) { .ov-stat.ov-cams.wide { grid-column: 1 / -1; } }

/* Timers: the timer being changed in the box below */
.item.tm-editing { border-color: #05E0FC; box-shadow: 0 0 0 1px #05E0FC inset; }
.tm-edit-txt { color: #05E0FC; font-weight: 600; }
.box.tm-edit-box { border-color: #05E0FC; }

/* Company › Camera keys */
.ck-user { border-top: 1px solid var(--line, rgba(255,255,255,.08)); padding: 10px 0 4px; margin-top: 8px; }
.ck-accesses { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.ck-access { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.ck-dev { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 0; }
.ck-key { display: inline-flex; align-items: center; gap: 6px; }

/* Sign out after no activity: the 10-second note */
.idle-note { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 9999; background: #2A1F05; color: #F5B83D; border: 1px solid rgba(245,184,61,.6); border-radius: 12px; padding: 12px 18px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: calc(100% - 32px); text-align: center; }
.idle-note { display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px 16px; }
.idle-num { font-family: 'Exo 2', sans-serif; font-style: italic; font-weight: 800; font-size: 2rem; line-height: 1; min-width: 2.2ch; text-align: center; color: #F5B83D; }
.idle-txt { flex: 1; }

/* Company › Connections tiles */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 10px; }
.conn-tile { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.conn-tile.conn-wide { grid-column: 1 / -1; }
.conn-tile-h { font-family: 'Exo 2', sans-serif; font-style: italic; font-weight: 700; font-size: 1rem; }
.conn-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.conn-row:first-of-type { border-top: 0; }
.conn-main { flex: 1 1 180px; min-width: 0; }
.conn-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.conn-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.conn-h3 { margin: 18px 0 4px; }

/* QR scanner (camera keys) */
.qr-scan { position: fixed; inset: 0; z-index: 10000; background: rgba(2,6,14,.85); display: flex; align-items: center; justify-content: center; padding: 16px; }
.qr-scan-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.qr-frame { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 1; }
.qr-frame::after { content: ''; position: absolute; inset: 14%; border: 3px solid #05E0FC; border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.qr-video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Company › Camera keys: per camera system */
.ck-keyaccess { display: flex; flex-direction: column; gap: 4px; }
.ck-access.ck-sys { padding-left: 18px; font-size: 12px; }
.ck-access.ck-sys::before { content: '└'; color: var(--muted); margin-right: 2px; }

/* Menu bell: red with new alerts, and Clear */
.nav-alerts-row { display: flex; align-items: center; gap: 6px; }
.nav-alerts-row .nav-item { flex: 1; min-width: 0; }
.nav-item.nav-alerts.has-alerts, .nav-item.nav-alerts.has-alerts svg { color: #FF5C7A; }
.nav-item.nav-alerts.has-alerts span { color: #FF5C7A; font-weight: 700; }
.nav-alerts .nav-count { background: none; color: inherit; padding: 0; min-width: 0; margin: 0; font-size: inherit; }
#bellBtn.has-alerts, #bellBtn.has-alerts svg { color: #FF5C7A; }
.nav-clear { border: 1px solid rgba(255,92,122,.5); background: transparent; color: #FF8BA0; border-radius: 999px; font-size: .72rem; font-weight: 600; padding: 3px 9px; cursor: pointer; }
.nav-clear:hover { background: rgba(255,92,122,.12); }

/* People: each person’s phones and computers */
.u-dev { margin-top: 3px; overflow-wrap: anywhere; }

/* + Invite someone: three steps */
.wz-step { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 10px; margin: 0 0 12px; min-width: 0; transition: opacity .2s; }
.wz-step legend { padding: 0 6px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.wz-step:disabled { opacity: .38; }
.wz-step.done { border-color: rgba(5,224,252,.45); }
.wz-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--blue, #0098FB); color: #fff; font-size: 13px; }
.wz-step:disabled .wz-n { background: rgba(255,255,255,.18); }
.wz-msg { min-height: 1.4em; margin-top: 4px; }
.wz-ok { color: #3BD48B; }
.wz-sum > div { margin: 2px 0; }
.wz-next li { margin: 6px 0; }
.wz-pw { user-select: all; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,.08); }
/* 🧭 Setup (company administrators): one list of what needs doing */
.setup-list { display: flex; flex-direction: column; gap: 8px; }
.setup-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); }
.setup-row.bad { border-color: rgba(245,184,61,.55); }
.setup-row .grow { min-width: 0; }
.setup-ic { font-size: 20px; flex: none; }
.setup-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.setup-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.setup-more { margin-top: 12px; }
.setup-more summary { cursor: pointer; font-weight: 600; }
.setup-fine { margin: 6px 0 0; padding-left: 18px; line-height: 1.7; }
.setup-ov { text-align: left; }
.setup-ov select, .setup-ov input[type=password] { width: 100%; }
.setup-ov label { display: flex; flex-direction: column; gap: 4px; }
.setup-ov label.chk-row, .chk-row { display: flex; flex-direction: row; align-items: flex-start; gap: 8px; text-align: left; }
.chk-row input[type=checkbox] { width: auto; margin-top: 3px; flex: none; }
@media (max-width: 600px) { .setup-row { flex-wrap: wrap; } .setup-btns { width: 100%; justify-content: flex-start; } }
/* 🎨 Layout's two pages, and the Company page's three parts */
.set-tabs.set-sub { margin-top: -8px; background: transparent; border-style: dashed; }
.set-tabs.set-sub .set-tab { font-size: .8rem; }
.set-tabs.co-parts { margin: 0; }
.setup-row.wait { border-color: rgba(5,224,252,.35); }
/* 🛡️ Who has what: one card per person */
.access .acc-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-top: 12px; background: var(--bg2); }
.access .acc-card.warn { border-color: rgba(245,184,61,.55); }
.acc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.acc-head b { font-size: 1.05rem; }
.acc-sec { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.acc-t { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.acc-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 4px 0; font-size: .88rem; }
.acc-dev { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 0; }
.acc-dev + .acc-dev { border-top: 1px dashed var(--line); }
.acc-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.acc-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.access input[type=password], .access input[type=search] { width: 100%; margin-top: 8px; }
.acc-role { margin-top: 18px; }
.acc-does { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; padding: 10px 14px; border-radius: 12px; background: rgba(5,224,252,.06); border: 1px solid rgba(5,224,252,.25); font-size: .85rem; }
.acc-does ul { margin: 0; padding-left: 18px; line-height: 1.55; }
@media (max-width: 700px) { .acc-does { grid-template-columns: 1fr; } }
/* 🧭 Setup: what needs doing, grouped by job; and the numbered steps on 👥 People and 🔐 Camera keys */
.setup-group { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-top: 12px; background: var(--bg2); display: flex; flex-direction: column; gap: 8px; }
.setup-group.bad { border-color: rgba(245,184,61,.55); }
.setup-group-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.setup-group-h b { font-size: 1rem; }
.setup-group-h .btn { margin-left: auto; }
.setup-flow { margin: 4px 0 12px; padding: 10px 14px 10px 32px; border-radius: 12px; background: rgba(5,224,252,.06); border: 1px solid rgba(5,224,252,.25); line-height: 1.6; font-size: .88rem; }
/* Settings on a PC: as wide as the screen allows (a 24px margin each side), tabs on one line; phones keep the full-width card */
@media (min-width: 900px) {
  .modal-card.wide { width: calc(100vw - 48px); max-width: 1800px; max-height: calc(100vh - 48px); }
  .modal-card.wide .set-tabs { flex-wrap: nowrap; }
  .modal-card.wide .conn-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .modal-card.wide .setup-row .grow, .modal-card.wide .acc-head, .modal-card.wide .acc-line { white-space: normal; }
}
/* 🔒 a company user's new phone or PC, until an administrator accepts it */
.card.locked { max-width: 560px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 12px; padding: 22px; }
.card.locked h2 { margin: 0; }
.lock-ways { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lock-ways > div { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.lock-code { font: 700 2rem/1.1 'Exo 2', sans-serif; letter-spacing: .12em; color: var(--cyan, #05E0FC); text-align: center; padding: 8px 0; user-select: all; }
.acc-keys { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 640px) { .lock-ways { grid-template-columns: 1fr; } }
/* Settings in two halves: a caption starts each half (🛠 Admin · 👥 People · 🔑 Me) */
.set-tabs.grouped { flex-wrap: nowrap; align-items: center; }
.set-row { display: flex; align-items: center; gap: 4px; flex: none; }
.set-row + .set-row { border-left: 1px solid var(--line); margin-left: 6px; padding-left: 6px; }
.set-tabs .set-group { flex: none; font-size: .72rem; font-weight: 600; font-style: italic; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.set-tabs .set-group::after { content: ':'; }
/* a phone: one row per group, stacked; the tabs wrap instead of scrolling out of sight */
@media (max-width: 899px) {
  .set-tabs.grouped { flex-direction: column; align-items: stretch; overflow: visible; }
  .set-row { flex-wrap: wrap; }
  .set-row + .set-row { border-left: 0; margin-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 4px; }
  .set-tabs .set-group { flex-basis: 100%; padding: 2px 6px 0; }
  .set-tabs.set-sub { flex-wrap: wrap; overflow: visible; }
}
.setup-half { margin: 18px 0 2px; font-size: .95rem; color: var(--cyan, #05E0FC); }
/* 📍 Sites › a site: each connection, what is there, and Show */
.site-conns { display: flex; flex-direction: column; gap: 8px; }
.site-conn { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); }
.site-conn.off { opacity: .6; }
.site-conn-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-show { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; }
.site-show input { width: 20px; height: 20px; }
/* 📍 Which sites: per site Not this site / See only / See and switch */
.sites-pick { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 6px 0; }
.sites-pick-row { display: flex; align-items: center; gap: 8px; }
.sites-pick-row select { width: auto; }
.wz-sites { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 6px; }
.acc-sites .sites-pick { margin: 0; }

/* 📺 Fire TVs: top 4 in use */
.tv-top { display: flex; flex-direction: column; gap: 12px; }
.tv-row { display: flex; flex-direction: column; gap: 4px; }
.tv-strip { width: 100%; height: 12px; display: block; }

/* a window is open: the page behind does not scroll, and its scrollbar is hidden (only the window scrolls, when it is taller than the screen) */
html:has(#modal:not([hidden])), body:has(#modal:not([hidden])) { overflow: hidden; }
.modal-card { overscroll-behavior: contain; }
/* Settings is not wider than it needs to be: on a PC at most 1180px, centred; on a phone the bottom menu stays visible and usable */
@media (min-width: 900px) { .modal-card.wide { width: min(1180px, calc(100vw - 96px)); max-height: calc(100vh - 64px); } }
@media (max-width: 760px) {
  .modal { bottom: calc(62px + var(--safe-b)); padding: 8px; z-index: 30; }
  .modal-card { max-height: 100%; padding: 16px 14px; border-radius: 16px; }
}
/* Settings menu v2: each section is its own small box with its name on top (ADMIN · YOUR PEOPLE · ME) and its tabs inside */
.set-tabs.grouped { gap: 6px; padding: 0; background: none; border: 0; overflow: visible; flex-wrap: wrap; align-items: stretch; }
.set-tabs.grouped .set-row { flex-wrap: wrap; align-content: flex-start; gap: 3px; padding: 4px 5px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); margin: 0; }
.set-tabs.grouped .set-row + .set-row { border-left: 1px solid var(--line); margin: 0; padding-left: 5px; padding-top: 4px; }
.set-tabs.grouped .set-group { flex-basis: 100%; padding: 0 5px 2px; font-size: .58rem; font-style: normal; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--cyan, #05E0FC); opacity: .8; }
.set-tabs.grouped .set-group::after { content: none; }
.set-tabs.grouped .set-tab { padding: 6px 9px; font-size: .8rem; }
.set-tabs.grouped .set-row:has(.set-tab.on) { border-color: rgba(5,224,252,.45); background: rgba(5,224,252,.06); }
@media (max-width: 899px) {
  .set-tabs.grouped { flex-direction: column; gap: 8px; }
  .set-tabs.grouped .set-tab { flex: 1 1 auto; text-align: center; }
}
@media (max-width: 899px) {
  .set-tabs.grouped .set-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .set-tabs.grouped .set-group { grid-column: 1 / -1; }
  .set-tabs.grouped .set-tab { padding: 8px 4px; font-size: .74rem; white-space: normal; line-height: 1.2; }
}
/* Settings windows: no empty space between the heading, short notes and the content */
.modal-card .form { gap: 10px; }
.modal-card .form > h2 { margin: 0; }
.modal-card .form > p { margin: 0; }
.modal-card .set-tabs { margin-bottom: 12px; }
.modal-card .form > h2 + .setup-half { margin-top: 0; }
/* Settings keeps one size and stays at the top: switching tabs no longer makes the window jump while a page loads */
.modal:has(> .modal-card.wide) { place-items: start center; }
@media (min-width: 900px) { .modal-card.wide { height: calc(100vh - 64px); } .modal:has(> .modal-card.wide) { padding-top: 32px; } }
@media (max-width: 760px) { .modal-card.wide { height: 100%; } }
/* 📍 a site's page: what is here and who may use it */
.site-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: rgba(255,255,255,.03); }
.site-box-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.site-box-h .btn { margin-left: auto; }
.modal-card .set-tabs.grouped { flex-wrap: wrap; } /* the section boxes go to a next line instead of being cut off */
.site-people { display: flex; flex-wrap: wrap; gap: 6px; }
.site-person { font-size: .82rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.site-keys { display: flex; flex-direction: column; gap: 8px; }
.modal-card .set-tabs.set-sub { flex-wrap: wrap; overflow: visible; } /* the sites row wraps instead of scrolling sideways */
/* 📍 a site page: rows with a control (a person's access here, an item's site, a device's key) */
.site-rows { display: flex; flex-direction: column; gap: 6px; }
.site-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .85rem; }
.site-row > :first-child { flex: 1 1 160px; min-width: 0; }
.site-row select { width: auto; min-width: 150px; }
.site-give { padding-top: 6px; border-top: 1px dashed var(--line); }
.site-things > summary { cursor: pointer; color: var(--cyan, #05E0FC); }
.site-things[open] > summary { margin-bottom: 6px; }
.site-box-h .btn { margin-left: 0; } .site-box-h > b { margin-right: auto; } /* the title on the left, its buttons together on the right */
/* ✕ that closes Settings and other windows: big on a PC, small on a phone */
@media (min-width: 761px) {
  .modal-x { width: 50px; height: 50px; font-size: 30px; top: 14px; right: 16px; border-width: 2px; }
  .modal-x:hover { border-color: var(--cyan, #05E0FC); color: var(--cyan, #05E0FC); }
  .modal-card .set-tabs { margin-right: 62px; }
}
@media (max-width: 760px) {
  .modal-x { width: 32px; height: 32px; font-size: 19px; top: 8px; right: 8px; }
  .modal-card .set-tabs { margin-right: 36px; }
}
/* 👥 what administrators do, and what users get and how they are onboarded: side by side on a PC, one under the other on a phone */
.roles-box { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 8px; }
.roles-box > div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgba(255,255,255,.03); font-size: .85rem; }
.roles-box b.rb-h { display: block; font-size: .95rem; margin-bottom: 4px; }
.roles-box ul, .roles-box ol { margin: 4px 0 0; padding-left: 20px; } .roles-box li { margin: 2px 0; }
.roles-box .rb-user { border-color: rgba(5,224,252,.45); }
@media (max-width: 700px) { .roles-box { grid-template-columns: 1fr; } }
/* 📈 Graphs: every card the same height (one row as tall as the next); a card with a longer legend gets a shorter graph, not a taller card */
.ov-graphs { grid-auto-rows: 192px; }
.ov-graphs > .ov-g { display: flex; flex-direction: column; overflow: hidden; }
.ov-graphs > .ov-g > .ov-g-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ov-graphs > .ov-g > .ov-g-body > div:not(.legend):not(.tip), .ov-graphs > .ov-g > .ov-g-body > .chart { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ov-graphs > .ov-g .ov-svg, .ov-graphs > .ov-g .ov-g-body > svg, .ov-graphs > .ov-g .chart svg { flex: 1 1 0; min-height: 44px; height: auto !important; }
.ov-graphs > .ov-g .legend { flex: none; flex-direction: row; flex-wrap: wrap; gap: 2px 12px; line-height: 1.3; }
.ov-graphs > .ov-g .legend + .small, .ov-graphs > .ov-g .ov-g-body .small.muted { flex: none; }
/* 🔐 camera keys per site, and the emergency box */
.ck-site { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.ck-site-h { font-weight: 800; font-size: .95rem; }
.ck-sites-h { margin: 16px 0 4px; font-size: .9rem; color: var(--cyan, #05E0FC); }
.ck-sos { border: 1px solid rgba(255,107,138,.55); background: rgba(255,107,138,.07); border-radius: 12px; padding: 10px 12px; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
/* ❄️ one aircon: the big temperature, ⌄ set ⌃, mode buttons and runtime */
.ac-open { cursor: pointer; }
.ac-detail .ac-big { text-align: center; font: 300 4.2rem/1 'Exo 2', sans-serif; color: var(--cyan, #05E0FC); margin: 10px 0 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ac-detail .ac-big.heat { color: #FF9F43; }
.ac-big-set { display: flex; justify-content: center; align-items: center; gap: 22px; margin: 8px 0; }
.ac-big-set b { font-size: 1.8rem; min-width: 70px; text-align: center; color: var(--cyan, #05E0FC); }
.ac-btn.big { width: 56px; height: 56px; font-size: 1.6rem; border-radius: 50%; }
.ac-modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 4px; }
.ac-mode-btn { border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); border-radius: 12px; padding: 10px 4px; font: inherit; font-weight: 700; cursor: pointer; }
.ac-mode-btn.on { background: linear-gradient(135deg, #0098FB, #05E0FC); color: #031022; border-color: transparent; }
.ac-rt-tot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0; }
.ac-rt-tot b { display: block; font: 300 2rem/1.1 'Exo 2', sans-serif; }
.ac-rt-tot span { color: var(--muted); font-size: .8rem; }

/* 🎨 colour bulb swatches (eWeLink B05, ported from the app) */
.amz-colors { display: flex; flex-wrap: wrap; gap: 10px; }
.amz-sw { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); cursor: pointer; padding: 0; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.amz-sw.on { border-color: #fff; box-shadow: 0 0 0 2px var(--blue), 0 1px 4px rgba(0,0,0,.4); transform: scale(1.08); }

/* Voice control: mic button + listening overlay */
#voiceBtn.listening { background: var(--blue, #0098FB); border-color: var(--blue, #0098FB); color: #fff; }
#voiceBtn.listening svg { fill: #fff; }
#voiceBtn.listening::after { content: ''; position: absolute; inset: -4px; border-radius: 14px; border: 2px solid var(--cyan, #05E0FC); animation: vc-pulse 1.1s ease-out infinite; }
@keyframes vc-pulse { 0% { transform: scale(0.9); opacity: 0.9; } 100% { transform: scale(1.35); opacity: 0; } }
.vc-overlay { position: fixed; inset: 0; z-index: 4000; display: grid; place-items: center; background: rgba(2, 7, 16, 0.72); backdrop-filter: blur(3px); padding: 20px; }
.vc-card { width: 100%; max-width: 420px; background: var(--card, #0b1626); border: 1px solid var(--line, #17293f); border-radius: 18px; padding: 26px 22px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.vc-mic { font-size: 44px; line-height: 1; margin-bottom: 10px; animation: vc-bob 1.3s ease-in-out infinite; }
@keyframes vc-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.vc-text { font-size: 20px; font-weight: 600; min-height: 28px; margin: 4px 0 10px; color: var(--text, #eaf2ff); word-break: break-word; }
.vc-hint { margin: 6px 0 16px; line-height: 1.5; }

/* Menu-names + name fields editor */
.nm-field { display: flex; flex-direction: column; gap: 4px; }
.nm-field > span { font-size: 13px; color: var(--muted, #9fb4cf); }
.nm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 6px 0 4px; }
@media (max-width: 560px) { .nm-grid { grid-template-columns: 1fr; } }

/* ---------- 📶 Bluetooth page (20 Nov 2026) ---------- */
.ble-sum { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.ble-stat { display: flex; flex-direction: column; }
.ble-stat b { font-family: 'Exo 2', sans-serif; font-style: italic; font-size: 1.35rem; color: var(--text); }
.ble-stat span { font-size: .75rem; color: var(--muted); }
.ble-tabs { flex-wrap: wrap; }
.ble-type { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; color: var(--text);
  background: color-mix(in srgb, var(--c) 22%, var(--card)); border: 1px solid color-mix(in srgb, var(--c) 22%, var(--card)); white-space: nowrap; }
.ble-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ble-near { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 18px; align-items: start; }
.ble-near-r { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ble-rooms { gap: 6px; }
.ble-radar { width: 100%; max-width: 380px; display: block; }
.ble-radar .rg { fill: none; stroke: var(--line); stroke-dasharray: 3 4; }
.ble-radar .rl, .ble-hist .rl, .ble-trend .rl { fill: var(--muted); font-size: 10px; }
.ble-radar .me { fill: var(--cyan); }
.ble-radar circle.st { stroke: #fff; stroke-width: 2; }
.ble-list { overflow-x: auto; max-height: 560px; overflow-y: auto; }
.ble-tbl { width: 100%; border-collapse: collapse; font-size: .85rem; }
.ble-tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: .75rem; padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.ble-tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ble-tbl tr.st td { background: color-mix(in srgb, var(--blue) 8%, transparent); }
.ble-ic { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 1.1rem;
  background: color-mix(in srgb, var(--c) 22%, var(--card)); border: 1px solid color-mix(in srgb, var(--c) 22%, var(--card)); }
.ble-item { flex-wrap: wrap; }
.ble-item.st { border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); }
.ble-acts { gap: 6px; }
.ble-acts select { width: auto; padding: 5px 8px; font-size: .82rem; }
.ble-det:not(:empty) { margin-top: 10px; }
.ble-hist { width: 100%; max-width: 680px; display: block; }
.ble-hist .gl, .ble-trend .gl { stroke: var(--line); }
.ble-hist .ln { fill: none; stroke: var(--cyan); stroke-width: 2; }
.ble-trend { width: 100%; display: block; margin-top: 10px; }
.ble-form { display: grid; grid-template-columns: 1fr 1fr 180px auto; gap: 10px; margin-top: 12px; }
.ble-key { border-color: color-mix(in srgb, var(--cyan) 45%, var(--line)); display: flex; flex-direction: column; gap: 10px; }
.ble-code { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; padding: 8px 10px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); word-break: break-all; user-select: all; }
@media (max-width: 860px) {
  .ble-near { grid-template-columns: 1fr; }
  .ble-radar { margin: 0 auto; }
  .ble-form { grid-template-columns: 1fr; }
  .ble-tbl th:nth-child(6), .ble-tbl td:nth-child(6) { display: none; }
}

.ble-pcard { align-items: center; }
.ble-rssi { width: 56px; height: 56px; flex: none; border-radius: 50%; display: grid; place-content: center; text-align: center; line-height: 1.05;
  background: color-mix(in srgb, var(--c) 30%, var(--card)); border: 1px solid color-mix(in srgb, var(--c) 30%, var(--card)); }
.ble-rssi b { font-family: 'Exo 2', sans-serif; font-style: italic; font-size: 1.05rem; color: var(--text); }
.ble-rssi span { font-size: .62rem; color: var(--muted); }
.ble-id { word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: .72rem; }
.ble-acts.col { flex-direction: column; align-items: stretch; }
.ble-raw { margin-top: 8px; display: grid; gap: 4px; font-size: .8rem; }
.ble-raw > div { display: grid; grid-template-columns: 150px 1fr; gap: 8px; }
.ble-raw code, .ble-val { font-family: ui-monospace, Consolas, monospace; font-size: .78rem; word-break: break-all; color: var(--cyan); }
.ble-gatt { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.ble-svc { padding: 8px 10px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--bg2); display: flex; flex-direction: column; gap: 6px; }
.ble-chr { display: flex; gap: 8px; align-items: center; padding-left: 10px; border-left: 2px solid var(--line); }
.ok-t { color: var(--ok); }
@media (max-width: 560px) { .ble-raw > div { grid-template-columns: 1fr; gap: 0; } }.ble-pcard { flex-wrap: wrap; }
@media (max-width: 560px) { .ble-pcard > .ble-acts.col { flex-direction: row; flex-basis: 100%; justify-content: flex-end; } .ble-pcard { gap: 10px; padding: 12px; } }
.ble-body label.row { flex-wrap: nowrap; align-items: flex-start; }
/* ---------- 🔗 Add a Matter device (20 Nov 2026) ---------- */
.matter-step { padding: 10px 12px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--bg2); margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.matter-step .mono, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .72rem; word-break: break-all; }
.matter-add > p.ok { color: var(--ok); } .matter-add > p.err { color: #ffb3c1; }
.qr-scan { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.qr-scan video { width: 100%; max-width: 360px; border-radius: 12px; background: #000; }
/* ---------- 🎯 Find a Bluetooth device (20 Nov 2026) ---------- */
.find-box { display: flex; flex-direction: column; gap: 12px; }
.find-mid { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: center; }
.find-meter { width: 220px; max-width: 70vw; }
.find-meter .trk { fill: none; stroke: var(--bg2); stroke-width: 16; }
.find-meter .val { fill: none; stroke-width: 16; stroke-linecap: round; transition: stroke-dasharray .25s ease, stroke .25s; }
.find-meter .pct { fill: var(--text); font-family: 'Exo 2', sans-serif; font-style: italic; font-size: 44px; font-weight: 700; }
.find-meter .sub { fill: var(--muted); font-size: 13px; }
.find-info { display: flex; flex-direction: column; gap: 6px; min-width: 220px; flex: 1; }
.find-word { font-family: 'Exo 2', sans-serif; font-style: italic; font-size: 1.6rem; font-weight: 700; }
/* ---------- 📶 Proximity view (20 Nov 2026) ---------- */
.prox { position: relative; height: 560px; border-radius: 16px; overflow: hidden; background: color-mix(in srgb, var(--blue) 12%, var(--bg2)); margin-top: 6px; }
.prox-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.prox-bg .z3 { fill: color-mix(in srgb, var(--blue) 22%, var(--bg2)); }
.prox-bg .z2 { fill: color-mix(in srgb, var(--blue) 36%, var(--bg2)); }
.prox-bg .z1 { fill: color-mix(in srgb, var(--blue) 52%, var(--bg2)); }
.prox-zone { position: absolute; left: 10px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 8px; color: var(--text); background: rgba(5,11,23,.45); }
.prox-me { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); font-size: 2rem; }
.prox-dot { position: absolute; transform: translate(-50%, -50%); width: 46px; height: 46px; border-radius: 50%; display: grid; place-content: center; text-align: center; line-height: 1.05; cursor: pointer;
  background: var(--c); border: 1px solid var(--c); color: #fff; font-size: .62rem; padding: 0; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.prox-dot b { font-size: .72rem; } .prox-dot span { opacity: .9; }
.prox-dot:hover, .prox-dot:focus-visible { outline: 2px solid #fff; z-index: 2; }
.prox-empty { position: absolute; top: 45%; width: 100%; text-align: center; }
/* ---------- 🕘 History, ☆ Favourites, 📈 signal sparkline (20 Nov 2026) ---------- */
.ble-ptabs { margin-top: 10px; align-self: flex-start; }
.ble-star { padding: 2px 9px; font-size: 1rem; line-height: 1.2; }
.ble-star.on { color: #FACC15; border-color: rgba(250,204,21,.5); }
.ble-spark { width: 90px; height: 24px; flex: none; }
.ble-spark polyline { fill: none; stroke-width: 2; stroke-linejoin: round; }
.ble-past { opacity: .85; }
/* ---------- ☁ Upload settings, R/N buttons, folding services (20 Nov 2026) ---------- */
.ble-send { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.ble-rn { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-weight: 700; flex: none; }
.ble-rn.on { background: var(--cyan); border-color: var(--cyan); color: #04202a; }
details.ble-svc > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
details.ble-svc > summary::before { content: '▸'; color: var(--muted); margin-right: 4px; }
details.ble-svc[open] > summary::before { content: '▾'; }
@media (max-width: 560px) { .ble-spark { width: 56px; } }

/* ---------- 📱 No sideways scrolling on phones (20 Nov 2026, Johan: "the app scrolls from side to side") ----------
   The Devices page was ~40 px wider than an iPhone: grid "1fr" columns grow to fit their widest content (the category
   buttons, the "86 of 88 online" pill, long brand labels like "Home Assistant"). minmax(0, 1fr) and min-width: 0 let
   them shrink and wrap instead; the brand label shortens with "…"; and nothing may push the page wider than the screen. */
.shell { grid-template-columns: 240px minmax(0, 1fr); }
@media (max-width: 760px) { .shell { grid-template-columns: minmax(0, 1fr); } }
.shell > *, main, #view, #view > *, .card, .card-h > * { min-width: 0; }
.cat-chips { min-width: 0; flex: 1 1 auto; }
.brand-tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
html, body { max-width: 100%; overflow-x: hidden; }
main { overflow-x: clip; }
.dt-top > .row { min-width: 0; flex: 0 1 auto; overflow: hidden; } .dt-top > .row > * { min-width: 0; flex-shrink: 1; } /* a long brand label (HOME ASSISTANT) shortens inside the tile */

/* 📱 iPhone zoomed in when a text box was tapped (its text was under 16 px), and the page then slid sideways (Johan, 20 Nov 2026) */
@media (max-width: 760px), (pointer: coarse) { input, select, textarea { font-size: 16px; } }
/* 🪟 iotlinx dialogs; the empty Bluetooth box is a button (20 Nov 2026) */
.ix-dialog b { font-size: 1rem; line-height: 1.35; }
.ix-dialog input { margin-top: 4px; }
.ble-start { width: 100%; cursor: pointer; font: inherit; color: var(--cyan); background: transparent; }
.ble-start:hover, .ble-start:focus-visible { border-color: var(--cyan); background: color-mix(in srgb, var(--cyan) 8%, transparent); }
/* iotlinx dialogs (same look as the app) */
.pw-ask { position: fixed; inset: 0; z-index: 9999; background: rgba(2, 6, 14, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pw-ask-card { width: min(380px, 100%); background: var(--bg2, #0A1528); border: 1px solid rgba(5, 224, 252, .35); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }

/* 🔌 Connections for a new company (20 Nov 2026) */
.conn-welcome { padding: 12px 14px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--bg2); margin-bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.conn-add-d > summary { list-style: none; display: inline-flex; cursor: pointer; }
.conn-add-d > summary::-webkit-details-marker { display: none; }
.conn-add-d[open] { flex-basis: 100%; }

/* 🖥 Booth display (#kiosk): no menus, large type, a small bar with the page name */
body.kiosk header.top, body.kiosk aside.side, body.kiosk #nav, body.kiosk #tabbar, body.kiosk .sec-nav, body.kiosk .drawer-back { display: none !important; }
body.kiosk .shell, body.kiosk main { grid-template-columns: minmax(0, 1fr) !important; }
body.kiosk #view { font-size: 1.18rem; padding-bottom: 70px; }
.kiosk-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; align-items: center; gap: 16px; padding: 10px max(16px, env(safe-area-inset-left, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)); background: rgba(5, 11, 23, .92); border-top: 1px solid rgba(0, 152, 251, .4); color: #E6F0FB; }
.kiosk-bar #kioskLabel { font-family: 'Exo 2', sans-serif; font-style: italic; font-weight: 700; font-size: 1.3rem; color: #05E0FC; }
.kiosk-bar .kiosk-hint { flex: 1; opacity: .7; }
.kiosk-bar .kiosk-x { background: transparent; border: 1px solid rgba(255, 255, 255, .25); color: inherit; border-radius: 999px; width: 40px; height: 40px; font-size: 1rem; cursor: pointer; }

/* 📦 the box landing page: 1-2-3 (20 Nov 2026) */
.box-land { list-style: none; counter-reset: bl; margin: 10px 0 4px; padding: 0; display: grid; gap: 8px; text-align: left; }
.box-land li { counter-increment: bl; display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,152,251,.06); }
.box-land li::before { content: counter(bl); grid-row: span 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: linear-gradient(135deg, #0098FB, #05E0FC); color: #031022; }
.box-land li span { font-size: .8rem; color: var(--muted); }
.box-choose { display: grid; gap: 10px; margin-top: 6px; }
.box-choose p { margin: 4px 0 0; text-align: center; }
.box-choose .btn { width: 100%; padding: 14px; font-size: 1rem; }
.login-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }

/* no underlined links anywhere (Johan's rule, as in the iotlinx app): what can be clicked is a button or a pill */
a { text-decoration: none; }
#noAccountP a, #forgotP a, .login-card p a, .keep-row a { display: inline-block; padding: 3px 12px; border: 1px solid rgba(5,224,252,.45); border-radius: 999px; color: #05E0FC; font-weight: 600; }
