:root {
  --bg: #0b0e14; --panel: #131822; --panel2: #1a2130; --line: #263042; --text: #e6eaf2; --muted: #8b96ab;
  --red: #e5484d; --green: #30c97a; --amber: #f5a524; --blue: #4c8dff; --grey: #5b667a;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; transition: background .15s; }
.btn:hover:not(:disabled) { background: #232c3f; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.danger { background: #3a1b20; border-color: #6b2830; color: #ff9a9e; }
.btn.go { background: #12301f; border-color: #1f5b3a; color: #7ee2a8; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: transparent; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, #1b2540, var(--bg)); }
.login-card { width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 14px; box-shadow: 0 20px 60px #0008; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.login-card input { font-size: 15px; }
.error { color: #ff8b90; min-height: 18px; font-size: 13px; }

.brand { font-weight: 800; letter-spacing: .12em; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand.big { font-size: 20px; }
.rec { width: 11px; height: 11px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 #e5484d99; animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px #e5484d00; } 100% { box-shadow: 0 0 0 0 #e5484d00; } }

.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 700; letter-spacing: .04em; }
.badge.demo { background: #3b2d0b; color: var(--amber); border: 1px solid #6b4f10; }
.badge.live { background: #3a1b20; color: #ff9a9e; border: 1px solid #6b2830; }
.badge.role { background: #1d2b4a; color: #9bbcff; }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; min-width: 96px; }
.kpi b { font-size: 18px; display: block; line-height: 1.2; }
.kpi span { font-size: 11px; color: var(--muted); }
.kpi.bad b { color: #ff8b90; }
.kpi.warn b { color: var(--amber); }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); }
.user { display: flex; gap: 8px; align-items: center; }
.banner { background: #4a1d22; color: #ffb3b6; text-align: center; padding: 6px; }

.tabs { display: flex; gap: 4px; padding: 10px 18px 0; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 58px; z-index: 15; }
.tabs button { background: none; border: none; padding: 10px 16px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button.active { color: var(--text); border-color: var(--blue); }
.count { background: var(--red); color: white; border-radius: 999px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }
main { padding: 16px 18px 60px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { min-width: 280px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; align-content: start; }
.card.problem { border-color: #6b2830; box-shadow: 0 0 0 1px #6b283055; }
.card.running { border-color: #1f4a35; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head h3 { margin: 0; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; letter-spacing: .05em; }
.pill.RUNNING { background: #12301f; color: #7ee2a8; }
.pill.IDLE { background: #232a38; color: var(--muted); }
.pill.STARTING, .pill.STOPPING { background: #3b2d0b; color: var(--amber); }
.preview { width: 100%; aspect-ratio: 16/9; border-radius: 10px; background: #000; cursor: zoom-in; display: block; }
.stats { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.stats b { color: var(--text); font-weight: 600; }
.stats .bad { color: #ff8b90; } .stats .warn { color: var(--amber); }
.row { display: flex; gap: 8px; align-items: center; }
.row select { flex: 1; min-width: 0; }
.outs { display: grid; gap: 4px; }
.out { display: grid; grid-template-columns: 10px 1fr auto auto 40px; gap: 8px; align-items: center; padding: 5px 8px; background: var(--panel2); border-radius: 8px; font-size: 12.5px; }
.out .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.out .nm small { color: var(--muted); margin-left: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--grey); }
.dot.ACTIVE { background: var(--green); box-shadow: 0 0 8px #30c97a88; }
.dot.ERROR { background: var(--red); animation: pulse 1.2s infinite; }
.dot.STARTING, .dot.STOPPING { background: var(--amber); }
.dot.DISABLED { background: #3c4659; }
.proto { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 5px; letter-spacing: .05em; }
.proto.srt { background: #1d3a5c; color: #8cc4ff; } .proto.rtmp { background: #4a2a52; color: #e2a6ef; }
.mbps { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 52px; text-align: right; }

.switch { position: relative; width: 36px; height: 20px; background: #3c4659; border-radius: 999px; border: none; padding: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: white; border-radius: 50%; transition: transform .15s; }
.switch.on { background: var(--green); } .switch.on::after { transform: translateX(16px); }
.switch:disabled { opacity: .4; cursor: not-allowed; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: var(--panel2); position: sticky; top: 0; }
.tbl td.url { max-width: 360px; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.tbl tr:hover td { background: #161c29; }
.st { display: inline-flex; align-items: center; gap: 6px; }

.list { display: grid; gap: 8px; }
.alert { display: grid; grid-template-columns: 8px 1fr auto; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.alert .bar { align-self: stretch; border-radius: 4px; background: var(--grey); }
.alert.critical .bar { background: var(--red); } .alert.major .bar { background: #ff7a45; }
.alert.warning .bar { background: var(--amber); } .alert.info .bar { background: var(--blue); }
.alert small { color: var(--muted); display: block; margin-top: 2px; }
.alert.inactive { opacity: .55; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; max-width: 780px; display: grid; gap: 14px; }
.panel h3 { margin: 0; }
.sim-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); }

.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 110%; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; min-width: 320px; padding: 6px; z-index: 30; box-shadow: 0 14px 40px #000a; }
.menu-pop button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 9px 12px; border-radius: 7px; }
.menu-pop button:hover { background: #232c3f; } .menu-pop .danger { color: #ff9a9e; }
.menu-pop hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }

.modal-bg { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(520px, 100%); display: grid; gap: 12px; max-height: 92vh; overflow: auto; }
.modal.wide { width: min(1000px, 100%); }
.modal h3 { margin: 0; }
.modal label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.modal input, .modal select { color: var(--text); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.modal canvas { width: 100%; border-radius: 10px; background: #000; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 80; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--green); padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 10px 30px #0009; animation: in .2s; }
.toast.err { border-left-color: var(--red); }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }
@media (max-width: 720px) { .topbar { gap: 8px; } .tabs { top: 0; position: static; overflow-x: auto; } .grid { grid-template-columns: 1fr; } }
