:root {
  --bg: #0a0e17;
  --bg2: #0f1522;
  --panel: #131b2b;
  --panel2: #18223a;
  --line: #243049;
  --text: #e6ecf5;
  --muted: #8b9ab4;
  --dim: #5d6b85;
  --accent: #e11d48;
  --accent2: #fb7185;
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --gray: #64748b;
  --c1: #38bdf8;
  --c2: #a78bfa;
  --c3: #34d399;
  --c4: #fbbf24;
  --radius: 12px;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", 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 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--c1); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 20px; }
h3 { font-size: 14px; letter-spacing: .02em; }

/* ── Brand ── */
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; letter-spacing: .02em; padding: 4px 6px 18px; }
.brand b { color: var(--accent2); font-weight: 700; }
.brand.big { font-size: 26px; padding: 0 0 4px; justify-content: center; }
.logo-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(225,29,72,.25); }

/* ── Login ── */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(225,29,72,.18), transparent 60%), radial-gradient(900px 500px at 100% 100%, rgba(59,130,246,.14), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 14px; }
.login-card p { text-align: center; margin: 0 0 6px; }

/* ── Layout ── */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
nav { display: grid; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; }
nav a:hover { background: var(--panel); color: var(--text); }
nav a.active { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
nav a .ico { width: 18px; text-align: center; opacity: .9; }
.side-foot { margin-top: auto; display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.me { font-size: 13px; padding: 4px 6px; }
.me .role { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel2); color: var(--muted); margin-left: 6px; text-transform: uppercase; letter-spacing: .05em; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: rgba(10,14,23,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; white-space: nowrap; }
.pill b { font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 10px; }
.clock { font-family: var(--mono); color: var(--muted); font-size: 13px; }
.menu-btn { display: none; }
.view { padding: 20px; display: grid; gap: 16px; align-content: start; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Dot ── */
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gray); flex: none; }
.dot.green { background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,.25); animation: blink 1s infinite; }
.dot.live { background: var(--accent); box-shadow: 0 0 0 3px rgba(225,29,72,.3); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ── Cards / grid ── */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { display: flex; align-items: center; gap: 8px; }
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.ok .value { color: var(--green); }
.kpi.bad .value { color: var(--red); }
.kpi.warn .value { color: var(--yellow); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-width: 0; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v small { font-size: 11px; color: var(--muted); font-weight: 500; }

.chart { width: 100%; height: 150px; display: block; }
.chart.sm { height: 44px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* ── Preview ── */
.preview-wrap { display: grid; grid-template-columns: 1fr 34px; gap: 10px; }
.player { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.player video { width: 100%; height: 100%; object-fit: contain; display: block; }
.player .overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); background: rgba(0,0,0,.55); padding: 16px; }
.player .badge { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.player .tools { position: absolute; bottom: 10px; right: 10px; display: flex; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: rgba(15,21,34,.85); border: 1px solid var(--line); letter-spacing: .03em; }
.tag.live { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag.warn { background: rgba(245,158,11,.15); border-color: rgba(245,158,11,.5); color: var(--yellow); }
.tag.ok { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.45); color: var(--green); }
.tag.err { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.45); color: var(--red); }
.vu { background: #000; border-radius: 8px; border: 1px solid var(--line); width: 34px; height: 100%; display: block; }

/* ── Destinations ── */
.dest-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.dest { position: relative; overflow: hidden; display: grid; gap: 12px; }
.dest::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--pc, var(--gray)); }
.dest-top { display: flex; align-items: center; gap: 10px; }
.dest-top .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dest-top .plat { font-size: 12px; color: var(--muted); }
.dest-top .grow { flex: 1; min-width: 0; }
.dest .status { font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.dest .err-line { font-size: 12px; color: var(--red); background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25); padding: 6px 9px; border-radius: 8px; font-family: var(--mono); word-break: break-word; }
.dest-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dest-foot .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: rgba(255,255,255,.02); }
.table-wrap { overflow-x: auto; }
.otable td.spark { width: 140px; }
.otable canvas { width: 130px; height: 28px; display: block; }

/* ── Forms ── */
label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 14px; width: 100%; min-width: 0;
}
textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; cursor: pointer; }
.form { display: grid; gap: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.hint { font-size: 12px; color: var(--dim); margin-top: -4px; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: var(--mono); font-size: 13px; }
.error { color: var(--red); font-size: 13px; min-height: 1em; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; }
.seg button.on { background: var(--panel2); color: var(--text); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 8px 14px; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 550; font-size: 13.5px; white-space: nowrap; }
.btn:hover { border-color: #33415f; background: #1d2944; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #be123c; }
.btn.green { background: rgba(34,197,94,.15); border-color: rgba(34,197,94,.5); color: #86efac; }
.btn.danger { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.45); color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn.rec { background: rgba(239,68,68,.15); border-color: var(--red); color: #fecaca; }
.btn.rec.on { background: var(--red); color: #fff; }

/* toggle switch */
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #2a3550; border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #cbd5e1; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: #fff; }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }

/* ── Presets ── */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.preset { border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 12px; cursor: pointer; text-align: left; color: var(--text); font: inherit; display: flex; align-items: center; gap: 9px; }
.preset:hover, .preset.on { border-color: var(--pc); box-shadow: inset 0 0 0 1px var(--pc); }
.preset .sw { width: 12px; height: 12px; border-radius: 4px; background: var(--pc); flex: none; }

/* ── Modal / toast ── */
.modal { position: fixed; inset: 0; background: rgba(3,6,12,.7); z-index: 50; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal-card { width: 100%; max-width: 640px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: grid; gap: 14px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--blue); padding: 10px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 13.5px; animation: tin .2s ease-out; }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--yellow); }
.toast.success { border-left-color: var(--green); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.alert-banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: 10px; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.45); color: #fecaca; display: grid; gap: 4px; font-size: 13.5px; }

/* ── Logs ── */
.lv { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; text-transform: uppercase; letter-spacing: .04em; }
.lv.info { background: rgba(59,130,246,.15); color: #93c5fd; }
.lv.success { background: rgba(34,197,94,.15); color: #86efac; }
.lv.warn { background: rgba(245,158,11,.15); color: #fcd34d; }
.lv.error { background: rgba(239,68,68,.15); color: #fca5a5; }
.lv.action { background: rgba(167,139,250,.15); color: #c4b5fd; }
.logs td { font-size: 13px; }
.logs td.t { white-space: nowrap; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.mini-log { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; font-size: 12.5px; }
.mini-log div { display: flex; gap: 8px; align-items: baseline; }
.mini-log .t { color: var(--dim); font-family: var(--mono); font-size: 11.5px; flex: none; }

.guide { background: var(--bg2); border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.guide ol { margin: 6px 0 0; padding-left: 18px; }
.guide b { color: var(--text); }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.bar { height: 6px; border-radius: 99px; background: var(--bg2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--c1); border-radius: 99px; }

/* ── Responsive ── */
@media (max-width: 1280px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .g-main, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .menu-btn { display: inline-flex; }
  .g2 { grid-template-columns: 1fr; }
  .view { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .pills { flex-wrap: nowrap; overflow-x: auto; }
  .clock { display: none; }
  .alert-banner { margin: 12px 16px 0; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dest-grid { grid-template-columns: 1fr; }
}
