/* UONO Cloud — styles. Dark by default, light via the header toggle. Fonts are self-hosted (Barlow, SIL OFL). */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-display: swap; src: url("../fonts/barlow-semi-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); }

:root, [data-theme="dark"] {
  --bg: #091923;
  --bg-2: #0c202c;
  --panel: #0f2632;
  --panel-2: #14303f;
  --line: #1f4657;
  --line-2: #2c6077;
  --ink: #e7f3f6;
  --ink-2: #9fbfca;
  --ink-3: #6e909c;
  --teal: #22d3c5;
  --blue: #47a3ff;
  --ok: #34d399;
  --alarm: #ff5468;
  --fault: #ffa726;
  --off: #587682;
  --on-accent: #032622;
  --hexline: rgba(34, 211, 197, .07);
  --shadow: 0 0 0 1px rgba(0,0,0,.2);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #edf4f6;
  --bg-2: #e4eef1;
  --panel: #ffffff;
  --panel-2: #f3f8f9;
  --line: #cddfe5;
  --line-2: #a9c5cf;
  --ink: #0c2530;
  --ink-2: #41616d;
  --ink-3: #6b8993;
  --teal: #08988d;
  --blue: #1a68c9;
  --ok: #0f9060;
  --alarm: #d42a44;
  --fault: #b86f00;
  --off: #8aa3ad;
  --on-accent: #ffffff;
  --hexline: rgba(8, 152, 141, .09);
  --shadow: 0 0 0 1px rgba(12,37,48,.03);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 "Barlow", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif; font-weight: 600; letter-spacing: .005em; margin: 0; line-height: 1.15; }
h1 { font-size: 32px; }
h2 { font-size: 20px; }
h3 { font-size: 18px; }
p { margin: 0 0 12px; }
code { font: 500 .88em ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--panel-2); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.right { text-align: right; }
.inline { display: inline; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 58px; display: flex; align-items: center; gap: 22px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.mark { color: var(--teal); flex: none; }
.brand-text { font: 600 21px/1 "Barlow Semi Condensed", sans-serif; letter-spacing: .02em; }
.brand-text span { font-weight: 500; color: var(--ink-2); }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--ink-2); padding: 7px 12px; border-radius: 6px; font-weight: 500; }
.nav a:hover { color: var(--ink); background: var(--panel); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--teal); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.who-name { font-weight: 500; font-size: 14px; }
.who-role { font-size: 12.5px; color: var(--ink-3); }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--ink-2); width: 36px; height: 36px; border-radius: 6px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 26px 20px 64px; flex: 1; }
.wrap.narrow { max-width: 760px; }
.foot { display: flex; justify-content: center; gap: 28px; flex-wrap: wrap; padding: 18px 20px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13.5px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 6px 0 0; }
.crumbs { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-3); margin-bottom: 14px; }
.crumbs a { color: var(--ink-2); }
.block { margin-top: 30px; }
.block-head, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; margin-top: 26px; box-shadow: var(--shadow); }
.panel.pad { margin-top: 20px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 20px; align-items: start; }
.two-col > .panel { margin-top: 26px; }
.empty { color: var(--ink-3); padding: 14px 0; margin: 0; }
li.empty { list-style: none; }

