:root {
  --bg: #12151b;
  --panel: #1a1e26;
  --panel-raised: #1f2430;
  --line: #2a3040;
  --text: #e7eaf0;
  --text-muted: #8890a0;
  --text-faint: #5b6272;

  --ok: #45d483;
  --ok-dim: #1e3a2c;
  --warn: #f0a83f;
  --warn-dim: #3d3020;
  --crit: #f0553f;
  --crit-dim: #3d2320;
  --unknown: #5b6272;
  --unknown-dim: #262a33;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 16px 90px;
  min-height: 100vh;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.topbar__brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- old rack header (kept for .rack__link reuse) ---------- */

.rack {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

/* ---------- header ---------- */

.rack__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.rack__title-main {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.rack__title-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 10px;
}

.rack__link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.rack__link .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--unknown);
  flex-shrink: 0;
}

.rack__link[data-state="open"] .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.rack__link[data-state="connecting"] .dot { background: var(--warn); }
.rack__link[data-state="closed"] .dot { background: var(--crit); box-shadow: 0 0 6px var(--crit); }

/* ---------- headline lamp ---------- */

.headline {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.headline__lamp {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--unknown);
  flex-shrink: 0;
}

.headline[data-state="ok"] .headline__lamp { background: var(--ok); box-shadow: 0 0 14px var(--ok); }
.headline[data-state="warn"] .headline__lamp { background: var(--warn); box-shadow: 0 0 14px var(--warn); }
.headline[data-state="crit"] .headline__lamp { background: var(--crit); box-shadow: 0 0 14px var(--crit); animation: pulse 1.4s ease-in-out infinite; }
.headline[data-state="unknown"] .headline__lamp { background: var(--unknown); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.headline__status {
  font-size: 17px;
  font-weight: 700;
}

.headline__detail {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- grid / panels ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel--wide { grid-column: 1 / -1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.panel__head h2 {
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.panel__hint {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.panel__body { padding: 16px; }

.panel__note {
  font-size: 12px;
  color: var(--text-faint);
  margin: 12px 0 0;
  line-height: 1.5;
}

.empty-note {
  color: var(--text-faint);
  font-size: 13px;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ---------- universe grid ---------- */

.universe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.universe-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-raised);
  padding: 10px 12px;
  border-left: 3px solid var(--unknown);
}

.universe-card[data-status="live"] { border-left-color: var(--ok); }
.universe-card[data-status="lost"] { border-left-color: var(--crit); background: var(--crit-dim); }

.universe-card__num {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
}

.universe-card__meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--mono);
}

/* ---------- heartbeat ---------- */

.heartbeat__row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.heartbeat__row:last-child { border-bottom: none; }

.label { color: var(--text-muted); }
.value { color: var(--text); font-weight: 600; }
.mono { font-family: var(--mono); font-weight: 400; }

.raw-block {
  margin: 10px 0 0;
  padding: 8px 10px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- alert log ---------- */

.alert-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-log li {
  display: grid;
  grid-template-columns: 88px 70px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: var(--panel-raised);
  font-size: 12.5px;
}

.alert-log .time {
  font-family: var(--mono);
  color: var(--text-faint);
}

.alert-log .level {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: lowercase;
}

/* The placeholder line is prose, not a log row — it shouldn't be forced
   into the three-column log grid. */
.alert-log li.empty-note {
  display: block;
  background: none;
  padding: 0;
  line-height: 1.5;
}

.alert-log li[data-level="critical"] { border-left: 3px solid var(--crit); }
.alert-log li[data-level="critical"] .level { color: var(--crit); }
.alert-log li[data-level="warning"] { border-left: 3px solid var(--warn); }
.alert-log li[data-level="warning"] .level { color: var(--warn); }
.alert-log li[data-level="info"] { border-left: 3px solid var(--ok); }
.alert-log li[data-level="info"] .level { color: var(--ok); }
.alert-log li[data-level="error"] { border-left: 3px solid var(--crit); }
.alert-log li[data-level="error"] .level { color: var(--crit); }

/* ---------- footer ---------- */

.rack__footer {
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
  text-align: center;
}

.notify-banner {
  display: block;
  width: 100%;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.notify-banner:active { opacity: 0.85; }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 4px 6px;
  border-radius: var(--radius);
  cursor: pointer;
}

.tab-btn.active {
  color: var(--text);
  background: var(--panel-raised);
}

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--unknown);
}

.tab-dot[data-status="ok"] { background: var(--ok); }
.tab-dot[data-status="warn"] { background: var(--warn); }
.tab-dot[data-status="crit"] { background: var(--crit); box-shadow: 0 0 6px var(--crit); }

.tab-panel { display: flex; flex-direction: column; gap: 16px; }
.tab-panel[hidden] { display: none; }

/* ---------- home summary tiles ---------- */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.summary-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--unknown);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  font-family: var(--sans);
  color: var(--text);
}

