:root {
  --bg: #07080a;
  --rail: #0c0e12;
  --surface: #14171d;
  --inset: #08090c;
  --line: #2b3038;
  --text: #e6edf4;
  --muted: #8b949e;
  --amber: #e0a21a;
  --tally: #e11d2e;
  --go: #17a35c;
  --danger: #c44545;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}
.hidden { display: none !important; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  background: #1c222b;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
}
button:hover { border-color: #4a5563; }
button.go {
  background: var(--go);
  color: #04150c;
  border-color: transparent;
  font-weight: 700;
}
button.danger {
  background: #3a1618;
  color: #ffd0d0;
  border-color: #6b2a30;
}
button.ghost { background: transparent; }
.login-wrap {
  height: 100%;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, #10141a, #07080a);
}
.login-card, .card, .monitor, .log-card {
  background: var(--surface);
  border: 1px solid var(--line);
}
.login-card {
  width: min(400px, calc(100% - 32px));
  padding: 28px;
}
.login-card h1, h2, h3 { margin: 0 0 8px; font-family: "Barlow Condensed", sans-serif; }
.kicker, .mon-top, .meter span, .cg-label span, .badge, .eyebrow {
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--amber);
}
.muted, .hint { color: var(--muted); font-size: 12px; }
label { display: grid; gap: 6px; margin: 12px 0; font-size: 12px; color: var(--muted); }
input, select, textarea {
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 10px;
  min-width: 0;
  width: 100%;
}
.desk {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}
.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}
.rail-head {
  display: flex;
  gap: 10px;
  align-items: center;
}
.rail-head strong {
  display: block;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 22px;
  letter-spacing: 0.08em;
}
.rail-head small { color: var(--muted); }
.tally {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3a4048;
  box-shadow: inset 0 0 0 2px #111;
}
.tally.live {
  background: var(--tally);
  box-shadow: 0 0 12px var(--tally);
  animation: pulse 1.1s infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }
nav { display: grid; gap: 6px; }
nav button { text-align: left; font-family: "Barlow Condensed", sans-serif; font-size: 16px; }
nav button.active {
  background: #1a1510;
  border-color: var(--amber);
  color: var(--amber);
}
.rail-foot { margin-top: auto; display: grid; gap: 8px; color: var(--muted); font-size: 12px; }
.stage {
  min-width: 0;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 64px;
  height: 100vh;
  overflow: hidden;
}
.transport {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #0f1217;
  min-width: 0;
}
.pgm {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.pgm h2 {
  margin: 0;
  font-size: 22px;
  font-family: "Barlow Condensed", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid #5a4518;
  color: var(--amber);
  flex: 0 0 auto;
}
.badge.live {
  color: #fff;
  background: var(--tally);
  border-color: var(--tally);
}
.clock {
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  color: #c5d0dc;
  min-width: 8.5ch;
  text-align: right;
}
.actions { display: flex; gap: 6px; flex: 0 0 auto; }
.workspace {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  padding: 12px;
}
.panel { display: none; min-width: 0; }
.panel.active { display: block; }
.program-panel.active {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 12px;
  height: 100%;
  min-height: 0;
}
.monitor, .log-card, .card { min-width: 0; }
.monitor, .log-card { padding: 10px; display: flex; flex-direction: column; min-height: 0; }
.mon-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.mon-top a { color: var(--muted); font-size: 12px; }
.bezel {
  background: #000;
  border: 2px solid #1b1f26;
  box-shadow: inset 0 0 0 1px #000;
  min-width: 0;
}
.bezel video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: contain;
  background: #000;
}
.url-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  min-width: 0;
}
.url-row code, td code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--inset);
  padding: 7px 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}
.stack { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 12px; min-width: 0; min-height: 0; }
.meters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.meter {
  background: var(--inset);
  border: 1px solid var(--line);
  padding: 10px;
  min-width: 0;
}
.meter b {
  display: block;
  margin-top: 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#log {
  flex: 1;
  min-height: 160px;
  margin: 0;
  overflow: auto;
  overflow-x: hidden;
  background: #050607;
  padding: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #8fbf9a;
  white-space: pre-wrap;
  word-break: break-word;
}
.card { padding: 16px; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-h h3 { margin: 0; font-family: "Barlow Condensed", sans-serif; font-size: 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.add-form { display: grid; grid-template-columns: 160px minmax(0, 1fr) 90px auto; gap: 8px; }
.file-form { grid-template-columns: 160px minmax(0, 1fr) auto; margin-top: 8px; }
.tag-vod {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--amber);
  border: 1px solid #5a4518;
  padding: 1px 5px;
  margin-left: 6px;
  font-family: "Barlow Condensed", sans-serif;
}
.table-wrap { overflow: auto; margin-top: 12px; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: middle; }
th:nth-child(3), td:nth-child(3) { width: 42%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); width: auto; }
.check input { width: auto; }
.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 220px;
  margin: 12px 0;
}
.pos-grid button.active { border-color: var(--amber); color: var(--amber); }
.error { color: #ff8b8b; }
.now td { color: var(--amber); }
.cg {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: #101318;
  min-width: 0;
}
.cg-label {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.cg-label b {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now-on-air { color: var(--go) !important; }
#toast {
  position: fixed;
  right: 16px;
  bottom: 80px;
  background: #13251d;
  border: 1px solid #2f6;
  color: #d8ffe9;
  padding: 10px 14px;
  z-index: 20;
  display: none;
}
@media (max-width: 1100px) {
  .desk { grid-template-columns: 160px minmax(0, 1fr); }
  .program-panel.active, .grid-2, .add-form, .meters, .cg, .transport {
    grid-template-columns: minmax(0, 1fr);
  }
  .stage { grid-template-rows: auto minmax(0, 1fr) auto; }
  .actions { flex-wrap: wrap; }
}