/* ---------- buttons, forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 15px; border-radius: 6px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); font-weight: 500; font-size: 15px; line-height: 1.2; font-family: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--teal); text-decoration: none; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--alarm); border-color: var(--alarm); color: #fff; font-weight: 600; }
.btn.danger-ghost { background: transparent; color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 45%, var(--line)); }
.btn.sm { padding: 5px 11px; font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font: inherit; font-size: 15px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 22%, transparent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--teal); }
label { display: block; font-size: 14.5px; color: var(--ink-2); margin: 14px 0 5px; }
label.check, .checks label, .radios label { display: flex; gap: 10px; align-items: center; color: var(--ink); margin: 8px 0; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 8px 16px 10px; margin: 18px 0 0; }
legend { padding: 0 6px; color: var(--ink-2); font-size: 14.5px; }
.hint { color: var(--ink-3); font-size: 13.5px; margin: 5px 0 0; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; }
.form.pad { padding: 8px 22px 22px; }
.mono-in { font: 500 14px ui-monospace, Consolas, monospace; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input { flex: 1 1 260px; width: auto; }
.danger-zone { border-color: color-mix(in srgb, var(--alarm) 40%, var(--line)); }
.search input { width: 300px; max-width: 100%; }

.notice { padding: 11px 14px; border-radius: 6px; margin: 0 0 16px; border: 1px solid; }
.notice.bad { background: color-mix(in srgb, var(--alarm) 14%, var(--panel)); border-color: color-mix(in srgb, var(--alarm) 50%, var(--line)); }
.notice.good { background: color-mix(in srgb, var(--ok) 14%, var(--panel)); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.banner { margin: 0 0 16px; padding: 11px 16px; border-radius: 6px; background: color-mix(in srgb, var(--fault) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--fault) 50%, var(--line)); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.panel .table-wrap { border: 0; background: none; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; font-size: 14px; color: var(--ink-3); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl .num { text-align: right; }
.tbl.compact td, .tbl.compact th { padding: 7px 12px; font-size: 14px; }
.tbl tr.dim td { opacity: .55; }
.tag { display: inline-block; font-size: 12.5px; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); }
.tag.warn { color: var(--fault); border-color: color-mix(in srgb, var(--fault) 50%, var(--line)); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; margin: 14px 0 6px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.status-line { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; }

/* ---------- hexagon status glyph ---------- */
.hex { --c: var(--off); flex: none; width: 24px; height: 26px; background: var(--c); display: inline-block; vertical-align: middle;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.hex.sm { width: 16px; height: 18px; }
.hex[data-state="online"], .hex[data-state="ok"] { --c: var(--ok); }
.hex[data-state="alarm"] { --c: var(--alarm); }
.hex[data-state="fault"] { --c: var(--fault); }
.hex[data-state="offline"], .hex[data-state="blocked"], .hex[data-state="unknown"] { --c: var(--off); }
.hex[data-state="info"] { --c: var(--blue); }

/* ---------- sign in ---------- */
body.auth { background: var(--bg); }
.auth-wrap { flex: 1; display: grid; place-items: center; padding: 30px 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cpath d='M28 2 54 17v30L28 62 2 47V17zM28 64 54 79M2 79 28 64M28 62v35' fill='none' stroke='%2322d3c5' stroke-opacity='.10'/%3E%3C/svg%3E"); }
.auth-card { width: min(410px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 32px 30px 30px; }
.auth-card h1 { font-size: 28px; margin: 8px 0 4px; }
.auth-mark { color: var(--ink); }
.auth-card .btn.block { margin-top: 22px; padding: 11px; font-size: 16px; }

/* ---------- fleet ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { display: inline-flex; align-items: center; gap: 9px; padding: 7px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; font-size: 15px; line-height: 1; font-family: inherit; cursor: pointer; }
.chip b { font: 600 15px/1 "Barlow Semi Condensed", sans-serif; color: var(--ink); }
.chip:hover { border-color: var(--line-2); }
.chip[aria-pressed="true"] { background: var(--panel-2); border-color: var(--teal); color: var(--ink); }
.chip .hex { width: 11px; height: 12px; }
.fleet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.dev-card { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px 14px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--off); border-radius: 8px; color: var(--ink); }
.dev-card:hover { text-decoration: none; border-color: var(--line-2); border-left-color: var(--c, var(--off)); background: var(--panel-2); }
.dev-card[data-state="ok"] { border-left-color: var(--teal); --c: var(--teal); }
.dev-card[data-state="alarm"] { border-left-color: var(--alarm); --c: var(--alarm); }
.dev-card[data-state="fault"] { border-left-color: var(--fault); --c: var(--fault); }
.dev-card[data-state="offline"] { --c: var(--off); }
.dc-top { display: flex; gap: 12px; align-items: center; }
.dc-name { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.dc-name b { font: 600 19px/1.2 "Barlow Semi Condensed", sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-name span { color: var(--ink-3); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-state { font-size: 13.5px; color: var(--ink-2); text-align: right; white-space: nowrap; }
.dc-vals { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.dc-vals li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 5px; border-bottom: 1px dashed var(--line); }
.dc-vals li:last-child { border-bottom: 0; }
.dc-vals span { color: var(--ink-2); font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-vals b { font: 600 17px/1.2 "Barlow Semi Condensed", sans-serif; white-space: nowrap; }
.dc-vals i { font-style: normal; font-weight: 500; color: var(--ink-3); margin-left: 3px; font-size: .85em; }
.dc-vals li.alarm b { color: var(--alarm); } .dc-vals li.fault b { color: var(--fault); }
.dc-foot { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 13.5px; margin-top: auto; }
.badge { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid; }
.badge.alarm { color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 55%, transparent); background: color-mix(in srgb, var(--alarm) 12%, transparent); }
.badge.fault { color: var(--fault); border-color: color-mix(in srgb, var(--fault) 55%, transparent); background: color-mix(in srgb, var(--fault) 12%, transparent); }
.badge.warn { color: var(--fault); border-color: color-mix(in srgb, var(--fault) 55%, transparent); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.spacer { flex: 1; }
.sig { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.sig i { width: 3px; background: var(--line-2); display: block; border-radius: 1px; }
.sig i.on { background: var(--teal); }
.fleet-empty { grid-column: 1 / -1; padding: 40px 24px; text-align: center; background: var(--panel); border: 1px dashed var(--line-2); border-radius: 8px; }
.fleet-empty h3 { margin-bottom: 8px; }

/* ---------- device page ---------- */
.dev-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.dev-title { display: flex; align-items: center; gap: 16px; }
.dev-title .hex { width: 34px; height: 38px; }
.dev-title p { margin: 4px 0 0; }
.dev-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.hero {
  display: grid; grid-template-columns: minmax(300px, 520px) 1fr; gap: 30px; align-items: center; padding: 26px; border: 1px solid var(--line); border-radius: 10px; background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cpath d='M28 2 54 17v30L28 62 2 47V17zM28 64 54 79M2 79 28 64M28 62v35' fill='none' stroke='%2322d3c5' stroke-opacity='.075'/%3E%3C/svg%3E");
}
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding: 18px; } }
.mirror-fig { margin: 0; }
.mirror-fig figcaption { color: var(--ink-3); font-size: 13.5px; margin-top: 12px; text-align: center; }
.mirror {
  background: #06090b; padding: 14px; border-radius: 12px; border: 1px solid #2a3b45;
  box-shadow: inset 0 0 0 2px #121c22, 0 10px 30px rgba(0,0,0,.28);
}
.mirror svg { display: block; width: 100%; height: auto; border-radius: 3px; background: #000; }
.mirror.off svg { filter: grayscale(1) brightness(.55); }
.vitals { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px 26px; }
.vitals div { min-width: 0; }
.vitals dt { color: var(--ink-3); font-size: 14px; margin-bottom: 2px; }
.vitals dd { margin: 0; font: 500 19px/1.3 "Barlow Semi Condensed", sans-serif; overflow-wrap: anywhere; }
.vitals dd small { display: block; font: 400 14px/1.3 "Barlow", sans-serif; color: var(--ink-2); }
.copy { background: none; border: 0; color: var(--teal); font-weight: 500; font-size: 14px; font-family: inherit; cursor: pointer; padding: 0 0 0 8px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tile { --c: var(--teal); background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; padding: 14px 16px 13px; min-width: 0; }
.tile[data-state="alarm"] { --c: var(--alarm); background: color-mix(in srgb, var(--alarm) 7%, var(--panel)); }
.tile[data-state="fault"] { --c: var(--fault); }
.tile[data-state="stale"] { --c: var(--off); }
.tile-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--ink-2); font-size: 15px; }
.tile-top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-val { display: flex; align-items: baseline; gap: 7px; margin: 6px 0 10px; font-family: "Barlow Semi Condensed", sans-serif; }
.tile-val b { font-size: 42px; font-weight: 600; line-height: 1; letter-spacing: .005em; }
.tile-val small { font-size: 18px; color: var(--ink-3); font-weight: 500; }
.tile[data-state="alarm"] .tile-val b { color: var(--alarm); }
.tile[data-state="fault"] .tile-val b { color: var(--fault); font-size: 34px; }
.tile[data-state="stale"] .tile-val b { color: var(--ink-3); }
.bar { position: relative; height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 2px; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--c); width: 0; transition: width .6s ease; }
.bar-tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--alarm); opacity: .9; }
.bar-scale { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
.tile-note { color: var(--ink-3); font-size: 13.5px; margin-top: 8px; line-height: 1.35; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { background: none; border: 0; border-right: 1px solid var(--line); padding: 6px 13px; color: var(--ink-2); font-weight: 500; font-size: 14.5px; font-family: inherit; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--ink); background: var(--panel-2); }
.seg button.on { background: var(--teal); color: var(--on-accent); font-weight: 600; }

.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr)); gap: 16px; }
.chart-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 8px; background: var(--bg-2); min-width: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.chart-head b { font: 600 17px/1.2 "Barlow Semi Condensed", sans-serif; }
.chart-stats { color: var(--ink-3); font-size: 13.5px; }
.chart-stats span { color: var(--ink-2); }
.chart-host { position: relative; height: 176px; margin-top: 6px; }
.chart-host canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-tip { position: absolute; pointer-events: none; z-index: 3; background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 10px; font-size: 13.5px; line-height: 1.35; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.chart-tip b { font-family: "Barlow Semi Condensed", sans-serif; font-size: 16px; }
.chart-tip .a { color: var(--alarm); } .chart-tip .f { color: var(--fault); }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); }