.summary-tile[data-status="ok"] { border-left-color: var(--ok); }
.summary-tile[data-status="warn"] { border-left-color: var(--warn); }
.summary-tile[data-status="crit"] { border-left-color: var(--crit); background: var(--crit-dim); }

.summary-tile__name {
  font-size: 13px;
  font-weight: 700;
}

.summary-tile__status {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ---------- DiGiCo mirror ---------- */

.mirror-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mirror-frame img {
  width: 100%;
  display: block;
}

/* `display: block` above beats the browser's own [hidden] rule, which left
   the broken-image alt text showing in the frame before the first
   screenshot arrived. Put [hidden] back in charge. */
.mirror-frame img[hidden] { display: none; }

/* ---------- VNC remote button ---------- */

.vnc-button {
  display: inline-block;
  padding: 10px 16px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 8px;
}

.vnc-button:active { opacity: 0.85; }

/* ---------- OSC control form ---------- */

.osc-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.osc-input {
  flex: 1 1 160px;
  padding: 9px 12px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.osc-input::placeholder { color: var(--text-faint); }

#digico-osc-send {
  cursor: pointer;
  border-left-color: var(--warn);
}

/* ---------- OSC vocab list ---------- */

.osc-vocab-h {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 18px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.osc-vocab-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.osc-vocab-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.osc-vocab-list .fn-name {
  flex: 1 1 170px;
  font-size: 13px;
  font-weight: 600;
}

.osc-vocab-list .fn-address {
  flex: 1 1 160px;
  padding: 6px 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.osc-vocab-list .fn-address::placeholder { color: var(--text-faint); }

.osc-vocab-list .fn-use {
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.osc-vocab-list .fn-use:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ================================================================
   DiGiCo console control
   Everything below is the send-side UI. It is deliberately styled
   apart from the read-only panels above — amber/red accents, an arm
   switch, and visible dimming when safe — because it is the only
   part of this dashboard that can change a live show.
   ================================================================ */

/* ---------- console utility row (ping / resend / counts) ---------- */

.util-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.util-btn {
  padding: 9px 14px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.util-btn:active { opacity: 0.85; }
.util-btn:disabled { opacity: 0.4; cursor: default; }

.util-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
}

.util-toggle input { accent-color: var(--ok); width: 15px; height: 15px; }

#digico-ping-result[data-state="good"] { color: var(--ok); }
#digico-ping-result[data-state="pending"] { color: var(--warn); }
#digico-ping-result[data-state="bad"] { color: var(--crit); }

/* ---------- arm switch ---------- */

.panel--arm { border-left: 3px solid var(--warn); }

.panel__hint[data-armed="true"] { color: var(--crit); font-weight: 700; }

.arm-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.arm-btn__lamp {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--unknown);
  flex-shrink: 0;
}

.arm-btn[data-armed="true"] {
  background: var(--crit-dim);
  border-color: var(--crit);
}

.arm-btn[data-armed="true"] .arm-btn__lamp {
  background: var(--crit);
  box-shadow: 0 0 12px var(--crit);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ---------- armed / safe regions ---------- */

.control-region { border-left: 3px solid var(--warn); }

.control-region[data-armed="false"] .panel__body {
  opacity: 0.45;
  filter: saturate(0.4);
}

.control-region[data-armed="false"] { border-left-color: var(--line); }

/* ---------- snapshots ---------- */

.snap-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.snap-btn {
  flex: 1;
  padding: 14px 12px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.snap-btn:disabled { opacity: 0.4; cursor: default; }
.snap-btn:active:not(:disabled) { opacity: 0.85; }

.snap-fire {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.snap-btn--fire {
  flex: 0 0 auto;
  border-left: 3px solid var(--crit);
  padding: 10px 22px;
}

/* ---------- steppers / index selectors ---------- */

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}

.stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  width: max-content;
}

.stepper__btn {
  width: 40px;
  background: var(--panel-raised);
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 18px;
  cursor: pointer;
}

.stepper__btn:disabled { opacity: 0.4; cursor: default; }

.stepper__input {
  width: 68px;
  padding: 9px 6px;
  background: var(--bg);
  border: none;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  text-align: center;
  -moz-appearance: textfield;
}

.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.stepper--lg .stepper__btn { width: 52px; font-size: 22px; }
.stepper--lg .stepper__input { width: 88px; font-size: 20px; padding: 12px 6px; }

.ch-select { margin-bottom: 16px; }

.index-select { margin: 4px 0 12px; }

.band-scope {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

/* ---------- primary mute/solo ---------- */

.ch-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ch-primary .ctl {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-raised);
  padding: 12px;
  margin: 0;
}

.ch-primary .ctl__body { margin-top: 8px; }
.ch-primary .ctl__btn { flex: 1; padding: 12px 0; font-size: 14px; }
.ch-primary .ctl__name { font-size: 15px; }

/* ---------- generated control rows ---------- */

.ctl {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.ctl:last-child { border-bottom: none; }

.ctl__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.ctl__name {
  font-size: 13.5px;
  font-weight: 600;
}

.ctl__tag {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.ctl__body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ctl__btn {
  padding: 8px 16px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ctl__btn:disabled { opacity: 0.4; cursor: default; }
.ctl__btn:active:not(:disabled) { opacity: 0.8; }

/* On/off pairs are neutral by default — turning EQ on isn't a red-alert
   action. Only the genuinely consequential ones get a warning colour, set
   per-control rather than blanket-applied. */
.ctl__btn--on { border-left: 3px solid var(--line); }
.ctl__btn--off { border-left: 3px solid var(--line); }

.ctl[data-tone="crit"] .ctl__btn--on { border-left-color: var(--crit); }
.ctl[data-tone="crit"] .ctl__btn--off { border-left-color: var(--ok); }
.ctl[data-tone="warn"] .ctl__btn--on { border-left-color: var(--warn); }

.ctl__slider {
  flex: 1 1 160px;
  min-width: 120px;
  accent-color: var(--ok);
  height: 26px;
}

.ctl__slider:disabled { opacity: 0.4; }

.ctl__readout {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  min-width: 52px;
  text-align: right;
}

.ctl__input {
  flex: 1 1 110px;
  min-width: 90px;
  max-width: 280px;
  padding: 8px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.ctl__input:disabled { opacity: 0.4; }
.ctl__input::placeholder { color: var(--text-faint); }

.ctl__note {
  font-size: 11.5px;
  color: var(--text-faint);
  margin: 0;
  line-height: 1.5;
}

.ctl--missing { opacity: 0.5; }
.ctl--missing .ctl__note { color: var(--warn); }

/* ---------- disclosure sections ---------- */

.disclosure {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-raised);
  margin-top: 10px;
}

.disclosure > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.disclosure > summary::-webkit-details-marker { display: none; }

.disclosure > summary::before {
  content: "▸";
  margin-right: 8px;
  color: var(--text-faint);
  font-size: 11px;
}

.disclosure[open] > summary::before { content: "▾"; }

.disclosure__count {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-faint);
  margin-left: auto;
  white-space: nowrap;
}

.disclosure > div {
  padding: 4px 14px 14px;
  border-top: 1px solid var(--line);
}

.scale-list {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.scale-list li { margin-bottom: 8px; }
.scale-list code { font-family: var(--mono); font-size: 11.5px; color: var(--text); }

.osc-select {
  flex: 0 1 110px;
  cursor: pointer;
}

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .rack { padding: 14px 12px 40px; }
  .rack__header { flex-direction: column; align-items: flex-start; }
  .alert-log li { grid-template-columns: 70px 60px 1fr; font-size: 12px; }
}

@media (max-width: 520px) {
  .ch-primary { grid-template-columns: 1fr; }
  .util-row { flex-direction: column; align-items: stretch; }
  .util-btn { width: 100%; }
  .util-toggle { justify-content: center; padding: 4px 0; }
  .ctl__readout { min-width: 46px; }
  .snap-fire { flex-direction: column; align-items: stretch; }
  .snap-fire .stepper { width: 100%; }
  .snap-fire .stepper__input { flex: 1; width: auto; }
  .snap-btn--fire { width: 100%; }
}
