/* CDN Live Monitor — shadcn/ui (zinc) design tokens and components, no build step. */

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --ring: 240 5.9% 10%;
  --ok: 142 72% 32%;
  --warn: 32 95% 40%;
  --bad: 0 72% 48%;
  --live: 142 71% 45%;
  --radius: 0.625rem;
  color-scheme: light;
}

.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 8% 6%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 18%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --ring: 240 4.9% 83.9%;
  --ok: 142 69% 58%;
  --warn: 38 92% 60%;
  --bad: 0 84% 66%;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; border: 0 solid hsl(var(--border)); }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.sheet-open { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: 12px; font-weight: 400; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout */
.app { max-width: 1320px; margin: 0 auto; padding: 24px 16px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.brand p { font-size: 13px; }
.brand-mark { width: 36px; height: 36px; border-radius: var(--radius); background: hsl(var(--primary)); display: grid; place-items: center; flex: none; }
.brand-mark span { width: 12px; height: 12px; border-radius: 50%; background: hsl(var(--live)); box-shadow: 0 0 0 4px hsl(var(--live) / .25); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ---------- primitives */
.card { background: hsl(var(--card)); border-width: 1px; border-radius: calc(var(--radius) + 2px); box-shadow: 0 1px 2px rgb(0 0 0 / .04); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px; border-radius: calc(var(--radius) - 2px); font-weight: 500; cursor: pointer; background: transparent; transition: background-color .15s, color .15s; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { background: hsl(var(--primary) / .9); }
.btn-ghost:hover { background: hsl(var(--accent)); }
.btn-icon { width: 36px; padding: 0; }
.input { height: 36px; width: 100%; padding: 0 12px; border-width: 1px; border-color: hsl(var(--input)); border-radius: calc(var(--radius) - 2px); background: transparent; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: hsl(var(--ring) / .6); box-shadow: 0 0 0 3px hsl(var(--ring) / .12); }
.select { width: auto; padding-right: 32px; appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }
.select option { background: hsl(var(--card)); }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: hsl(var(--muted)); font-size: 12px; font-weight: 600; white-space: nowrap; }
kbd { font: 500 11px/1 ui-monospace, monospace; padding: 3px 6px; border-width: 1px; border-radius: 4px; color: hsl(var(--muted-foreground)); background: hsl(var(--muted)); }

/* ---------- live pill + banner */
.live-pill { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-width: 1px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--muted-foreground)); }
.live-pill[data-state="ok"] .live-dot { background: hsl(var(--live)); animation: pulse 2s infinite; }
.live-pill[data-state="bad"] { color: hsl(var(--bad)); border-color: hsl(var(--bad) / .4); }
.live-pill[data-state="bad"] .live-dot { background: hsl(var(--bad)); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 hsl(var(--live) / .6); } 70% { box-shadow: 0 0 0 7px hsl(var(--live) / 0); } 100% { box-shadow: 0 0 0 0 hsl(var(--live) / 0); } }

.banner { margin-bottom: 16px; padding: 10px 14px; border-width: 1px; border-radius: var(--radius); font-weight: 500; }
.banner[data-tone="warn"] { color: hsl(var(--warn)); border-color: hsl(var(--warn) / .35); background: hsl(var(--warn) / .08); }
.banner[data-tone="bad"] { color: hsl(var(--bad)); border-color: hsl(var(--bad) / .35); background: hsl(var(--bad) / .08); }

