:root {
  --bg: #0c0e12;
  --panel: #14171d;
  --panel-2: #1a1e26;
  --line: #252a34;
  --text: #e7eaf0;
  --muted: #8a92a3;
  --live: #ff3b47;
  --ok: #2fd27a;
  --warn: #f5b041;
  --info: #4c9aff;
  --violet: #a78bfa;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
a { color: inherit; }
.link { color: var(--info); text-decoration: none; font-weight: 500; }
[hidden] { display: none !important; }

/* layout */
.app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .2px; padding: 0 8px 18px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: conic-gradient(from 200deg, var(--live), #ff8a3b, var(--live)); position: relative; }
.logo::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--panel); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
nav a:hover { background: var(--panel-2); color: var(--text); }
nav a.on { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--live); }
.side-foot { margin-top: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
main { padding: 22px 28px 40px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 650; }
.top-r { display: flex; align-items: center; gap: 10px; }
.demo-tag { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--warn); border: 1px solid #5a4416; padding: 3px 8px; border-radius: 6px; }

.onair {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.onair i { width: 9px; height: 9px; border-radius: 50%; background: #4a5060; }
.onair b { font-weight: 600; color: var(--text); letter-spacing: 0; }
.onair.live { color: #fff; background: #3a1216; border-color: #6d1e25; }
.onair.live i { background: var(--live); box-shadow: 0 0 0 0 var(--live); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,59,71,.6); } 70% { box-shadow: 0 0 0 8px rgba(255,59,71,0); } 100% { box-shadow: 0 0 0 0 rgba(255,59,71,0); } }

/* cards & tiles */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; margin-bottom: 12px; }
.card-h.sub { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .card, .grid2 { margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tiles.mini { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.tiles.mini .tile { background: var(--panel-2); }
.tl { color: var(--muted); font-size: 12px; font-weight: 500; }
.tv { font-size: 26px; font-weight: 650; margin: 4px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv.small-tv { font-size: 17px; }
.tv.live { color: var(--live); }
.tv.ok { color: var(--ok); }
.ts { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.preview { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.preview video { width: 100%; height: 100%; display: block; }
.preview-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: repeating-linear-gradient(135deg, #0f1115 0 12px, #12151a 12px 24px); text-align: center; padding: 20px; }

.dmini { list-style: none; margin: 0; padding: 0; }
.dmini li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.dmini li:last-child { border-bottom: 0; }
.dmini .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dmini .rt { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #4a5060; }
.dot.live { background: var(--ok); box-shadow: 0 0 8px rgba(47,210,122,.6); }
.dot.starting, .dot.retrying { background: var(--warn); }
.dot.wait { background: #4a5060; outline: 1px solid #6a7080; }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.live { background: #12321f; color: var(--ok); }
.pill.starting, .pill.retrying { background: #3a2c10; color: var(--warn); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* charts */
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 4px 10px; border-radius: 6px; font: inherit; font-size: 12px; cursor: pointer; }
.seg button.on { background: var(--line); color: var(--text); }
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.chart { position: relative; min-width: 0; }
.chart-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.chart .cursor { stroke: #6a7080; stroke-dasharray: 3 3; }
.tip { position: absolute; pointer-events: none; background: #0b0d11; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; white-space: nowrap; z-index: 2; font-variant-numeric: tabular-nums; }

/* destinations */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.bar p { margin: 0; max-width: 640px; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.dcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; border-top: 3px solid var(--c); min-width: 0; }
.dcard.off { opacity: .65; }
.dcard-h { display: flex; align-items: center; gap: 10px; }
.dcard-h h3 { margin: 0; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plat { font-size: 11px; font-weight: 700; color: var(--c); text-transform: uppercase; letter-spacing: .06em; }
.dstate { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dmeta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; min-height: 18px; }
.durl { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.derr { background: #2a1416; border: 1px solid #4a1e23; color: #ffb3b8; font-size: 12px; padding: 6px 8px; border-radius: 6px; font-family: var(--mono); word-break: break-word; }
.dact { display: flex; gap: 6px; margin-top: auto; flex-wrap: wrap; }

.switch { position: relative; width: 38px; height: 22px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #3a404c; border-radius: 999px; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--info); outline-offset: 2px; }

/* tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.big { font-size: 18px; font-weight: 650; }

/* forms & buttons */
.btn { font: inherit; font-weight: 600; border-radius: 8px; padding: 8px 14px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a4150; }
.btn.primary { background: var(--text); color: #0c0e12; border-color: var(--text); }
.btn.primary:hover { background: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff8a92; }
.btn.danger:hover { border-color: #6d1e25; background: #2a1416; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; color: var(--info); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; padding: 0; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 12px; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ok); }
input:focus, select:focus { outline: 2px solid #2d4a7a; border-color: var(--info); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err { background: #2a1416; border: 1px solid #4a1e23; color: #ffb3b8; padding: 8px 10px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }

.svc { list-style: none; margin: 0; padding: 0; }
.svc li { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.svc li .nm { flex: 1; font-family: var(--mono); }

.log { background: #08090c; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0; font: 12px/1.6 var(--mono); color: #c9cfda; white-space: pre-wrap; word-break: break-word; max-height: 65vh; overflow: auto; }
.log .w { color: var(--warn); }
.log .e { color: #ff8a92; }

.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(460px, calc(100vw - 32px)); }
.dlg.wide { width: min(820px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(0,0,0,.6); }
.dlg h2 { margin: 0 0 16px; font-size: 18px; }
.dlg-act { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #0c0e12; padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 50; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: calc(100vw - 32px); }
.toast.bad { background: #ff8a92; }

/* login */
.login-body { display: grid; place-items: center; padding: 16px; }
.login { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login .brand { padding: 0 0 4px; }
.login p { margin: 0 0 20px; }
.login label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.login .btn { width: 100%; padding: 10px; }

/* responsive */
@media (max-width: 1200px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: sticky; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 8px; z-index: 10; overflow-x: auto; }
  .side .brand { padding: 0 8px 0 0; }
  nav { flex-direction: row; }
  nav a { padding: 7px 10px; white-space: nowrap; }
  nav a.on { box-shadow: inset 0 -2px 0 var(--live); }
  .side-foot { margin: 0 0 0 auto; padding: 0; }
  .side-foot .muted { display: none; }
  main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top h1 { font-size: 19px; }
}
@media (max-width: 480px) {
  .tiles.mini { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .tv { font-size: 22px; }
  .onair b { display: none; }
}
