/* setconnect operator dashboard.
 *
 * Built as studio hardware rather than as a web dashboard: a rack of machines,
 * each a row of channel strips. Two rules hold the whole thing together —
 *
 *   1. Colour only ever means signal state. Green, amber and red are the dBFS
 *      scale, the same one the desktop meters use. Nothing is coloured to
 *      decorate, and there is no brand accent competing with the signal.
 *   2. Monospace only ever means measurement. Timecodes, dB, byte counts and
 *      channel numbers, so digits never shift as values tick.
 */

:root {
  --rack:   #0d1317;   /* the room, dark with a blue-green cast */
  --panel:  #141d22;
  --strip:  #1a252b;
  --strip-2:#1f2c33;
  --rule:   #27353d;
  --rule-hi:#3a4c57;

  --read:   #dde7eb;   /* readout */
  --mark:   #9dafb8;   /* the grayer half of the wordmark */
  --legend: #8195a0;   /* legending */
  --faint:  #5b6c76;

  --sig:    #45c285;
  --warn:   #e5a23c;
  --fault:  #e8594a;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --rail: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--rack);
  color: var(--read);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Measurement. Tabular so a ticking timecode does not shuffle sideways. */
.m {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--sig); outline-offset: 2px; }

/* ------------------------------------------------------------- status bar */

.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px; height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}

/* The wordmark. Lowercase throughout, with `set` carried a shade back so the
 * two halves read as one word rather than as two stuck together. */
.wordmark { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; color: var(--read); }
.wordmark span { color: var(--mark); font-weight: inherit; }

.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tabs button {
  background: none; border: 1px solid transparent; border-radius: 2px;
  color: var(--legend); padding: 5px 12px; font-size: 13px;
}
.tabs button:hover { color: var(--read); background: var(--strip); }
.tabs button[aria-current="page"] {
  color: var(--read); background: var(--strip-2); border-color: var(--rule-hi);
}

.bar__spacer { flex: 1; }

.tally { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--legend); }
.tally__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sig); }
.tally__dot--fault { background: var(--fault); }
.tally__dot--warn { background: var(--warn); }

.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--legend); }
.who button {
  background: none; border: 1px solid var(--rule); border-radius: 2px;
  color: var(--legend); padding: 4px 10px; font-size: 12px;
}
.who button:hover { color: var(--read); border-color: var(--rule-hi); }

/* ------------------------------------------------------------------ page */

main { padding: 20px; max-width: 1400px; }

.stale {
  display: none; margin-bottom: 16px; padding: 9px 12px;
  border: 1px solid var(--warn); border-left-width: var(--rail);
  background: color-mix(in srgb, var(--warn) 9%, transparent);
  font-size: 13px;
}
.stale[data-on="1"] { display: block; }

/* ---------------------------------------------------------------- faults */

.faults { margin-bottom: 20px; border: 1px solid var(--rule); }
.faults__head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; background: var(--panel);
  border-bottom: 1px solid var(--rule);
  font-size: 13px; font-weight: 600;
}
.faults__list { list-style: none; margin: 0; padding: 0; }
.faults__list li {
  display: flex; gap: 12px; align-items: baseline;
  padding: 8px 14px; border-bottom: 1px solid var(--rule);
  font-size: 13px;
}
.faults__list li:last-child { border-bottom: 0; }
.faults__who { color: var(--legend); min-width: 130px; }
.lv-error { color: var(--fault); }
.lv-warn  { color: var(--warn); }

/* ------------------------------------------------------------------ rack */

.machine {
  margin-bottom: 14px;
  border: 1px solid var(--rule);
  border-left: var(--rail) solid var(--faint);   /* the on-air lamp */
  background: var(--panel);
}
.machine[data-state="live"]    { border-left-color: var(--sig); }
.machine[data-state="warn"]    { border-left-color: var(--warn); }
.machine[data-state="fault"]   { border-left-color: var(--fault); }
.machine[data-state="offline"] { border-left-color: var(--faint); opacity: .62; }

.machine__head {
  display: flex; align-items: baseline; gap: 14px;
  padding: 11px 14px; border-bottom: 1px solid var(--rule);
}
.machine__name { font-size: 14px; font-weight: 650; }
.machine__meta { color: var(--legend); font-size: 12.5px; }
.machine__head .m { font-size: 13px; }

.rec {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; letter-spacing: .04em; color: var(--sig);
}
.rec__lamp {
  width: 7px; height: 7px; border-radius: 50%; background: var(--sig);
  animation: pulse 2.4s ease-in-out infinite;
}
.rec--idle { color: var(--faint); }
.rec--idle .rec__lamp { background: var(--faint); animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }
@media (prefers-reduced-motion: reduce) { .rec__lamp { animation: none } }