/* ---------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { position: relative; padding: 16px 18px; overflow: hidden; }
.kpi-label { font-size: 13px; font-weight: 500; color: hsl(var(--muted-foreground)); }
.kpi-value { margin-top: 6px; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { margin-top: 4px; font-size: 12px; color: hsl(var(--muted-foreground)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub .up { color: hsl(var(--ok)); } .kpi-sub .down { color: hsl(var(--bad)); }
.kpi[data-tone="warn"] .kpi-value { color: hsl(var(--warn)); }
.kpi[data-tone="bad"] .kpi-value { color: hsl(var(--bad)); }
.spark { position: absolute; right: 14px; top: 16px; width: 96px; height: 34px; overflow: visible; }
.spark-line { fill: none; stroke: hsl(var(--live)); stroke-width: 1.75; vector-effect: non-scaling-stroke; }
.spark-fill { fill: hsl(var(--live) / .12); }

/* ---------- channels card */
.channels { padding: 18px 0 6px; }
.channels-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; padding: 0 18px; }
.channels-head h2 { font-size: 16px; font-weight: 600; }
.channels-head p { font-size: 13px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 320px; justify-content: flex-end; }
.search { position: relative; flex: 1 1 220px; max-width: 340px; display: flex; align-items: center; }
.search .icon { position: absolute; left: 11px; color: hsl(var(--muted-foreground)); pointer-events: none; }
.search .input { padding-left: 34px; padding-right: 36px; }
.search .input::-webkit-search-cancel-button { display: none; }
.search kbd { position: absolute; right: 9px; pointer-events: none; }
.search .input:focus + kbd, .search .input:not(:placeholder-shown) + kbd { display: none; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px 18px 12px; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 12px; border-width: 1px; border-radius: 999px; background: transparent; font-size: 13px; font-weight: 500; cursor: pointer; transition: background-color .15s, border-color .15s; }
.chip:hover { background: hsl(var(--accent)); }
.chip[aria-pressed="true"] { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }
.chip-count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: hsl(var(--muted)); color: hsl(var(--foreground)); font-size: 12px; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .chip-count { background: hsl(var(--primary-foreground) / .18); color: inherit; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { height: 40px; padding: 0 12px; text-align: left; font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground)); border-top-width: 1px; border-bottom-width: 1px; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom-width: 1px; vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 14px; }
.table tbody tr:last-child td { border-bottom-width: 0; }
.row { cursor: pointer; transition: background-color .12s; }
.row:hover, .row.selected { background: hsl(var(--muted) / .6); }
.row:focus-visible { outline-offset: -2px; }
.col-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-go { width: 28px; color: hsl(var(--muted-foreground)); }
.col-go svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; display: block; transition: transform .15s; }
.row:hover .col-go svg { transform: translateX(2px); }