.events { list-style: none; margin: 0; padding: 0; }
.events li:not(.empty) { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }
.events .hex { width: 14px; height: 16px; margin-top: 4px; }
.events .msg small { display: block; color: var(--ink-3); font-size: 13px; }
.events time { color: var(--ink-3); font-size: 13.5px; white-space: nowrap; }
.events .msg a { color: var(--ink); }

.cfg h4 { margin: 18px 0 8px; font: 600 16px "Barlow Semi Condensed", sans-serif; color: var(--ink-2); }
.cfg h4:first-child { margin-top: 0; }
.cfg .tbl th, .cfg .tbl td { padding: 6px 10px; font-size: 14.5px; }
.cfg .table-wrap { border: 1px solid var(--line); background: none; }
.cfg dl.kv { margin: 6px 0; font-size: 14.5px; }

/* ---------- dialogs and toast ---------- */
dialog.dlg { width: min(460px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); border: 1px solid var(--line-2); border-radius: 10px; padding: 22px 24px; }
dialog.dlg::backdrop { background: rgba(2, 10, 14, .62); }
dialog.dlg h3 { margin-bottom: 10px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.radios { margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 50; background: var(--panel-2); border: 1px solid var(--line-2); border-left: 4px solid var(--teal); padding: 11px 18px; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: min(92vw, 520px); }
.toast.bad { border-left-color: var(--alarm); }

@media (max-width: 720px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .who { display: none; }
  .brand-text span { display: none; }
  h1 { font-size: 27px; }
  .wrap { padding: 18px 14px 50px; }
  .tile-val b { font-size: 38px; }
}
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }

/* =====================================================================
   Autostack additions: dynamic widgets, customize mode, dialogs
   ===================================================================== */
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.info { background: color-mix(in srgb, var(--blue) 12%, var(--panel)); border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); }
.vitals.compact { margin: 0 0 8px; padding: 14px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 22px; }
.vitals.compact dd { font-size: 17px; }
#btnCustomize.on { background: var(--teal); border-color: var(--teal); color: var(--on-accent); font-weight: 600; }

/* lamps: on/off fields and status words */
.state-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 12px; }
.lamp { --c: var(--off); position: relative; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "dot label val" "dot since since"; gap: 0 12px; align-items: center;
  padding: 11px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.lamp-dot { grid-area: dot; width: 14px; height: 16px; background: var(--c); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.lamp .ll { grid-area: label; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lamp .lv { grid-area: val; font: 600 18px/1.2 "Barlow Semi Condensed", sans-serif; letter-spacing: .02em; text-align: right; overflow: hidden; text-overflow: ellipsis; max-width: 12em; }
.lamp .lt { grid-area: since; color: var(--ink-3); font-size: 12.5px; }
.lamp[data-state="on"] { --c: var(--ok); }
.lamp[data-state="on"] .lv { color: var(--ok); }
.lamp[data-state="text"] { --c: var(--blue); }
.lamp[data-state="stale"] { opacity: .6; }
.lamp .tile-edit { position: absolute; top: 4px; right: 4px; }

/* tiles */
.tile-top { position: relative; }
.tile[data-w="counter"] { --c: var(--blue); }
.tile[data-state="stale"] { --c: var(--off); }
.spark { height: 30px; margin: 2px 0 4px; }
.spark-svg { width: 100%; height: 30px; display: block; }
.spark-svg path { fill: none; stroke: var(--c); stroke-width: 1.6; vector-effect: non-scaling-stroke; opacity: .85; }
.tile .tile-note:empty { display: none; }

/* details list */
.details { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 30px; }
.details > div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.details dt { color: var(--ink-3); font-size: 15px; }
.details dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-weight: 500; }

/* the gear: only in customize mode */
.tile-edit { display: none; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink-2); width: 28px; height: 28px; border-radius: 6px; padding: 0; cursor: pointer; align-items: center; justify-content: center; margin-left: 6px; flex: none; }
.tile-edit:hover { color: var(--teal); border-color: var(--teal); }
body.customizing .tile-edit { display: inline-flex; }
body.customizing .tile, body.customizing .lamp { outline: 1px dashed color-mix(in srgb, var(--teal) 55%, transparent); outline-offset: 2px; }
.details dd .tile-edit { margin-left: 10px; }

.hidden-list { list-style: none; margin: 0; padding: 0; }
.hidden-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.raw { margin: 12px 0 0; padding: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: auto; max-height: 360px; font: 13px/1.5 ui-monospace, Consolas, monospace; color: var(--ink-2); white-space: pre-wrap; word-break: break-all; }
details summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }

/* dialogs */
dialog.dlg.wide { width: min(600px, calc(100vw - 32px)); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.dlg-actions.spread { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.dc-vals b.is-on { color: var(--ok); }
.dev-card[data-state="ok"] { --c: var(--teal); }