/* -------------------------------------------------------- channel strips */

.strips { display: grid; }

.strip {
  display: grid;
  grid-template-columns: 26px 1fr 122px 34px 1fr 78px 92px;
  align-items: center; gap: 12px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--rule);
  background: var(--strip);
}
.strip:nth-child(even) { background: var(--strip-2); }
.strip:last-child { border-bottom: 0; }
.strip--off { opacity: .4; }

/* Channel number, legended like a console. */
.strip__n {
  font-family: var(--mono); font-size: 12px; color: var(--faint);
  text-align: center; border: 1px solid var(--rule); border-radius: 2px; padding: 1px 0;
}
.strip__name { font-size: 13px; font-weight: 550; }
.strip__patch { color: var(--faint); font-size: 11.5px; font-family: var(--mono); }
.strip__db { text-align: right; font-size: 12px; color: var(--legend); }
.strip__db--hot { color: var(--fault); }
.strip__dj { font-size: 13px; }
.strip__dj--none { color: var(--faint); }
.strip__state { font-size: 12px; color: var(--warn); }
.strip__time { text-align: right; font-size: 12.5px; color: var(--legend); }
.strip__up { text-align: right; font-size: 11.5px; color: var(--faint); }
.strip__up--done { color: var(--sig); }
.strip__up--stall { color: var(--warn); }

/* LED-ladder meter. The segmentation is drawn as gaps over the fill, so the
 * bar reads as discrete lamps rather than a smooth progress bar. */
.meter { position: relative; height: 9px; background: #0a1013; border: 1px solid var(--rule); }
.meter__fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg,
    var(--sig) 0%, var(--sig) 72%, var(--warn) 86%, var(--fault) 100%);
  background-size: 122px 100%;   /* scale stays fixed to the track, not the fill */
  transition: width .08s linear;
}
.meter__peak { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--read); }
.meter__peak--hot { background: var(--fault); }
.meter__ref { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--rule-hi); }
.meter::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg,
    transparent 0 4px, #0a1013 4px 5.5px);
}
@media (prefers-reduced-motion: reduce) { .meter__fill { transition: none } }

/* ----------------------------------------------------------------- table */

.sheet { width: 100%; border-collapse: collapse; border: 1px solid var(--rule); }
.sheet th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--legend);
  padding: 9px 12px; background: var(--panel); border-bottom: 1px solid var(--rule);
}
.sheet td { padding: 9px 12px; border-bottom: 1px solid var(--rule); font-size: 13px; }
.sheet tr:last-child td { border-bottom: 0; }
.sheet tbody tr:hover { background: var(--strip); }
.sheet .num { text-align: right; }

.pill {
  display: inline-block; padding: 1px 7px; border-radius: 2px;
  font-size: 11px; font-weight: 600; border: 1px solid;
}
.pill--ready { color: var(--sig);   border-color: color-mix(in srgb, var(--sig) 45%, transparent);
               background: color-mix(in srgb, var(--sig) 12%, transparent); }
.pill--work  { color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
               background: color-mix(in srgb, var(--warn) 12%, transparent); }
.pill--fault { color: var(--fault); border-color: color-mix(in srgb, var(--fault) 45%, transparent);
               background: color-mix(in srgb, var(--fault) 12%, transparent); }
.pill--idle  { color: var(--legend); border-color: var(--rule); }

.act {
  background: var(--strip-2); border: 1px solid var(--rule-hi); border-radius: 2px;
  color: var(--read); padding: 3px 10px; font-size: 12px;
}
.act:hover:not(:disabled) { border-color: var(--read); }
.act:disabled { opacity: .4; cursor: not-allowed; }
.act--quiet { background: none; border-color: var(--rule); color: var(--legend); }
.act + .act { margin-left: 6px; }

.key { font-family: var(--mono); font-size: 12.5px; letter-spacing: .02em; }
.key--dead { color: var(--faint); text-decoration: line-through; }

/* ------------------------------------------------------------- empty/sign-in */

.empty { padding: 56px 20px; text-align: center; color: var(--legend); }
.empty h2 { font-size: 15px; font-weight: 600; color: var(--read); margin: 0 0 6px; }
.empty p { margin: 0; font-size: 13px; max-width: 46ch; margin-inline: auto; }

.gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.gate__inner { width: 100%; max-width: 330px; }
.gate h1 { margin: 0 0 6px; }
.gate h1 .wordmark { font-size: 21px; }
.gate p { color: var(--legend); font-size: 13px; margin: 0 0 22px; }
.gate button {
  width: 100%; padding: 11px; border-radius: 2px;
  background: var(--strip-2); border: 1px solid var(--rule-hi); color: var(--read);
  font-size: 14px; font-weight: 550;
}
.gate button:hover { border-color: var(--read); }
.gate__note { margin-top: 14px; font-size: 12px; color: var(--faint); }
.gate__err { margin-bottom: 18px; padding: 9px 11px; font-size: 13px;
             border: 1px solid var(--fault); border-left-width: var(--rail);
             background: color-mix(in srgb, var(--fault) 10%, transparent); }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--strip-2); border: 1px solid var(--rule-hi); border-radius: 2px;
  padding: 9px 16px; font-size: 13px; z-index: 50;
}
.toast--bad { border-color: var(--fault); }

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

@media (max-width: 900px) {
  main { padding: 12px; }
  .bar { gap: 10px; padding: 0 12px; }
  .machine__meta { display: none; }
  /* Collapse to the three things that matter on a phone in a corridor:
     which channel, is there signal, and who is on it. */
  .strip { grid-template-columns: 24px 1fr 72px 34px; row-gap: 3px; }
  .strip__dj, .strip__time, .strip__up { grid-column: 2 / -1; text-align: left; font-size: 12px; }
  .sheet thead { display: none; }
  .sheet, .sheet tbody, .sheet tr, .sheet td { display: block; width: 100%; }
  .sheet tr { border-bottom: 1px solid var(--rule); padding: 6px 0; }
  .sheet td { border: 0; padding: 3px 12px; }
  .sheet .num { text-align: left; }
}

/* -------------------------------------------------------------- machines */

/* A token is shown once and never again, so the panel that reveals it has to
 * look like a thing you must act on — not another row in a table. */
.reveal {
  margin-bottom: 16px; border: 1px solid var(--sig);
  border-left-width: var(--rail);
  background: color-mix(in srgb, var(--sig) 8%, transparent);
  padding: 14px 16px;
}
.reveal h3 { margin: 0 0 4px; font-size: 14px; font-weight: 650; }
.reveal p { margin: 0 0 12px; font-size: 13px; color: var(--legend); max-width: 62ch; }
.reveal__token {
  display: flex; align-items: center; gap: 10px;
  background: #0a1013; border: 1px solid var(--rule); padding: 10px 12px;
}
.reveal__token code {
  font-family: var(--mono); font-size: 13px; word-break: break-all; flex: 1;
  user-select: all;
}

.dialog {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 20px;
  background: rgba(3, 6, 8, .72);
}
.dialog__panel {
  width: 100%; max-width: 420px; background: var(--panel);
  border: 1px solid var(--rule-hi); padding: 20px;
}
.dialog h3 { margin: 0 0 6px; font-size: 15px; font-weight: 650; }
.dialog p { margin: 0 0 16px; font-size: 13px; color: var(--legend); }
.dialog input[type="text"] {
  width: 100%; padding: 9px 10px; background: #0a1013;
  border: 1px solid var(--rule-hi); border-radius: 2px; color: var(--read);
  margin-bottom: 14px;
}
.dialog label { display: flex; gap: 8px; align-items: flex-start;
                font-size: 13px; color: var(--legend); margin-bottom: 16px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }

.act--danger { border-color: color-mix(in srgb, var(--fault) 55%, transparent); color: var(--fault); }
.act--danger:hover:not(:disabled) { border-color: var(--fault); }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
       margin-right: 7px; vertical-align: 1px; }
.dot--on { background: var(--sig); }
.dot--off { background: var(--faint); }
.dot--bad { background: var(--fault); }

/* The endpoint an operator types into a booth machine. Given its own panel
 * because it is the one value needed on every manual setup. */
.endpoint {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px; padding: 11px 14px;
  border: 1px solid var(--rule); background: var(--panel);
}
.endpoint__label { font-size: 11.5px; color: var(--legend); margin-bottom: 2px; }
.endpoint__value {
  font-family: var(--mono); font-size: 13px; color: var(--read);
  user-select: all; word-break: break-all;
}
.endpoint > div { flex: 1; min-width: 0; }
.reveal__token a.act { text-decoration: none; display: inline-flex; align-items: center; }

.reveal__note { margin: 10px 0 6px; font-size: 12px; color: var(--legend); }
.reveal__actions { margin-top: 14px; display: flex; justify-content: flex-end; }
.reveal .reveal__token + .reveal__token { margin-top: 8px; }