.ch { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.health { width: 8px; height: 8px; border-radius: 50%; flex: none; background: hsl(var(--ok)); box-shadow: 0 0 0 3px hsl(var(--ok) / .15); }
.row[data-health="warn"] .health { background: hsl(var(--warn)); box-shadow: 0 0 0 3px hsl(var(--warn) / .18); }
.row[data-health="bad"] .health { background: hsl(var(--bad)); box-shadow: 0 0 0 3px hsl(var(--bad) / .18); }
.ch-name { font-weight: 600; }
.ch-id { font-size: 12px; color: hsl(var(--muted-foreground)); }
.ch-id:empty { display: none; }

.v-wrap { display: flex; align-items: center; gap: 10px; }
.v-num { min-width: 36px; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; border-radius: 4px; }
.v-bar { flex: 1; min-width: 60px; max-width: 140px; height: 6px; border-radius: 999px; background: hsl(var(--muted)); overflow: hidden; }
.v-bar i { display: block; height: 100%; border-radius: inherit; background: hsl(var(--primary)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.flash-up { animation: flashUp 1.4s; } .flash-down { animation: flashDown 1.4s; }
@keyframes flashUp { 0%, 30% { color: hsl(var(--ok)); } 100% { color: inherit; } }
@keyframes flashDown { 0%, 30% { color: hsl(var(--bad)); } 100% { color: inherit; } }

.q-list { display: flex; gap: 4px; flex-wrap: wrap; }
.q { display: inline-flex; gap: 4px; align-items: center; height: 22px; padding: 0 7px; border-width: 1px; border-radius: 6px; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.q b { font-weight: 600; }
.tone-ok { color: hsl(var(--ok)); } .tone-warn { color: hsl(var(--warn)); } .tone-bad { color: hsl(var(--bad)); }
.empty { padding: 36px 18px; text-align: center; color: hsl(var(--muted-foreground)); }
.footnote { margin-top: 14px; font-size: 12px; }

/* ---------- detail sheet */
.overlay { position: fixed; inset: 0; background: rgb(0 0 0 / .5); opacity: 0; transition: opacity .25s; z-index: 40; }
.overlay.open { opacity: 1; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); z-index: 50; display: flex; flex-direction: column; background: hsl(var(--background)); border-left-width: 1px; box-shadow: -10px 0 30px rgb(0 0 0 / .15); transform: translateX(100%); transition: transform .3s cubic-bezier(.32,.72,0,1); }
.sheet.open { transform: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 18px 14px 20px; border-bottom-width: 1px; }
.sheet-title { font-size: 17px; font-weight: 600; word-break: break-all; }
.sheet-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; font-size: 13px; color: hsl(var(--muted-foreground)); }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }
.sheet-body h3 { margin: 22px 0 10px; font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }

.verdict { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-width: 1px; border-radius: var(--radius); margin-bottom: 14px; }
.verdict-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: hsl(var(--muted-foreground)); }
.verdict-title { font-weight: 600; }
.verdict-text { font-size: 13px; color: hsl(var(--muted-foreground)); }
.verdict[data-tone="ok"] { border-color: hsl(var(--ok) / .35); background: hsl(var(--ok) / .07); }
.verdict[data-tone="ok"] .verdict-dot { background: hsl(var(--ok)); }
.verdict[data-tone="ok"] .verdict-title { color: hsl(var(--ok)); }
.verdict[data-tone="warn"] { border-color: hsl(var(--warn) / .35); background: hsl(var(--warn) / .07); }
.verdict[data-tone="warn"] .verdict-dot { background: hsl(var(--warn)); }
.verdict[data-tone="warn"] .verdict-title { color: hsl(var(--warn)); }
.verdict[data-tone="bad"] { border-color: hsl(var(--bad) / .35); background: hsl(var(--bad) / .07); }
.verdict[data-tone="bad"] .verdict-dot { background: hsl(var(--bad)); animation: pulseBad 1.6s infinite; }
.verdict[data-tone="bad"] .verdict-title { color: hsl(var(--bad)); }
@keyframes pulseBad { 50% { opacity: .35; } }

.player { position: relative; aspect-ratio: 16 / 9; max-width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; }
.player video { width: 100%; height: 100%; display: block; }
.player-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 6px 12px; border-radius: 999px; background: rgb(0 0 0 / .65); color: #fff; font-size: 13px; pointer-events: none; }
.player-msg:empty { display: none; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 12px; }
.stat { padding: 10px 12px; border-width: 1px; border-radius: var(--radius); background: hsl(var(--card)); }
.stat span { display: block; font-size: 12px; color: hsl(var(--muted-foreground)); }
.stat strong { display: block; margin-top: 2px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

.mini { width: 100%; border-collapse: collapse; font-size: 13px; border-width: 1px; border-radius: var(--radius); }
.mini th { text-align: left; font-weight: 500; font-size: 12px; color: hsl(var(--muted-foreground)); padding: 8px 10px; border-bottom-width: 1px; white-space: nowrap; background: hsl(var(--muted) / .5); }
.mini td { padding: 8px 10px; border-bottom-width: 1px; font-variant-numeric: tabular-nums; }
.mini tr:last-child td { border-bottom-width: 0; }
.mini td:first-child { font-weight: 600; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(360px, 100%); padding: 28px; display: grid; gap: 12px; }
.login-card h1 { font-size: 18px; font-weight: 600; margin-top: 4px; }
.form-error { color: hsl(var(--bad)); font-size: 13px; }

/* ---------- theme icon */
.icon-sun { display: none; } .dark .icon-sun { display: block; } .dark .icon-moon { display: none; }

/* ---------- responsive */
@media (max-width: 960px) { .col-q { display: none; } }
@media (max-width: 760px) { .col-cache, .col-err { display: none; } .toolbar { justify-content: stretch; } .search { max-width: none; } }
@media (max-width: 560px) {
  .col-bw { display: none; }
  .v-bar { display: none; }
  .kpi-value { font-size: 24px; }
  .spark { width: 70px; }
  .live-pill { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
