:root {
  color-scheme: dark;
  --bg: #090e14; --panel: #111923; --card: #151f2b; --line: #293748;
  --text: #f0f5fa; --muted: #abbacb; --accent: #80d9e9; --error: #ffadad;
  font: 16px/1.5 system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }
header { background: var(--panel); border-bottom: 1px solid var(--line); }
.header-inner, main, nav, footer { width: min(100%, 72rem); padding-inline: clamp(1rem, 4vw, 2rem); margin-inline: auto; }
.header-inner { display: flex; align-items: center; gap: clamp(.65rem, 3vw, 1.25rem); min-height: 5rem; }
.header-inner img { width: clamp(3.5rem, 12vw, 6.5rem); height: auto; }
.header-inner strong, .header-inner span { display: block; }
.header-inner span { color: var(--muted); font-size: .83rem; }
.header-inner form { margin-left: auto; }
nav { display: flex; flex-wrap: wrap; gap: .5rem; padding-block: 1rem 0; }
nav a { color: var(--muted); border-radius: .5rem; padding: .6rem .85rem; text-decoration: none; }
nav a[aria-current] { background: var(--card); color: var(--accent); }
a { color: var(--accent); }
main { flex: 1; padding-block: clamp(1.2rem, 4vw, 2.5rem); }
.compact { max-width: 33rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
h1 { font-size: clamp(1.55rem, 4vw, 2.25rem); margin: 0 0 1.25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .55rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: .75rem; padding: clamp(1rem, 3vw, 1.5rem); margin-bottom: 1rem; }
.card p { margin: .35rem 0 1rem; }
.muted, footer, dt { color: var(--muted); }
dd { margin: 0 0 .65rem; }
.fields { display: grid; gap: .85rem; max-width: 34rem; }
label { display: grid; gap: .3rem; }
input:not([type=checkbox]) { width: 100%; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: .45rem; padding: .65rem; font: inherit; }
.check { display: flex; align-items: center; }
.check input { accent-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.journal-presets, .journal-pagination { margin-block: 1rem; }
.journal-filters { align-items: end; }
.journal-table td:nth-child(4), .journal-table td:nth-child(6) { white-space: normal; overflow-wrap: anywhere; min-width: 10rem; max-width: 28rem; }
.button.quiet { background: transparent; border-color: var(--line); color: var(--text); }
button, .button { display: inline-block; width: fit-content; background: var(--accent); color: #09141c; border: 1px solid transparent; border-radius: .45rem; padding: .55rem .85rem; font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; }
button:disabled { opacity: .45; cursor: default; }
button.quiet { background: transparent; border-color: var(--line); color: var(--text); font-size: .8rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.notice { background: var(--card); border-left: .25rem solid var(--accent); padding: .75rem 1rem; }
.error { border-color: var(--error); color: var(--error); }
.secret { display: block; overflow-wrap: anywhere; margin: 0 0 1rem; padding: .6rem; background: var(--bg); }
.setup-qr:not([hidden]) { display: block; max-width: 100%; height: auto; margin: 0 auto 1rem; }
.manual-setup { margin: 0 0 1rem; }
.manual-setup summary { cursor: pointer; color: var(--accent); }
.table-wrap, .table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9rem; }
th, td { padding: .55rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td:nth-child(2), td:nth-child(3) { white-space: normal; }
footer { padding-block: 1rem; font-size: .86rem; text-align: center; }
.header-inner > div { min-width: 0; }
.header-inner strong { overflow-wrap: anywhere; }
.wc-preview { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
select { color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: .45rem; padding: .65rem; font: inherit; }
textarea { width: 100%; resize: vertical; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: .45rem; padding: .65rem; font: .85rem/1.4 ui-monospace, monospace; }
[hidden] { display: none !important; }
.recipient-sheet { border: 1px solid var(--line); border-radius: .45rem; margin-block: 1rem; }
.recipient-sheet table { min-width: 52rem; }
.recipient-sheet th { background: var(--panel); }
.recipient-sheet td { padding: 0; border-right: 1px solid var(--line); }
.recipient-sheet input:not([type=checkbox]), .recipient-sheet select { border: 1px solid transparent; border-radius: 0; min-width: 9rem; }
.recipient-sheet input[type=email] { min-width: 15rem; }
.recipient-sheet input:focus, .recipient-sheet select:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.recipient-sheet button { margin: .35rem; }
.sheet-actions { align-items: center; margin-bottom: .75rem; }
meter { display: block; width: 100%; height: 1rem; margin-block: .65rem; accent-color: var(--accent); }
.card .firmware-feedback { min-height: 3.5rem; margin: .75rem 0 0; overflow-wrap: anywhere; }
.firmware-controls { display: grid; gap: .85rem; border: 0; margin: 0; padding: 0; min-width: 0; }
.firmware-controls:disabled { opacity: .55; }
progress { display: block; width: 100%; height: 1.15rem; margin-block: .75rem; accent-color: var(--accent); }
.ota-spinner { display: inline-block; width: 1.6rem; height: 1.6rem; margin-block: .75rem; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: ota-spin .9s linear infinite; }
@keyframes ota-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ota-spinner { animation: none; } }

/* Operations console: bounded content, readable controls, mobile first tables. */
:root { --bg:#0b101a; --panel:#101826; --card:#141e2e; --line:#2a3850; --text:#edf3fc; --muted:#a9b9d0; --accent:#6cddcb; font:16px/1.6 "Segoe UI",system-ui,sans-serif; }
html { scroll-padding-top:1.5rem; }
body { display:grid; grid-template-columns:14.5rem minmax(0,1fr); grid-template-rows:auto 1fr auto; }
body.view-login, body.view-enroll, body.view-inactive { display:flex; flex-direction:column; }
header { grid-column:1/-1; }
.header-inner { width:100%; min-height:5.75rem; padding:1rem 2rem; gap:1.25rem; }
.header-inner img { width:6rem; flex-shrink:0; }
.header-inner strong { font-size:1.05rem; letter-spacing:-.025em; }
.header-inner span { font-size:.875rem; }
.header-inner form { margin:0 0 0 auto; flex-shrink:0; }
nav.primary-nav { align-self:start; position:sticky; top:1rem; display:flex; flex-direction:column; flex-wrap:nowrap; gap:.4rem; padding:1.6rem 1rem; width:100%; min-width:0; }
.nav-label,.eyebrow { display:block; color:var(--muted); font-size:.75rem; font-weight:700; letter-spacing:.1em; }
.nav-label { padding:0 .9rem .75rem; }
.primary-nav a { padding:.8rem .9rem; border:1px solid transparent; border-radius:.65rem; font-weight:600; }
.primary-nav a:hover { background:var(--panel); color:var(--text); }
.primary-nav a[aria-current] { color:var(--accent); background:#16322f; border-color:#2c5f57; }
main { width:100%; min-width:0; max-width:104rem; padding:2rem clamp(1rem,3vw,3rem) 3rem; }
.compact { max-width:31rem; padding-top:clamp(2rem,7vh,5rem); }
.compact h1 { text-align:center; }
.compact .card { padding:2rem; }
.compact .fields { max-width:none; }
.compact button { width:100%; }
.page-toolbar { display:flex; justify-content:space-between; align-items:center; gap:1rem; margin-bottom:1.75rem; }
.notification-switch { display:flex; align-items:center; flex-wrap:wrap; gap:.75rem; padding:.55rem .75rem; border:1px solid var(--line); border-radius:.75rem; background:var(--panel); font-size:.875rem; }
.notification-switch button { min-height:2.5rem; padding:.35rem .75rem; }
h1 { margin:0 0 1.5rem; font-size:clamp(1.65rem,2.6vw,2.5rem); line-height:1.2; letter-spacing:-.04em; }
h2 { font-size:1.15rem; line-height:1.4; margin:0 0 .85rem; letter-spacing:-.02em; }
h3 { font-size:1rem; margin:1.75rem 0 .75rem; }
p { overflow-wrap:anywhere; }
.page-description { color:var(--muted); margin-top:-.75rem; margin-bottom:1.75rem; }
.card { min-width:0; padding:clamp(1rem,2vw,1.6rem); margin:0 0 1.25rem; border-radius:1rem; box-shadow:0 8px 24px #00000014; }
.card > :last-child { margin-bottom:0; }
.grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:1.25rem; }
.metric-grid { display:grid; gap:1rem; grid-template-columns:repeat(4,minmax(0,1fr)); margin-bottom:1.25rem; }
.metric { display:flex; flex-direction:column; gap:.65rem; margin:0; border-top:2px solid #3c766f; }
.metric > span:last-child { color:var(--muted); font-size:.875rem; }
.metric-value { font-size:clamp(1.8rem,3vw,2.6rem); letter-spacing:-.05em; line-height:1.2; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.metric-value small { color:var(--muted); font-size:1rem; font-weight:500; letter-spacing:0; }
.section-heading { display:flex; gap:1rem; justify-content:space-between; align-items:center; margin-bottom:.5rem; }
.section-heading .eyebrow { margin-bottom:.3rem; }
.signal-history { display:flex; gap:.35rem; padding-block:.75rem; min-height:6.5rem; align-items:end; }
.signal-sample { position:relative; display:flex; flex:1; min-width:0; height:4.5rem; align-items:end; justify-content:center; border:1px solid #c58c42; border-radius:.3rem; background:#805d30; color:#fff0d9; }
.signal-sample[data-code="00"] { background:#25665b; border-color:#4ac4a7; color:#d4fff0; }
.signal-sample[data-mode="PRUEBA"] { opacity:.55; border-style:dashed; }
.signal-sample > span:first-child { font-size:.75rem; padding-bottom:.2rem; overflow:hidden; }
.sample-detail { display:none; }
.signal-sample:hover,.signal-sample:focus-visible { outline:2px solid var(--text); outline-offset:2px; }
.signal-sample:focus-visible .sample-detail { display:block; position:absolute; bottom:5rem; left:0; z-index:2; width:min(18rem,65vw); padding:.7rem; background:var(--panel); border:1px solid var(--line); border-radius:.5rem; }
.history-legend { display:flex; flex-wrap:wrap; gap:.5rem 1.5rem; font-size:.875rem; color:var(--muted); }
.empty-state { width:100%; border:1px dashed var(--line); padding:1.5rem; border-radius:.65rem; text-align:center; color:var(--muted); }
dl { display:grid; grid-template-columns:minmax(8rem,1fr) minmax(0,2fr); gap:.65rem 1rem; margin:1rem 0 1.5rem; }
dt,dd { margin:0; overflow-wrap:anywhere; }
dd { font-weight:500; }
.fields { gap:1rem; width:100%; max-width:42rem; margin-block:1rem; min-width:0; }
label { min-width:0; font-size:.875rem; font-weight:600; }
.check,label:has(> input[type=checkbox]) { display:flex; align-items:center; gap:.65rem; }
input:not([type=checkbox]),select,textarea { min-width:0; max-width:100%; min-height:2.85rem; padding:.7rem .8rem; background:#0d1522; border-color:#3a4c66; border-radius:.6rem; }
input[type=checkbox] { width:1.2rem; height:1.2rem; flex-shrink:0; margin:0; }
select { width:100%; text-overflow:ellipsis; }
textarea { font:inherit; line-height:1.6; }
button,.button { display:inline-flex; align-items:center; justify-content:center; gap:.5rem; min-height:2.85rem; max-width:100%; padding:.65rem 1rem; border-radius:.6rem; font-size:.875rem; line-height:1.4; text-align:center; overflow-wrap:anywhere; }
button:hover,.button:hover { filter:brightness(1.08); }
button.quiet,.button.quiet { font-size:.875rem; background:var(--panel); color:var(--text); border-color:#41516a; }
a { text-underline-offset:.2em; }
.actions { align-items:center; }
section > form + form,section > form + p,details > form + form { margin-top:1rem; }
section > form.actions { margin-bottom:1rem; }
.notice { border:1px solid #345e63; border-left:3px solid var(--accent); background:#102a30; border-radius:.65rem; padding:1rem 1.15rem; overflow-wrap:anywhere; }
.error { border-color:#a85d65; background:#351f2a; color:var(--error); }
.pause-notice { border-color:#956f37; background:#30271a; color:#f9d69d; }
.query-feedback { margin-top:1rem; }
details > summary { cursor:pointer; font-weight:650; padding-block:.3rem; }
details > summary::marker { color:var(--accent); }
.disclosure > summary h2 { display:inline; margin-left:.4rem; }
.disclosure[open] > summary { border-bottom:1px solid var(--line); padding-bottom:1rem; margin-bottom:1.25rem; }
.channel-panel { padding:.85rem 1rem; border:1px solid var(--line); border-radius:.65rem; margin-block:1rem; background:var(--panel); }
.channel-panel[open] > summary { margin-bottom:1rem; }
.section-nav { width:100%; max-width:none; padding:0; margin:0 0 1.5rem; gap:.5rem; }
.section-nav a { padding:.45rem .75rem; border:1px solid var(--line); background:var(--panel); font-size:.875rem; }
.section-nav a:hover { color:var(--text); border-color:var(--accent); }
.history-panel { position:relative; }
.history-panel .signal-sample { position:static; }
.signal-sample:focus-visible .sample-detail { bottom:1rem; left:1rem; right:1rem; width:auto; }

/* Semantic palette: catalog severity drives presentation, including live query results. */
:root { --ok:#6ee7ac; --ok-bg:#102e25; --ok-line:#287856; --warn:#ffd082; --warn-bg:#342718; --warn-line:#b68136; --fail:#ffb2c4; --fail-bg:#391c2b; --fail-line:#d94b76; --info:#aed8ff; --info-bg:#15283b; --info-line:#477ca8; }
.query-feedback,.wc-state,.monitor-metric { --state-text:var(--muted); --state-bg:var(--panel); --state-line:var(--line); color:var(--state-text); background:var(--state-bg); border-color:var(--state-line); }
[data-severity="OK"] { --state-text:var(--ok); --state-bg:var(--ok-bg); --state-line:var(--ok-line); }
[data-severity="AVISO"] { --state-text:var(--warn); --state-bg:var(--warn-bg); --state-line:var(--warn-line); }
[data-severity="FALLA"] { --state-text:var(--fail); --state-bg:var(--fail-bg); --state-line:var(--fail-line); }
[data-severity="INFO"] { --state-text:var(--info); --state-bg:var(--info-bg); --state-line:var(--info-line); }
.notice[data-severity],.monitor-metric[data-severity] { color:var(--state-text,var(--muted)); background:var(--state-bg,var(--panel)); border-color:var(--state-line,var(--line)); }
.signal-sample[data-severity] { background:var(--state-bg,var(--panel)); color:var(--state-text,var(--muted)); border-color:var(--state-line,var(--line)); }
.signal-sample[data-severity="FALLA"] { background:#902d50; border-color:#f3779b; color:#fff0f5; }
.signal-sample[data-severity="OK"] { background:#25665b; border-color:#4ac4a7; color:#d4fff0; }
.signal-sample[data-severity="AVISO"] { background:#805d30; border-color:#c58c42; color:#fff0d9; }
.severity-key { display:inline-flex; align-items:center; gap:.45rem; color:var(--state-text,var(--muted)); }
.severity-key::before { content:""; width:.7rem; height:.7rem; border-radius:.2rem; background:var(--state-line,var(--line)); }
.table-wrap,.table-scroll { width:100%; max-width:100%; min-width:0; overscroll-behavior-x:contain; border:1px solid var(--line); border-radius:.65rem; margin-block:1rem; }
table { font-size:.875rem; }
th { background:#101a29; color:var(--muted); font-weight:650; }
th,td { padding:.85rem 1rem; white-space:normal; vertical-align:top; }
td { overflow-wrap:anywhere; min-width:6rem; max-width:28rem; }
tr:last-child td { border-bottom:0; }
tbody tr:hover { background:#ffffff04; }
.journal-table { min-width:56rem; }
.journal-filters { max-width:none; display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,12rem),1fr)); align-items:end; }
.recipient-sheet table { min-width:58rem; }
.recipient-sheet td { padding:.5rem; border-right:0; }
.recipient-sheet input:not([type=checkbox]),.recipient-sheet select { min-width:8rem; border:1px solid #3a4c66; border-radius:.6rem; }
.recipient-sheet input[type=email] { min-width:13rem; }
.recipient-sheet button { margin:0; }
.wc-preview { background:var(--panel); border-radius:.65rem; padding:1rem; }
meter,progress { height:.85rem; }
footer { grid-column:2; width:100%; padding:1rem 1.5rem; border-top:1px solid var(--line); font-size:.875rem; }
.skip-link { position:absolute; z-index:10; top:-5rem; left:1rem; background:var(--accent); color:var(--bg); padding:.75rem; }
.skip-link:focus { top:.5rem; }
@media (max-width:1200px) { .metric-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:900px) {
  body { display:flex; flex-direction:column; }
  .header-inner { padding:1rem; }
  nav.primary-nav { position:static; flex-direction:row; overflow-x:auto; gap:.4rem; padding:.75rem 1rem; border-bottom:1px solid var(--line); align-self:auto; }
  .nav-label { display:none; }
  .primary-nav a { flex-shrink:0; white-space:nowrap; padding:.65rem .8rem; font-size:.875rem; }
  main { flex:1; padding-top:1.25rem; }
  .page-toolbar { align-items:start; flex-direction:column; gap:.75rem; margin-bottom:1.25rem; }
  .notification-switch { width:100%; justify-content:space-between; }
  .grid { grid-template-columns:minmax(0,1fr); gap:0; }
}
@media (max-width:600px) {
  .header-inner { gap:.75rem; flex-wrap:wrap; }
  .header-inner img { width:3.75rem; }
  .header-inner > div { flex:1; }
  .header-inner strong { font-size:.95rem; }
  .header-inner span { font-size:.8rem; }
  .header-inner form { width:100%; display:flex; justify-content:end; }
  .header-inner form button { min-height:2.75rem; }
  .card { border-radius:.8rem; padding:1rem; }
  .metric-grid { gap:.65rem; }
  .metric .eyebrow { font-size:.75rem; letter-spacing:.03em; }
  .metric-value { font-size:1.75rem; }
  .metric-value small { font-size:.875rem; }
  .section-heading { align-items:start; flex-direction:column; }
  dl { grid-template-columns:minmax(0,1fr); gap:.2rem; }
  dd { margin-bottom:.75rem; }
  input:not([type=checkbox]),select,textarea { font-size:1rem; }
  .fields { max-width:none; }
  .fields > button { width:100%; }
  .signal-history { overflow-x:auto; justify-content:start; padding-inline:.2rem; }
  .signal-sample { flex:0 0 1.6rem; }
  .recipient-sheet { border:0; overflow:visible; }
  .recipient-sheet table,.recipient-sheet tbody { display:block; min-width:0; }
  .recipient-sheet thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .recipient-sheet tr { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); border:1px solid var(--line); border-radius:.65rem; padding:.65rem; margin-bottom:1rem; gap:.65rem; }
  .recipient-sheet td { display:block; min-width:0; max-width:none; padding:0; border:0; }
  .recipient-sheet td:nth-child(-n+3) { grid-column:1/-1; }
  .recipient-sheet td::before { content:attr(data-label); display:block; color:var(--muted); font-size:.875rem; margin-bottom:.3rem; }
  .recipient-sheet input:not([type=checkbox]),.recipient-sheet input[type=email],.recipient-sheet select { min-width:0; }
  .recipient-sheet td:last-child { grid-column:1/-1; }
  .recipient-sheet td:last-child::before { display:none; }
  footer { margin-top:auto; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto !important; animation:none !important; transition:none !important; } }
