:root {
  --bg: #0d0c0f;
  --panel: #16151a;
  --panel-2: #1c1b21;
  --line: #2a2830;
  --line-soft: #221f28;
  --text: #eceaf0;
  --muted: #97949f;
  --dim: #6d6a75;
  --accent: #c8a24a;
  --accent-soft: #3a2f14;
  --live: #3ddc7f;
  --hold: #ffb020;
  --danger: #f0616d;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--text); text-decoration: none; }

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .85em;
}

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

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 22px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: .01em; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.brand-sub { color: var(--dim); font-weight: 400; font-size: .8rem; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 7px 13px; border-radius: 7px; color: var(--muted); font-size: .875rem;
}
.nav-links a:hover { background: var(--panel-2); color: var(--text); }
.nav-links a.active { background: var(--accent-soft); color: var(--accent); }
.logout { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user { color: var(--dim); font-size: .8rem; }

/* ----------------------------------------------------------------- layout */

.page { max-width: 1180px; margin: 0 auto; padding: 26px 22px 70px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.35rem; font-weight: 600; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .spacer { margin-left: auto; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card h2 {
  margin: 0 0 4px; font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--dim);
}
.card .hint { color: var(--muted); font-size: .82rem; margin: 0 0 14px; }

/* ------------------------------------------------------------------ forms */

fieldset { border: none; margin: 0 0 26px; padding: 0; }
legend {
  padding: 0; margin-bottom: 4px; font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--accent);
}
/* A legend that carries a state chip - the panel says what it is doing
   without the form under it having to be read. Laid out as a row rather than
   left to sit inline: a legend blockifies what is inside it, so an inline-flex
   chip lands on a line of its own and reads as a heading of its own. */
legend.with-chip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
legend.with-chip .chip { letter-spacing: .05em; }
.legend-hint { color: var(--muted); font-size: .82rem; margin: 0 0 14px; max-width: 70ch; }

label { display: block; margin-bottom: 5px; font-size: .8rem; color: var(--muted); }
.field { margin-bottom: 14px; }
.field .sub { color: var(--dim); font-size: .76rem; margin-top: 5px; }

input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px;
  background: #0a090c; color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  font-family: inherit; font-size: .875rem;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,162,74,.12);
}
textarea { resize: vertical; min-height: 64px; }

.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.check label { margin: 0; color: var(--text); font-size: .875rem; }
.check .sub { margin-top: 2px; }

.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-family: inherit; font-size: .85rem; font-weight: 500;
}
.btn:hover { border-color: #3a3742; background: #232128; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #17130a; font-weight: 600; }
.btn-primary:hover { background: #d8b25a; border-color: #d8b25a; }
.btn-danger { color: var(--danger); border-color: #47262b; background: #1e1417; }
.btn-danger:hover { background: #2a181c; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: .78rem; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ----------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 12px; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--dim);
  border-bottom: 1px solid var(--line);
}
td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.right, th.right { text-align: right; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; color: var(--muted); }

/* ------------------------------------------------------------------ chips */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  border: 1px solid var(--line); background: #100f13; color: var(--dim);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.live { color: var(--live); border-color: #1d4634; }
.chip.hold { color: var(--hold); border-color: #4a3a15; }
.chip.bad { color: var(--danger); border-color: #47262b; }
.chip.on { color: var(--accent); border-color: var(--accent-soft); }

/* --------------------------------------------------------------- banners */

.banner { padding: 11px 22px; font-size: .85rem; border-bottom: 1px solid transparent; }
.banner-warn { background: #2a2110; color: #f0c976; border-color: #4a3a15; }
.banner-ok { background: #10251a; color: var(--live); border-color: #1d4634; }
.banner-bad { background: #241416; color: #f5a3aa; border-color: #47262b; }
.inline-banner { border-radius: 8px; border: 1px solid; margin-bottom: 18px; }

.errors { margin: 0 0 18px; padding: 12px 16px 12px 32px; }
.errors li { margin: 3px 0; }

/* -------------------------------------------------------------- statboard */

.stat { padding: 14px 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; }
.stat .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); }
.stat .v { font-size: 1.25rem; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat .v.small { font-size: .95rem; font-weight: 500; }

/* ---------------------------------------------------------------- preview */

.preview-wrap {
  position: relative; background: #000; border: 1px solid var(--line);
  border-radius: 9px; overflow: hidden; line-height: 0; user-select: none;
}
.preview-wrap img { width: 100%; display: block; }
.preview-empty {
  aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: .85rem; line-height: 1.5; text-align: center; padding: 20px;
}
.roi-box {
  position: absolute; border: 2px solid var(--accent);
  background: rgba(200,162,74,.10); pointer-events: none;
}
.roi-hint { color: var(--dim); font-size: .76rem; margin-top: 8px; }

.probe-result { margin-top: 10px; font-size: .82rem; }
.probe-result.ok { color: var(--live); }
.probe-result.bad { color: var(--danger); }
/* Not failing this instant, but it keeps happening. */
.probe-result.warn { color: var(--hold); }

.pipeline {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: .78rem; color: var(--muted); margin-top: 12px;
}
.pipeline .node {
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: #0a090c;
}
.pipeline .arrow { color: var(--dim); }

.empty {
  text-align: center; padding: 50px 20px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
}

/* ------------------------------------------------------------------ login */

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 30px;
}
.login-card h1 { margin: 0 0 4px; font-size: 1.1rem; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: .85rem; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.login-error {
  background: #241416; color: #f5a3aa; border: 1px solid #47262b;
  border-radius: 7px; padding: 9px 12px; font-size: .82rem; margin-bottom: 16px;
}

/* ------------------------------------------------------------------ radio */

.stations {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 12px; max-height: 340px; overflow-y: auto;
}
.stations:empty { display: none; }
.station {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
.station.picked { border-color: var(--accent); background: var(--accent-soft); }
.station .meta { min-width: 0; }
.station .name {
  font-size: .87rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.station .tags { color: var(--dim); font-size: .74rem; margin-top: 2px; }
.station .btn { margin-left: auto; flex: 0 0 auto; }
.now-playing {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px;
}
.now-playing .name { font-size: .9rem; font-weight: 500; }
.now-playing .muted { color: var(--muted); font-size: .85rem; }

/* Recent gate holds, newest first. */
.holds { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.holds .hint { padding: 2px 0; }
.hold {
  display: flex; align-items: baseline; gap: 10px; padding: 5px 9px;
  border: 1px solid var(--line-soft); border-radius: 7px; background: var(--panel-2);
  font-size: .78rem;
}
.hold .why { flex: 1; min-width: 0; }
.hold .dur, .hold .ago { font-family: var(--mono, monospace); color: var(--dim); }
.hold .dur { color: var(--hold); }
