:root {
  --bg: #07090d;
  --panel: #10141c;
  --panel-2: #161b26;
  --line: #232a38;
  --text: #f2f4f8;
  --muted: #8a94a8;
  --blue: #1f6fff;
  --blue-2: #174fc0;
  --red: #e5202e;
  --red-2: #b3121e;
  --green: #19c37d;
  --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; }
a { color: #6fa2ff; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; font-weight: 700; letter-spacing: .01em; }
h2 { font-size: 17px; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: #0b0e14; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 17px; margin-bottom: 28px; padding: 0 8px; }
.brand:hover { text-decoration: none; }
.brand img { max-height: 34px; max-width: 120px; }
.brand-mark { color: var(--red); font-size: 22px; line-height: 1; animation: pulse 1.6s infinite; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a { color: var(--muted); padding: 10px 12px; border-radius: 8px; font-weight: 600; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--panel-2); color: var(--text); border-left-color: var(--red); }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; flex-direction: column; padding: 0 8px; }
.who span { color: var(--muted); font-size: 12px; }
.main { flex: 1; padding: 28px 32px; min-width: 0; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 24px; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card.narrow { max-width: 560px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.card h2 { margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.stat strong { font-size: 28px; }
.stat small { color: var(--muted); }
.stat-live { border-color: rgba(229, 32, 46, .5); }
.stat-live strong { color: var(--red); }
.ok { color: var(--green); }
.bad { color: var(--red); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--panel-2); }
.row-warn td { background: rgba(229, 32, 46, .07); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions form { margin: 0; }

/* Badges */
.badge { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .08em; padding: 4px 9px; border-radius: 4px; white-space: nowrap; }
.badge-live { background: var(--red); color: #fff; box-shadow: 0 0 0 0 rgba(229, 32, 46, .7); animation: live 1.6s infinite; }
.badge-live::before { content: "● "; }
.badge-off { background: #2a303d; color: #b6bfd0; }
.badge-active { background: rgba(31, 111, 255, .18); color: #7fb0ff; border: 1px solid rgba(31, 111, 255, .45); }
.badge-inactive { background: transparent; color: var(--muted); border: 1px solid var(--line); }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(229, 32, 46, .6); } 70% { box-shadow: 0 0 0 8px rgba(229, 32, 46, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 32, 46, 0); } }
@keyframes pulse { 50% { opacity: .35; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; font-weight: 700; font-size: 13px; letter-spacing: .03em; cursor: pointer; color: #fff; background: var(--panel-2); text-decoration: none; }
.btn:hover { text-decoration: none; filter: brightness(1.12); }
.btn-red { background: var(--red); }
.btn-blue { background: var(--blue); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-danger { background: transparent; border-color: rgba(229, 32, 46, .6); color: #ff6b75; }
.btn-xs { padding: 5px 9px; font-size: 12px; }
.btn-lg { padding: 13px 18px; font-size: 15px; }
.btn-block { width: 100%; }
.btn.copied { background: var(--green); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: #c9d0dd; }
label small { color: var(--muted); font-weight: 400; }
input, select { background: #0b0e14; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 11px 12px; font-size: 15px; font-family: inherit; }
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
input:disabled { color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: 16px; height: 16px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.actions form { display: flex; gap: 8px; margin: 0; }
.filters { margin-bottom: 14px; }
.logo-preview { max-height: 60px; max-width: 200px; align-self: flex-start; background: #fff1; padding: 6px; border-radius: 6px; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 600; }
.alert-success { background: rgba(25, 195, 125, .12); border: 1px solid rgba(25, 195, 125, .45); color: #7ee2b5; }
.alert-error { background: rgba(229, 32, 46, .12); border: 1px solid rgba(229, 32, 46, .5); color: #ff8b93; }

/* Channel detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.detail-head h2 { font-size: 26px; margin: 4px 0 8px; }
.detail-state { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.detail-state .badge { font-size: 15px; padding: 8px 14px; }
.field-copy { margin-bottom: 18px; }
.field-copy > .muted:first-child { margin-bottom: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.copy-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.copy-row code { background: #0b0e14; border: 1px solid var(--line); border-radius: 8px; padding: 11px 14px; font-size: 15px; flex: 1; min-width: 260px; word-break: break-all; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 20% 10%, rgba(31, 111, 255, .22), transparent 45%), radial-gradient(circle at 85% 90%, rgba(229, 32, 46, .18), transparent 45%), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: rgba(16, 20, 28, .92); border: 1px solid var(--line); border-radius: 14px; padding: 32px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.login-logo { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; }
.login-logo img { max-height: 44px; max-width: 160px; }
.login-sub { color: var(--muted); margin: -8px 0 4px; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 20px 16px; }
  .table { display: block; overflow-x: auto; }
}
