/* Colors are chosen for at least 4.5:1 text contrast in both themes. */
:root {
  --bg: #ffffff; --surface: #f4f6fa; --text: #111827; --muted: #4b5563;
  --border: #c9d1de; --primary: #1d4ed8; --primary-text: #ffffff;
  --danger: #b91c1c; --ok: #166534; --warn: #92400e; --focus: #c2410c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a; --surface: #172036; --text: #e5e9f2; --muted: #b6c2d9;
    --border: #3a4a6b; --primary: #1d4ed8; --primary-text: #ffffff;
    --danger: #fca5a5; --ok: #86efac; --warn: #fcd34d; --focus: #fdba74;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* .button and .grid set display; hidden must still win */
html { font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.4rem; margin-top: .5rem; }
h3 { font-size: 1.1rem; margin-top: 1.25rem; }
h4 { font-size: 1rem; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: 1rem; top: -3rem; padding: .5rem 1rem; background: var(--primary); color: var(--primary-text); z-index: 10; }
.skip:focus { top: 1rem; }

header.site { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand h1 { font-size: 1.5rem; margin: 0; }
.brand p { margin: 0; }
nav ul { display: flex; flex-wrap: wrap; gap: .25rem 1rem; list-style: none; margin: 0; padding: 0; }
nav a { display: inline-block; padding: .35rem .25rem; }
.header-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.who { margin: 0; color: var(--muted); }

main { max-width: 1280px; margin: 0 auto; padding: 1rem 1.5rem 3rem; }
main:focus { outline: none; }
section { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
footer.site { padding: 1rem 1.5rem; border-top: 1px solid var(--border); }

button, .button { font: inherit; display: inline-block; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; text-decoration: none; min-height: 2.5rem; }
button.primary, .button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
button.danger { border-color: var(--danger); color: var(--danger); }
button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
button:disabled { opacity: .6; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: .25rem; margin: .5rem 0; min-width: 0; }
.field.grow { flex: 1 1 18rem; }
label { font-weight: 600; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .45rem .6rem; min-height: 2.5rem; }
textarea { font-family: var(--mono); font-size: .9rem; width: 100%; }
[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.hint { margin: 0; font-size: .875rem; color: var(--muted); }
.field-error { margin: 0; color: var(--danger); font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-end; }
.buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.status { min-height: 1.5rem; margin: .25rem 0; }
.status.ok { color: var(--ok); } .status.error { color: var(--danger); }
.notice { padding: .75rem 1rem; border-radius: 6px; border: 2px solid var(--danger); margin: 1rem 0; }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem; list-style: none; padding: 0; margin: .5rem 0 0; }
.cards li { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; }
.state { font-weight: 700; }
.state.ok { color: var(--ok); } .state.bad { color: var(--danger); } .state.warn { color: var(--warn); }

.pairs { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: .5rem 0; }
.pairs dt { color: var(--muted); } .pairs dd { margin: 0; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: .5rem 0; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 700; }

.log { max-height: 32rem; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.messages { list-style: none; margin: 0; padding: 0; }
.messages li { padding: .6rem .9rem; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: .875rem; }
.messages .meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); }
.messages .payload { white-space: pre-wrap; overflow-wrap: anywhere; margin: .3rem 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; padding: 0; margin: .25rem 0; }
.chips li { font-family: var(--mono); font-size: .85rem; padding: .1rem .5rem; border: 1px solid var(--border); border-radius: 4px; }
.pipeline { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; list-style: none; counter-reset: step; }
.pipeline li { counter-increment: step; flex: 1 1 12rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; }
.pipeline .step { display: block; font-weight: 700; }
.pipeline .step::before { content: counter(step) ". "; }

fieldset.channel, fieldset.board { border: 1px solid var(--border); border-radius: 8px; padding: .5rem 1rem 1rem; margin: .75rem 0; }
fieldset.channel legend, fieldset.board legend { font-weight: 700; padding: 0 .35rem; }
.channel-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; }

iframe.dashboard { width: 100%; height: 72rem; max-height: 85vh; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
iframe.panel { width: 100%; height: 18rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .5rem; }
.section-head h2 { margin: 0; flex: 1 1 auto; }
#command-slot { margin-top: 1rem; }
.grid > * { min-width: 0; }
select { max-width: 100%; }
.inline-action { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: .5rem 0; }
.switch { position: relative; width: 3.25rem; min-height: 0; height: 1.9rem; padding: 0; border-radius: 1rem; border: 1px solid var(--border); background: var(--border); }
.switch .knob { position: absolute; top: .2rem; left: .2rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--bg); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: left .15s; }
.switch[aria-checked="true"] { background: var(--ok); border-color: var(--ok); }
.switch[aria-checked="true"] .knob { left: 1.6rem; }
.brand-logo { display: none; }

/* Conekt theme (SITE_THEME=conekt): the TCU console's look and the Conekt logo colors.
   Light only, like the console. Text stays at 4.5:1 or better; the brand blue,
   green, and yellow are used only for decoration. */
:root[data-theme="conekt"] {
  --bg: #ffffff; --surface: #fafcfe; --page: #eef2f7; --text: #131a26; --muted: #5f6b7d;
  --border: #c4cede; --line: #dbe2ec; --primary: #2a6aa8; --primary-text: #ffffff;
  --danger: #b42318; --ok: #1f7a3a; --warn: #9a6500; --focus: #c2410c; --heading: #33405a;
  --cn-blue: #498fcb; --cn-green: #4aaf51; --cn-yellow: #fdc119;
  color-scheme: light;
}
[data-theme="conekt"] body { background: var(--page); font-size: .9375rem; }
[data-theme="conekt"] header.site { position: relative; background: var(--bg); border-bottom: 1px solid var(--line); padding-bottom: 1.25rem; }
[data-theme="conekt"] header.site::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, var(--cn-blue) 0 33.3%, var(--cn-green) 33.3% 66.6%, var(--cn-yellow) 66.6% 100%); }
[data-theme="conekt"] .brand { display: flex; align-items: center; gap: .75rem; }
[data-theme="conekt"] .brand-logo { display: block; height: 2.25rem; width: auto; }
[data-theme="conekt"] .brand h1 { font-size: 1.25rem; }
[data-theme="conekt"] nav a { color: var(--heading); font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; }
[data-theme="conekt"] nav a:hover { border-bottom-color: var(--cn-blue); }
[data-theme="conekt"] a { color: var(--primary); }
[data-theme="conekt"] main { max-width: 1180px; }
[data-theme="conekt"] main > section { background: var(--bg); border: 1px solid var(--line); border-top: 3px solid var(--cn-blue); border-radius: 12px; padding: 1rem 1.25rem; margin: 0 0 .9rem; }
[data-theme="conekt"] main > section:not(.login) h2 { font-size: .85rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--heading); margin-top: 0; }
[data-theme="conekt"] main > section h3 { font-size: .95rem; }
[data-theme="conekt"] .card, [data-theme="conekt"] .cards li, [data-theme="conekt"] .log, [data-theme="conekt"] .pipeline li { background: var(--surface); border-color: var(--line); }
[data-theme="conekt"] button, [data-theme="conekt"] .button, [data-theme="conekt"] input, [data-theme="conekt"] select, [data-theme="conekt"] textarea { border-radius: 8px; }
[data-theme="conekt"] button:not(.primary):not(.danger):not(.switch):not(:disabled):hover { background: #f0f5fb; }
[data-theme="conekt"] button.primary:hover, [data-theme="conekt"] .button.primary:hover { background: #235a8f; }
[data-theme="conekt"] input:focus, [data-theme="conekt"] select:focus, [data-theme="conekt"] textarea:focus { border-color: var(--primary); }
[data-theme="conekt"] iframe.dashboard { background: var(--bg); border-color: var(--line); }
[data-theme="conekt"] footer.site { border-top-color: var(--line); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media (max-width: 700px) { header.site { padding: .75rem 1rem; } main { padding: .75rem 1rem 2rem; } .header-actions { margin-left: 0; } }
.http-fields { margin-top: 1rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.mono { font-family: var(--mono); overflow-wrap: anywhere; }

/* Board simulator */
#sim-msg-form, #sim-boards { margin: .75rem 0; }
.sim-board h3 { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 0; }
.bearer-tag { font-size: .85rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; border: 2px solid var(--border); }
.bearer-tag[data-bearer="lte"] { border-color: #498fcb; }
.bearer-tag[data-bearer="wifi"] { border-color: #4aaf51; }
.bearer-tag[data-bearer^="sidewalk"] { border-color: #c48a00; }
.segmented { border: 0; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.segmented legend { font-weight: 600; margin-bottom: .35rem; padding: 0; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label { display: inline-block; padding: .45rem .8rem; min-height: 2.5rem; box-sizing: border-box; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); cursor: pointer; }
.segmented input:checked + label { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.segmented input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.sim-conn { margin: .5rem 0; padding: .5rem .75rem; border-left: 4px solid var(--border); background: var(--bg); }
.sim-conn.open { border-left-color: var(--ok); }
.sim-conn.closed { border-left-color: var(--warn); }
.sim-ids { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .75rem; margin: .5rem 0; font-size: .9rem; }
.sim-ids dt { color: var(--muted); }
.sim-ids dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.sim-received { list-style: none; padding: 0; margin: .25rem 0; font-family: var(--mono); font-size: .85rem; max-height: 8rem; overflow-y: auto; }
.sim-received li { padding: .15rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.inline-checks { border: 0; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.inline-checks legend { font-weight: 600; padding: 0; margin-bottom: .25rem; }
.inline-checks span, .check-row { display: flex; align-items: center; gap: .35rem; min-height: 2rem; }
.check-row { margin: .75rem 0 .25rem; font-weight: 600; }
.inline-checks input, .check-row input { width: 1.1rem; height: 1.1rem; }

/* Live traffic connection status */
.conn-status { margin: .75rem 0; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.conn-status dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .5rem 1.5rem; margin: 0; }
.conn-status dt { font-size: .85rem; color: var(--muted); }
.conn-status dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.conn-status dd.ok { color: var(--ok); } .conn-status dd.error { color: var(--danger); }
.conn-status .hint { margin: .75rem 0 0; }
.chips li.ok { border-color: var(--ok); }
.chips li.bad { border-color: var(--danger); }
.meta .origin strong { font-family: var(--mono); }


/* Admin / Presenter toggle in the header */
.view-toggle { display: inline-flex; border: 1px solid var(--line, var(--border)); border-radius: 999px; padding: 3px; background: var(--surface); }
.view-toggle a { padding: .35rem .95rem; border-radius: 999px; font-weight: 600; text-decoration: none; color: var(--text); min-height: 2rem; display: inline-flex; align-items: center; }
.view-toggle a:hover { background: var(--bg); }
.view-toggle a[aria-current="page"] { background: var(--primary); color: var(--primary-text); }


/* Presenter sign-in */
main > section.login { max-width: 24rem; margin: 2rem auto; padding: 1.5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
main > section.login h2 { margin-top: 0; font-size: 1.25rem; letter-spacing: 0; text-transform: none; }
.login form { display: grid; gap: 1rem; margin-top: 1rem; }
.login-field { display: grid; gap: .35rem; }
.login-field label { font-weight: 600; }
.login .field-error:empty { display: none; }
.login-admin { display: grid; gap: .5rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.login-admin .button { text-align: center; }


/* Presenter view: Amazon Sidewalk demo. One device at a time on tabs, its current
   network and latest connection, Send a command, Event History, Traffic, and totals.
   White page. Network colors (Conekt brand) mark networks; direction colors mark
   Device -> Cloud (violet) and Cloud -> Device (raspberry). Every mark also has a
   text label, so nothing depends on color alone. */
:root {
  --b-lte: #498fcb; --b-wifi: #4aaf51; --b-sidewalk: #fdc119; --b-lora: #1d1d1b; --b-none: #e6ebf1;
  --d-up: #7048c8; --d-down: #c2366f; --ink: #1d1d1b;
}
body.demo-mode { background: #fff !important; }
/* The sign-in page wears the Presenter view banner. */
body.presenter-banner { background: #fff !important; }
body.presenter-banner header.site { padding: .55rem 1.5rem .8rem; gap: .5rem 1.5rem; background: #fff; }
body.demo-mode nav, body.demo-mode #pause-all, body.demo-mode #manual-link, body.demo-mode #grafana-link,
body.demo-mode main > section:not(#demo), body.demo-mode header.site .brand, body.demo-mode footer.site { display: none !important; }
body.demo-mode header.site { padding: .55rem 1.5rem .8rem; gap: .5rem 1.5rem; background: #fff; }
body.demo-mode main { max-width: 1840px; padding: .9rem 1.5rem 1rem; }
.demo-live { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .9rem; }
.demo-live .dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--muted); }
.demo-live.ok .dot { background: #2e7d32; box-shadow: 0 0 0 3px rgba(46,125,50,.18); }
.demo-live.bad .dot { background: var(--danger); }

.demo-brand { display: flex; align-items: center; gap: 1.1rem; }
.demo-brand[hidden], .demo-powered[hidden] { display: none; }
.sidewalk-logo { display: block; height: 2.6rem; width: auto; }
.demo-caption { color: #526170; border-left: 1px solid #dce3e9; padding-left: 1.1rem; font-size: 1rem; white-space: nowrap; }
.demo-powered { display: flex; align-items: center; gap: .8rem; color: #526170; font-size: .8rem; white-space: nowrap; }
.wuqi-brand { display: inline-flex; align-items: center; gap: .35rem; color: #160974; font-weight: 700; font-size: .95rem; }
.wuqi-brand img { height: 1.4rem; width: auto; }
.demo-powered .divider { width: 1px; height: 1.6rem; background: #dce3e9; }
.demo-powered .conekt-mark { height: 2.1rem; width: auto; }
body.demo-mode .who { display: none; }

#demo { display: flex; flex-direction: column; gap: .85rem; background: none !important; border: 0 !important; padding: 0 !important; margin: 0 !important; }
#demo[hidden] { display: none; }
#demo h3 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; text-transform: none; color: var(--ink); }
.sw-panel { background: #fff; border: 1px solid #dce3e9; border-radius: 10px; box-shadow: 0 1px 3px rgba(29,29,27,.05); }
.sw-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.sw-panel-head > span { color: var(--muted); font-size: .85rem; }

/* Device card: tabs on top; one card below with the current network, the latest
   connection, and Send a command. The left edge takes the device's network color. */
.sw-hero { --net: var(--b-none); display: flex; flex-direction: column; min-width: 0; }
.sw-hero[data-bearer="lte"] { --net: var(--b-lte); }
.sw-hero[data-bearer="wifi"] { --net: var(--b-wifi); }
.sw-hero[data-bearer="sidewalk"] { --net: var(--b-sidewalk); }
.sw-hero[data-bearer="lora"] { --net: var(--b-lora); }
.sw-tabs { display: flex; align-items: flex-end; gap: .45rem; position: relative; z-index: 2; }
.sw-tabs [role="tab"] { --accent: #b8c2ce; position: relative; display: inline-flex; align-items: center; gap: .55rem; white-space: nowrap;
  min-height: 2.55rem; margin-top: .25rem; padding: .3rem 1rem; border: 1px solid #dce3e9; border-top: 3px solid var(--accent);
  border-bottom: 0; border-radius: 8px 8px 0 0; background: color-mix(in srgb, var(--accent) 8%, #f4f7f9);
  color: #526170; font-size: 1rem; font-weight: 600; cursor: pointer; }
.sw-tabs [role="tab"][data-bearer="lte"] { --accent: var(--b-lte); }
.sw-tabs [role="tab"][data-bearer="wifi"] { --accent: var(--b-wifi); }
.sw-tabs [role="tab"][data-bearer="sidewalk"] { --accent: var(--b-sidewalk); }
.sw-tabs [role="tab"][data-bearer="lora"] { --accent: var(--b-lora); }
.sw-tabs [role="tab"]:hover { color: var(--ink); }
.sw-tabs [role="tab"][aria-selected="true"] { margin-top: 0; min-height: 2.85rem; background: #fff; color: var(--ink); font-weight: 700;
  box-shadow: 0 -3px 10px rgba(29,29,27,.07); }
.sw-tabs [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 3px; background: #fff; }
.sw-tabs [role="tab"]:first-child { margin-left: 0; }
.sw-tab-net { display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; font-size: .9rem; }
.sw-tab-net::before { content: "·"; color: #8a96a3; }
.sw-card { position: relative; z-index: 1; margin-top: -1px; padding: 1.1rem 1.4rem; background: #fff;
  border: 1px solid #dce3e9; border-left: 6px solid var(--net); border-radius: 0 10px 10px 10px; box-shadow: 0 1px 3px rgba(29,29,27,.05);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr); gap: 1.6rem; align-items: center; }
.sw-info { min-width: 0; }
.sw-kicker { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #526170; }
.sw-network-row { display: flex; align-items: center; gap: .8rem; margin: .3rem 0 .25rem; }
.sw-network-icon { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 9px; background: color-mix(in srgb, var(--net) 22%, #fff); flex-shrink: 0; }
.sw-network-icon svg { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.sw-network-icon svg circle { fill: var(--ink); stroke: none; }
.sw-network { margin: 0; font-size: clamp(2.1rem, 2.9vw, 3.1rem); font-weight: 750; line-height: 1.05; letter-spacing: -.03em; color: var(--ink); white-space: nowrap; }
.sw-stale { font-size: .8rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: #fff4d6; color: #6b4e00; border: 1px solid #e0b84a; }
.sw-fresh { margin: 0; color: #526170; font-size: .95rem; }
.sw-details { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); gap: .55rem 1.2rem;
  padding-left: 1.4rem; border-left: 1px solid #e6ebf1; align-self: stretch; align-content: center; }
.sw-details dt { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #6b7785; }
.sw-details dd { margin: .1rem 0 0; font-size: .98rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-details div { min-width: 0; }

.sw-command { display: grid; align-content: center; gap: .55rem; padding-left: 1.75rem; border-left: 1px solid #e6ebf1; min-width: 0; }
.sw-command[hidden] { display: none; }
.sw-command-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
#demo .sw-command h3 { font-size: 1.5rem; }
.sw-field { display: grid; gap: .25rem; min-width: 0; }
.sw-field label { font-size: .8rem; color: #526170; font-weight: 600; }
.sw-field select, .sw-field input { width: 100%; min-width: 0; font-size: 1.05rem; min-height: 2.75rem; background: #f6f8fa; border-color: #d3dbe4; }
.sw-send-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem; align-items: end; }
.sw-send { min-height: 2.75rem; padding: .5rem 1.3rem; border: 0; border-radius: 6px; background: var(--ink); color: #fff; font-size: 1.05rem; font-weight: 700; white-space: nowrap; }
.sw-send:disabled { opacity: .45; }
.sw-feedback { margin: 0; min-height: 2.6rem; font-size: .92rem; color: #526170; line-height: 1.35; }
.sw-feedback.ok { color: var(--ok); font-weight: 600; } .sw-feedback.error { color: var(--danger); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  .sw-hero.sw-flash .sw-card { animation: sw-flash .9s ease-out; }
  @keyframes sw-flash { from { box-shadow: 0 0 0 6px color-mix(in srgb, var(--net) 55%, transparent); } to { box-shadow: 0 0 0 0 transparent; } }
}

/* Event History */
.sw-history, .sw-traffic { padding: .85rem 1.4rem .9rem; }
.sw-chart { margin-top: .55rem; }
.sw-chart svg { display: block; width: 100%; height: auto; }
.sw-lane-label { fill: #526170; font-size: 14px; font-weight: 600; }
.sw-tick { fill: #6b7785; font-size: 12px; }
.sw-grid { stroke: #eef1f5; stroke-width: 1; }
.sw-lane { stroke: #dce3e9; stroke-width: 1; }
.sw-band-unknown { fill: #f1f4f7; }
.sw-seg[data-bearer="lte"] rect { fill: var(--b-lte); }
.sw-seg[data-bearer="wifi"] rect { fill: var(--b-wifi); }
.sw-seg[data-bearer="sidewalk"] rect { fill: var(--b-sidewalk); }
.sw-seg[data-bearer="lora"] rect { fill: var(--b-lora); }
/* Sidewalk links: one yellow family, told apart by shade and by their labels. */
.sw-seg[data-link="FSK"] rect { fill: #e8a800; }
.sw-seg[data-link="BLE"] rect { fill: #ffe08a; }
.sw-link-tag { fill: #6b4e00; font-size: 12px; font-weight: 800; }
/* Idle time cut out of Event History: a thin grey line; the paused state stays quiet. */
.sw-break-gap { fill: #fff; }
.sw-break-line { stroke: #b8c2ce; stroke-width: 1.5; }
.sw-history.paused #sw-history-note { color: #6b7785; }
.sw-hero.sw-paused .sw-network-icon { background: #eef1f5; }
.sw-hero.sw-paused .sw-stale { background: #f1f4f7; color: #526170; border-color: #dce3e9; }
.sw-seg-label { fill: var(--ink); font-size: 14px; font-weight: 700; }
.sw-seg[data-bearer="lora"] .sw-seg-label { fill: #fff; }
.sw-mark circle, .sw-mark path { stroke: #fff; stroke-width: 2; }
.sw-mark.up circle { fill: var(--d-up); }
.sw-mark.down path { fill: var(--d-down); }
@media (prefers-reduced-motion: no-preference) {
  .sw-mark.fresh circle, .sw-mark.fresh path { animation: sw-pop 1s ease-out; transform-box: fill-box; transform-origin: center; }
  @keyframes sw-pop { from { transform: scale(1.8); } to { transform: scale(1); } }
}

/* Traffic: latest message each way; violet = Device -> Cloud, raspberry = Cloud -> Device */
.sw-traffic-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin-top: .6rem; }
.sw-flow { --dir: var(--d-up); min-width: 0; padding: .7rem 1rem .75rem; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--dir) 30%, #fff);
  border-left: 5px solid var(--dir); background: color-mix(in srgb, var(--dir) 6%, #fff); }
.sw-flow[data-dir="down"] { --dir: var(--d-down); }
.sw-flow-head { display: flex; align-items: center; gap: .55rem; }
.sw-flow-arrow { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--dir); color: #fff; font-weight: 800; font-size: 1rem; }
.sw-flow-title { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.sw-flow-status { margin-left: auto; font-size: .88rem; font-weight: 700; color: #526170; white-space: nowrap; }
.sw-flow-status.ok { color: var(--ok); } .sw-flow-status.error { color: var(--danger); }
.sw-flow-payload { margin: .45rem 0 .15rem; font-size: 1.2rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-flow-meta { margin: 0; color: #526170; font-size: .88rem; }

/* Five totals on a near-black strip; numeral colors are Conekt branding, labels stay light */
.sw-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: .85rem 1.4rem; border-radius: 10px; background: var(--ink); }
.sw-metrics > div { padding: 0 1.1rem; border-left: 1px solid #454540; min-width: 0; }
.sw-metrics > div:first-of-type { padding-left: 0; border-left: 0; }
.sw-metrics strong { display: block; font-size: 2.6rem; font-weight: 700; line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sw-metrics strong small { font-size: 1.2rem; color: #d6d9d2; font-weight: 600; letter-spacing: 0; }
.sw-metrics > div > span { display: block; margin-top: .2rem; color: #d6d9d2; font-size: .95rem; }
.sw-metrics .m-blue { color: var(--b-lte); } .sw-metrics .m-green { color: var(--b-wifi); } .sw-metrics .m-yellow { color: var(--b-sidewalk); }
.sw-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: #6b7785; font-size: .8rem; padding: 0 .2rem; }
.sw-footer-actions { display: inline-flex; align-items: center; gap: .8rem; }
.sw-footer .link { font-size: .8rem; min-height: 0; padding: .1rem .3rem; background: none; border: 0; color: var(--primary); text-decoration: underline; }
.rehearsal { font-size: .8rem; font-weight: 700; padding: .15rem .6rem; border-radius: 999px; background: #fff4d6; color: #6b4e00; border: 1px solid #e0b84a; }

@media (max-width: 1100px) {
  .sw-card { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .sw-command { padding-left: 0; border-left: 0; padding-top: 1rem; border-top: 1px solid #e6ebf1; }
  .sw-details { padding: .8rem 0 0; border-left: 0; border-top: 1px solid #e6ebf1; }
  .demo-caption, .demo-powered > span:first-child { display: none; }
}
@media (max-width: 700px) {
  .sw-traffic-grid { grid-template-columns: minmax(0, 1fr); }
  .sw-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 0; }
  .sw-metrics > div:nth-of-type(odd) { padding-left: 0; border-left: 0; }
  .sw-tabs { flex-wrap: wrap; }
  .sw-network { font-size: 2.2rem; }
}
/* A 1080p projector: use the height for larger type instead of empty space. */
@media (min-height: 1000px) and (min-width: 1400px) {
  .sw-card { padding: 1.3rem 1.5rem; }
  .sw-network { font-size: 3.4rem; }
  .sw-details dd { font-size: 1.08rem; }
  .sw-history, .sw-traffic { padding-top: 1rem; padding-bottom: 1.1rem; }
  .sw-flow { padding: .9rem 1.1rem; }
  .sw-flow-payload { font-size: 1.35rem; }
  .sw-metrics { padding: 1.05rem 1.4rem; }
  .sw-metrics strong { font-size: 3rem; }
}
