@font-face { font-family: "Geist"; src: url("brand/fonts/Geist-Variable.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("brand/fonts/GeistMono-Variable.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
:root {
  --bg: #f7f5f0; --surface: #ffffff; --surface-2: #f2efe8; --surface-3: #ebe7de;
  --ink: #1c2420; --ink-2: #39433e; --muted: #5d6762; --line: #e0dcd2; --line-2: #cfcabe;
  --rail: #143d2e; --rail-2: #1b4b39; --rail-ink: #eaf2ed; --rail-muted: #a3bcb0; --rail-line: #2a5a47;
  --teal: #0f766e; --teal-2: #0b5f58; --teal-soft: #e3f2ef;
  --amber: #8a4b06; --amber-bg: #fdf3e1; --amber-line: #efc57a;
  --fault: #a8231a; --fault-bg: #fdecea; --fault-line: #f0b4ae;
  --ok: #276347; --ok-bg: #e7f3ec; --ok-line: #b5d8c3;
  --unknown: #5f646b; --unknown-bg: #eeeeeb; --unknown-line: #d3d3cf;
  --held: #5b5486; --held-bg: #efedf7; --held-line: #cfcae6;
  --lab: #4b3f8f; --preview: #59626b;
  --radius: 8px; --gap: 16px;
  --font: "Geist", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
.num, time, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
a { color: var(--teal-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; white-space: nowrap; }
.brand img { width: 26px; height: 26px; }
.brand small { font-weight: 400; color: var(--muted); }
.site { display: flex; flex-direction: column; line-height: 1.2; flex-shrink: 0; max-width: 220px; }
.site strong { font-size: 15px; }
.site span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modechip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; letter-spacing: .02em; white-space: nowrap; }
.modechip.lab { background: var(--lab); color: #fff; background-image: repeating-linear-gradient(135deg, transparent 0 7px, rgba(255,255,255,.14) 7px 14px); }
.modechip.preview { background: transparent; color: var(--preview); border: 2px dashed var(--preview); }
.modechip.site { background: var(--rail); color: #fff; }
.modechip.site::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; min-width: 0; flex: 0 1 auto; }
.conn .label { overflow: hidden; text-overflow: ellipsis; }
.brand, .modechip, .topnav, .role { flex-shrink: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.up { background: var(--ok); } .dot.down { background: var(--fault); }
.spacer { flex: 1; }
.topnav { display: flex; gap: 4px; }
.topnav a { text-decoration: none; color: var(--ink-2); padding: 8px 12px; border-radius: 6px; font-size: 14px; }
.topnav a:hover { background: var(--surface-2); }
.topnav a[aria-current="page"] { background: var(--teal-soft); color: var(--teal-2); font-weight: 600; }
.role { font-size: 13px; color: var(--muted); white-space: nowrap; }
.role strong { color: var(--ink); }

.modeband { padding: 6px 20px; font-size: 13px; border-bottom: 1px solid var(--line); }
.modeband.lab { background: #efecf9; color: #352c6e; background-image: repeating-linear-gradient(135deg, transparent 0 12px, rgba(75,63,143,.06) 12px 24px); }
.modeband.preview { background: #eef0f2; color: #3e464e; border-bottom: 1px dashed var(--preview); }
.modeband.site { background: #e6efe9; color: var(--rail); }
.modeband b { font-weight: 650; }
.modeband .errs { color: var(--fault); margin-left: 8px; }

/* ---------- shell ---------- */
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar, .modeband { flex: none; }
html { overflow: hidden; }
.rail, .main, .inspector { position: relative; }
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr) 440px; flex: 1; min-height: 0; }
.rail { background: var(--rail); color: var(--rail-ink); overflow-y: auto; padding: 14px 10px 24px; }
.main { overflow-y: auto; padding: 20px 24px 40px; outline: none; }
.inspector { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; }

/* ---------- rail ---------- */
.rail h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--rail-muted); font-weight: 600; margin: 14px 8px 8px; }
.rail .search { width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--rail-line); background: var(--rail-2); color: var(--rail-ink); }
.rail .search::placeholder { color: var(--rail-muted); }
.rail ul { list-style: none; margin: 0; padding: 0; }
.room { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; color: var(--rail-ink); padding: 9px 10px; border-radius: 6px; cursor: pointer; min-height: 44px; }
.room:hover { background: var(--rail-2); }
.room[aria-current="true"] { background: #f7f5f0; color: var(--ink); }
.room[aria-current="true"] .rcount { color: var(--muted); }
.room .rname { flex: 1; min-width: 0; }
.room .rname span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .rcount { font-size: 12px; color: var(--rail-muted); }
.badge { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 22px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.badge.fault { background: var(--fault-bg); color: var(--fault); }
.badge.attention { background: var(--amber-bg); color: var(--amber); }
.badge.unknown { background: var(--unknown-bg); color: var(--unknown); }
.rail .views a { display: block; color: var(--rail-ink); text-decoration: none; padding: 9px 10px; border-radius: 6px; }
.rail .views a:hover { background: var(--rail-2); }
.rail .views a[aria-current="page"] { background: var(--rail-2); box-shadow: inset 3px 0 0 #2bb3a3; }

/* ---------- state chip ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.chip::before { content: ""; width: 9px; height: 9px; flex: none; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); } .chip.ok::before { background: var(--ok); border-radius: 50%; }
.chip.attention { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); } .chip.attention::before { background: var(--amber); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.chip.fault { background: var(--fault-bg); color: var(--fault); border-color: var(--fault-line); } .chip.fault::before { background: var(--fault); }
.chip.unknown, .chip.stale, .chip.error { background: var(--unknown-bg); color: var(--unknown); border-color: var(--unknown-line); } .chip.unknown::before, .chip.stale::before, .chip.error::before { border: 2px solid var(--unknown); border-radius: 50%; width: 5px; height: 5px; }
.chip.held { background: var(--held-bg); color: var(--held); border-color: var(--held-line); } .chip.held::before { background: var(--held); transform: rotate(45deg) scale(.8); }
.chip.inventory, .chip.not-connected, .chip.not-commissioned, .chip.neutral { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); } .chip.inventory::before, .chip.not-connected::before, .chip.not-commissioned::before, .chip.neutral::before { border: 2px dashed var(--muted); border-radius: 50%; width: 5px; height: 5px; }
.chip.confirmed { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); } .chip.confirmed::before { content: "✓"; width: auto; height: auto; font-size: 12px; }
.chip.accepted { background: var(--teal-soft); color: var(--teal-2); border-color: #b8dcd6; } .chip.accepted::before { content: "→"; width: auto; height: auto; }
.chip.unverified { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); } .chip.unverified::before { content: "?"; width: auto; height: auto; font-weight: 800; }
.chip.rejected, .chip.not-delivered, .chip.refused { background: var(--fault-bg); color: var(--fault); border-color: var(--fault-line); } .chip.rejected::before, .chip.not-delivered::before, .chip.refused::before { content: "✕"; width: auto; height: auto; font-size: 12px; }
.chip.expired { background: var(--unknown-bg); color: var(--unknown); } .chip.expired::before { content: "⌛"; width: auto; height: auto; font-size: 11px; }
.chip.human { background: #fff; color: var(--ok); border: 2px solid var(--ok); } .chip.human::before { content: "👤"; width: auto; height: auto; font-size: 11px; }
.chip.queued, .chip.sending { background: var(--surface-2); color: var(--ink-2); } .chip.queued::before, .chip.sending::before { border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; width: 7px; height: 7px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chip::before { animation: none !important; } }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 40px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn.primary:hover { background: var(--teal-2); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--teal-2); }
.btn.quiet:hover { background: var(--teal-soft); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; min-height: 38px; cursor: pointer; border-right: 1px solid var(--line); font-size: 14px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--teal-soft); color: var(--teal-2); font-weight: 650; box-shadow: inset 0 -3px 0 var(--teal); }
input[type="text"], input[type="number"], input[type="search"], input[type="password"], select, textarea { padding: 8px 10px; min-height: 40px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); }
input[type="number"] { width: 110px; font-variant-numeric: tabular-nums; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--ink); font-size: 15px; }

/* ---------- main: room ---------- */
.roomhead { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.roomhead .title { flex: 1; min-width: 240px; }
.roomhead .title p { color: var(--muted); margin-top: 4px; }
.roomhead .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.questions { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--gap); margin-bottom: 22px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card > header { padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 8px; }
.card > .body { padding: 0 16px 14px; }
.headline { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 6px; font-weight: 600; }
.headline.ok { background: var(--ok-bg); color: var(--ok); }
.headline.attention { background: var(--amber-bg); color: var(--amber); }
.headline.fault { background: var(--fault-bg); color: var(--fault); }
.headline.unknown, .headline.not-connected { background: var(--unknown-bg); color: var(--ink-2); }
.readings { width: 100%; border-collapse: collapse; font-size: 14px; }
.readings th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.readings td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--surface-3); vertical-align: top; }
.readings tr:last-child td { border-bottom: 0; }
.readings .dev { font-weight: 600; }
.readings .dev small { display: block; font-weight: 400; color: var(--muted); }
.readings button.link { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 600; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.readings button.link:hover { text-decoration-color: var(--teal); }
.val { font-weight: 650; }
details.more { margin-bottom: 22px; }
details.more > summary { cursor: pointer; font-weight: 600; padding: 8px 0; color: var(--ink-2); }
details.more .questions { margin-top: 8px; }

/* ---------- inventory ---------- */
.inv { margin-top: 4px; }
.invtools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0 12px; }
.invtools input[type="search"] { flex: 1; min-width: 220px; }
.invtable { width: 100%; table-layout: auto; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.invtable th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.invtable td { padding: 10px 12px; border-bottom: 1px solid var(--surface-3); vertical-align: top; font-size: 14px; }
.invtable tbody tr { cursor: pointer; }
.invtable tbody tr:hover { background: #fbfaf6; }
.invtable tbody tr[aria-selected="true"] { background: var(--teal-soft); box-shadow: inset 4px 0 0 var(--teal); }
.invtable tbody tr:focus-visible { outline: 3px solid var(--teal); outline-offset: -3px; }
.invtable .name { font-weight: 600; }
.invtable .sub { color: var(--muted); font-size: 13px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- inspector ---------- */
.insp-empty { padding: 40px 28px; color: var(--muted); }
.insp-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.insp-head .row { display: flex; gap: 10px; align-items: flex-start; }
.insp-head h2 { font-size: 19px; flex: 1; }
.insp-head .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.insp-head .bar { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.sec { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sec > h3 { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.sec > h3 .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.iface { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.iface h4 { font-size: 14px; display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.twostate { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.twostate > div { background: var(--surface-2); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.twostate b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.control { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.control .chead { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.control .cur { font-size: 14px; color: var(--ink-2); margin: 4px 0 10px; }
.control .crow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reasons { margin: 8px 0 0; padding: 8px 10px 8px 26px; background: var(--surface-2); border-radius: 6px; font-size: 13px; color: var(--ink-2); }
.outcome { margin-top: 10px; border-left: 3px solid var(--line-2); padding: 6px 0 6px 12px; font-size: 14px; }
.outcome.confirmed { border-color: var(--ok); } .outcome.unverified { border-color: var(--amber); } .outcome.rejected, .outcome.not-delivered, .outcome.refused { border-color: var(--fault); } .outcome.accepted { border-color: var(--teal); }
.outcome ol { margin: 6px 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.outcome .humanrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.diff { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; background: var(--surface-2); padding: 10px; border-radius: 6px; margin-top: 8px; }
.diff dt { color: var(--muted); }
.diff dd { margin: 0; font-weight: 600; }
.hist { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.hist li { padding: 7px 0; border-bottom: 1px solid var(--surface-3); display: grid; grid-template-columns: 74px 1fr; gap: 8px; }
.hist time { color: var(--muted); }
.note { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-radius: 6px; padding: 8px 10px; }
.note.owned { background: var(--held-bg); color: #3f386b; }
.linkrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--surface-3); }
.linkrow:last-child { border-bottom: 0; }
.back { display: none; }

/* ---------- activity / coverage / import ---------- */
.page h1 { margin-bottom: 4px; }
.page > p { color: var(--muted); margin-bottom: 16px; max-width: 760px; }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.dtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.dtable th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 9px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.dtable td { padding: 8px 10px; border-bottom: 1px solid var(--surface-3); vertical-align: top; }
.cov { display: grid; gap: var(--gap); }
.cov .card header { padding-bottom: 6px; }
.cov ul { margin: 0; padding-left: 0; list-style: none; }
.cov li { padding: 6px 0; border-bottom: 1px solid var(--surface-3); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.cov .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.cov h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 6px 0; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; font-size: 13px; color: var(--muted); }
.stat b { display: block; font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; }
.mobilebar { display: none; }

/* ---------- tablet (11-inch landscape ~1194px, portrait ~834px) ---------- */
@media (max-width: 1360px) {
  .shell { grid-template-columns: 232px minmax(0, 1fr) 400px; }
}
@media (max-width: 1280px) {
  .shell { grid-template-columns: 216px minmax(0, 1fr); }
  .inspector { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 92vw); box-shadow: -12px 0 32px rgba(20, 30, 25, .18); transform: translateX(105%); transition: transform .2s ease; z-index: 30; }
  .inspector.open { transform: none; }
  .back { display: inline-flex; }
  .topnav a { padding: 8px; }
  .brand small { display: none; }
}
/* ---------- small screens: list first, direct path to inspector ---------- */
@media (max-width: 820px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .topnav, .role, .conn .label { display: none; }
  html { overflow: visible; }
  body { display: block; height: auto; overflow: visible; }
  .shell { display: block; height: auto; }
  .rail { padding: 10px 12px; }
  .rail .roomlist { display: none; }
  .rail.expanded .roomlist { display: block; }
  .main { padding: 16px 16px 90px; overflow: visible; }
  .inspector { top: 0; width: 100vw; z-index: 40; }
  .questions { grid-template-columns: minmax(0, 1fr); }
  .questions > * { min-width: 0; }
  .brand > span, .site > span { display: none; }
  .site { max-width: 40vw; overflow: hidden; }
  .site strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .modechip { font-size: 12px; padding: 3px 8px; }
  .topbar { overflow: hidden; }
  .invtable .hide-sm { display: none; }
  .mobilebar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; gap: 8px; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--line); z-index: 25; align-items: center; }
  .mobilebar .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .kv { grid-template-columns: 110px 1fr; }
  .modeband { padding: 6px 12px; }
  /* list first on small screens, then the room questions */
  .main.roomview { display: flex; flex-direction: column; }
  .main.roomview .roomhead { order: 0; }
  .main.roomview .inv { order: 1; margin-bottom: 22px; }
  .main.roomview .questions { order: 2; }
  .main.roomview details.more { order: 3; }
  .roomhead .actions { width: 100%; }
  /* stacked reading rows: device | value, reading | observed */
  .readings thead { display: none; }
  .readings tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--surface-3); }
  .readings td { border: 0; padding: 1px 0; }
  .readings td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .readings td:nth-child(2) { grid-column: 1; grid-row: 2; color: var(--muted); }
  .readings td:nth-child(3) { grid-column: 2; grid-row: 1; text-align: right; }
  .readings td:nth-child(4) { grid-column: 2; grid-row: 2; text-align: right; }
  .readings.r3 td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; color: inherit; }
  .readings.r3 td:nth-child(3) { grid-column: 2; grid-row: 2; text-align: right; }
  .readings td[colspan] { grid-column: 2; grid-row: 1 / span 2; }
  .insp-head { padding: 12px 16px; }
  .sec { padding: 14px 16px; }
  .twostate { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .inspector { transition: none; } }
label.field > select, label.field > textarea, label.field > input[type="text"] { width: 100%; max-width: 100%; }
.diff dd, .diff dt { min-width: 0; overflow-wrap: anywhere; }
.inspector .crow > label.field { flex: 1; min-width: 120px; }

/* ---------- branding, sign-in, account ---------- */
.brand .logo { width: auto; max-width: 160px; object-fit: contain; display: block; }
.brandtext { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brandtext strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.brandtext small { font-weight: 400; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.sitepick select { min-height: 36px; max-width: 240px; font-weight: 600; }
.account { position: relative; flex-shrink: 0; }
.account > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.account > summary::-webkit-details-marker { display: none; }
.account > summary:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--rail); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.acctname { font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .menu { position: absolute; right: 0; top: calc(100% + 6px); width: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(20, 30, 25, .16); padding: 14px; z-index: 40; }
.account .menu input { width: 100%; margin-bottom: 6px; }
body.authmode .topbar, body.authmode .modeband, body.authmode .rail, body.authmode .inspector, body.authmode .mobilebar { display: none; }
body.authmode .shell { grid-template-columns: 1fr; }
.authwrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.authcard { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 14px; box-shadow: 0 8px 30px rgba(20, 30, 25, .08); }
.authcard input { width: 100%; }
.authbrand { display: flex; gap: 12px; align-items: center; }
.authcard h2 { font-size: 18px; }
.autherr { color: var(--fault); font-size: 14px; min-height: 1px; }
.hint { color: var(--muted); font-size: 12px; }

/* ---------- admin ---------- */
.shell.adminmode { grid-template-columns: minmax(0, 1fr); }
.shell.adminmode .rail, .shell.adminmode .inspector { display: none; }
.page.admin { max-width: 1120px; display: grid; gap: 16px; }
.page.admin > p { margin-bottom: 0; }
.card.pad { padding: 18px 20px; display: grid; gap: 10px; }
.card.pad > h2 { margin-bottom: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ccard { display: flex; gap: 14px; align-items: center; padding: 14px; text-decoration: none; color: inherit; }
.ccard:hover { border-color: var(--line-2); box-shadow: 0 4px 14px rgba(20, 30, 25, .06); }
.swatch { width: 56px; height: 56px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; padding: 6px; }
.swatch .logo { max-width: 44px; max-height: 44px; background: #fff; border-radius: 6px; padding: 3px; }
.phead { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--teal-2); }
.tabs { align-self: start; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label.field { min-width: 160px; flex: 1 1 180px; }
.row > label.field > input, .row > label.field > select { width: 100%; }
.dtable td.actions { white-space: nowrap; text-align: right; }
.dtable td.actions .btn + .btn { margin-left: 6px; }
.btn.danger { color: var(--fault); border-color: var(--fault-line); }
.btn.danger:hover { background: var(--fault-bg); }
section.danger { border-color: var(--fault-line); }
.brandgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.brandgrid form { display: grid; gap: 12px; }
.brandgrid .field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input[type="color"] { width: 48px; height: 40px; padding: 2px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); }
.bpreview { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.bp-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.bp-body { display: grid; grid-template-columns: 130px 1fr; min-height: 150px; }
.bp-rail { padding: 10px 8px; display: grid; gap: 6px; align-content: start; }
.bp-room { color: #fff; font-size: 13px; padding: 6px 8px; border-radius: 5px; }
.bp-room.on { background: var(--bg); color: var(--ink); }
.bp-main { padding: 14px; }
.roomadmin { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.roomadmin + .roomadmin { margin-top: 8px; }
.roomadmin > summary { cursor: pointer; padding: 4px 0; }
.roombody { display: grid; gap: 8px; margin-top: 8px; }
.adddev > summary { cursor: pointer; color: var(--teal-2); font-weight: 600; padding: 6px 0; }
.devform { display: grid; gap: 10px; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.devform .crow > label.field { min-width: 150px; }
@media (max-width: 820px) {
  .brandgrid { grid-template-columns: 1fr; }
  .acctname, .sitepick, .brandtext small { display: none; }
  .dtable td.actions { white-space: normal; }
}

/* ---------- TK Software credit ---------- */
.tkcredit { display: inline-flex; flex-direction: column; gap: 6px; text-decoration: none; padding: 8px; border-radius: 6px; }
.tkcredit img { width: 112px; min-width: 100px; height: auto; display: block; }
.tkcredit .tklabel { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.tkcredit.light .tklabel { color: #5a5750; }
.tkcredit.dark .tklabel { color: rgba(243, 238, 229, .78); }
.tkcredit:hover.light { background: var(--surface-2); }
.tkcredit:hover.dark { background: rgba(255, 255, 255, .06); }
.railcredit { margin: 28px 2px 0; }
.authwrap { flex-direction: column; gap: 22px; }
.authcredit { align-items: center; }
.pagefoot { max-width: 1120px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.menucredit { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.menucredit .tkcredit { padding: 0; }
@media (max-width: 820px) { .rail .railcredit { display: none; } .rail.expanded .railcredit { display: inline-flex; } }
.card.pad > .btn { justify-self: start; }
