:root {
  --bg: #0a0d12;
  --panel: #11161e;
  --panel-raised: #171d27;
  --line: #252d39;
  --text: #edf1f7;
  --muted: #8f99a8;
  --accent: #ff614d;
  --accent-soft: rgba(255, 97, 77, 0.13);
  --green: #42d392;
  --amber: #f4b860;
  --red: #ff6b72;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -10%, rgba(255, 97, 77, 0.12), transparent 32rem),
    var(--bg);
}

button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding-bottom: 64px;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand, .top-actions, .intro, .panel-heading, .channel-main, .channel-actions {
  display: flex;
  align-items: center;
}

.brand { gap: 14px; }
.brand h1, .brand p, h2, .eyebrow, .panel-heading p { margin: 0; }
.brand h1 { font-size: 17px; letter-spacing: 0.01em; }
.brand p { margin-top: 3px; color: var(--muted); font-size: 12px; }

.brand-mark {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 10px;
  border-radius: 12px;
  background: var(--accent);
  box-shadow: 0 8px 30px rgba(255, 97, 77, 0.22);
}

.brand-mark i { width: 4px; border-radius: 4px; background: white; }
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 20px; }
.brand-mark i:nth-child(3) { height: 15px; }

.top-actions { gap: 10px; }
.updated-at { margin-right: 6px; color: var(--muted); font-size: 12px; }
.auth-identity { color: var(--green); font-size: 11px; white-space: nowrap; }

.button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 650;
  font-size: 13px;
  transition: border-color 150ms, background 150ms, transform 150ms;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.55; transform: none; }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover { background: #ff7563; }
.button-quiet { background: var(--panel); border-color: var(--line); }
.button-quiet:hover { border-color: #3a4555; background: var(--panel-raised); }
.button-danger { color: var(--red); border-color: rgba(255, 107, 114, 0.28); background: rgba(255, 107, 114, 0.07); }
.button-danger:hover { border-color: rgba(255, 107, 114, 0.52); background: rgba(255, 107, 114, 0.13); }

main { padding-top: 48px; }
.intro { justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: 0.16em; text-transform: uppercase; }
h2 { margin-top: 6px; font-size: 24px; letter-spacing: -0.025em; }

.system-health {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 12px;
}

.system-health span, .status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--muted);
}
.system-health.online span, .status-live .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(66, 211, 146, 0.1); }
.status-error .status-dot { background: var(--red); }
.status-stale .status-dot { background: var(--amber); }
.status-disabled .status-dot { background: #596270; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  min-height: 136px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255,255,255,0.018), transparent), var(--panel);
}

.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-card strong { margin: 8px 0 3px; font-size: 34px; line-height: 1; letter-spacing: -0.04em; }
.stat-card small { color: #667080; font-size: 11px; }
.stat-card-warn strong { color: var(--amber); }

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.panel-heading { justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font-size: 19px; }
.panel-heading > p { color: var(--muted); font-size: 11px; }
.breaking-panel {
  margin-top: 28px;
  border-color: rgba(255, 97, 77, 0.22);
  background:
    linear-gradient(145deg, rgba(255, 97, 77, 0.035), transparent 38%),
    var(--panel);
}
.breaking-heading { gap: 24px; padding: 24px 28px; }
.breaking-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.breaking-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.breaking-filter > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.breaking-filter select {
  height: 34px;
  min-width: 178px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: rgba(0, 0, 0, 0.2);
  color-scheme: dark;
  cursor: pointer;
}
.breaking-filter select:hover { border-color: #3a4555; }
.breaking-filter select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.breaking-status {
  max-width: 380px;
  padding: 7px 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.16);
  text-align: right;
  line-height: 1.35;
}
.breaking-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}
.breaking-empty { grid-column: 1 / -1; padding: 32px 24px; }
.breaking-status-active { color: var(--amber) !important; }
.breaking-status-error { color: var(--red) !important; }
.breaking-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 13, 18, 0.48);
}
.breaking-card:hover { border-color: #354050; background: rgba(18, 23, 31, 0.82); }
.breaking-meta, .breaking-sources { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.breaking-category { padding: 4px 8px; color: var(--red); border-radius: 99px; background: rgba(255, 107, 114, 0.1); font-size: 9px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.breaking-time, .breaking-confidence { color: var(--muted); font-size: 10px; }
.breaking-confidence { margin-left: auto; }
.breaking-card h3 { margin: 14px 0 8px; font-size: 17px; line-height: 1.3; letter-spacing: -0.01em; }
.breaking-summary { margin: 0; color: #cbd2dd; font-size: 13px; line-height: 1.65; }
.breaking-sources { margin-top: auto; padding-top: 18px; color: #667080; font-size: 10px; }
.breaking-sources > strong { padding: 3px 7px; color: var(--text); border: 1px solid var(--line); border-radius: 99px; font-size: 9px; font-weight: 650; }
.breaking-first-seen { width: 100%; margin-top: 3px; color: var(--muted); }
.channel-list { min-height: 120px; }
.empty-state { padding: 44px 24px; color: var(--muted); text-align: center; }

.channel-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(120px, 1fr)) auto;
  align-items: center;
  gap: 22px;
  min-height: 92px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}
.channel-row:last-child { border-bottom: 0; }
.channel-row:hover { background: rgba(255,255,255,0.015); }
.channel-main { min-width: 0; gap: 13px; }
.channel-main { cursor: pointer; }
.channel-main > div { min-width: 0; }
.channel-main strong { display: block; font-size: 14px; }
.channel-main small {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-cell span { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; }
.channel-cell strong { display: block; margin-top: 6px; font-size: 13px; font-weight: 600; }
.channel-cell > small { display: block; margin-top: 5px; color: #667080; font-size: 10px; }
.status-label { display: flex !important; align-items: center; gap: 7px; color: var(--text) !important; font-size: 12px !important; letter-spacing: 0 !important; text-transform: none !important; }
.channel-actions { justify-content: flex-end; gap: 8px; }
.channel-actions .button { min-height: 34px; padding: 0 11px; font-size: 12px; }

dialog {
  width: min(520px, calc(100% - 30px));
  padding: 0;
  color: var(--text);
  border: 1px solid #303947;
  border-radius: 17px;
  background: var(--panel-raised);
  box-shadow: 0 24px 90px rgba(0,0,0,0.55);
}
dialog::backdrop { background: rgba(3, 5, 8, 0.78); backdrop-filter: blur(4px); }
dialog form { padding: 25px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.dialog-heading h2 { font-size: 21px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: transparent; cursor: pointer; font-size: 22px; line-height: 1; }

label { display: block; margin-bottom: 17px; }
label > span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 650; }
label > small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
input[type="text"], input[type="url"], input[type="password"], input:not([type]) {
  width: 100%;
  height: 43px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid #303947;
  border-radius: 9px;
  outline: none;
  background: #0d1118;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; }
.switch-row > span, .switch-row small { margin: 0; }
.switch-row strong { display: block; font-size: 12px; }
.switch-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-error { min-height: 18px; margin: 0 0 8px; color: var(--red); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.login-dialog { width: min(430px, calc(100% - 30px)); }
.login-intro { margin: -7px 0 22px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.toast { position: fixed; right: 22px; bottom: 22px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-raised); box-shadow: 0 10px 40px rgba(0,0,0,0.35); opacity: 0; transform: translateY(8px); pointer-events: none; transition: 180ms; font-size: 12px; }
.toast.visible { opacity: 1; transform: translateY(0); }

.transcript-dialog {
  width: min(720px, calc(100% - 30px));
  height: min(780px, calc(100vh - 36px));
}
.transcript-shell { height: 100%; display: flex; flex-direction: column; }
.transcript-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 25px 20px;
  border-bottom: 1px solid var(--line);
}
.transcript-heading h2 { font-size: 22px; }
.transcript-heading-actions { display: flex; align-items: center; gap: 11px; }
.stream-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.stream-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.stream-status.connected i { background: var(--green); box-shadow: 0 0 0 4px rgba(66, 211, 146, 0.1); }
.stream-status.reconnecting i { background: var(--amber); }
.transcript-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 25px 24px;
  scroll-behavior: smooth;
}
.transcript-empty { padding: 70px 10px; color: var(--muted); text-align: center; font-size: 13px; }
.transcript-card { padding: 18px 0; border-bottom: 1px solid var(--line); }
.transcript-card:last-child { border-bottom: 0; }
.transcript-meta { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.transcript-time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.transcript-badge { padding: 3px 7px; border-radius: 99px; color: var(--green); background: rgba(66, 211, 146, 0.1); font-size: 9px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.transcript-badge.partial, .transcript-badge.gap { color: var(--amber); background: rgba(244, 184, 96, 0.1); }
.transcript-badge.failed { color: var(--red); background: rgba(255, 107, 114, 0.1); }
.transcript-text { margin: 0; color: #d9dee7; font-size: 14px; line-height: 1.65; }
.transcript-note { margin: 9px 0 0; color: var(--amber); font-size: 10px; }
.transcript-footer { display: flex; justify-content: space-between; padding: 13px 25px; color: #667080; border-top: 1px solid var(--line); font-size: 10px; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .channel-row { grid-template-columns: minmax(180px, 2fr) 1fr 1fr auto; }
  .channel-cell-coverage { display: none; }
}

@media (max-width: 650px) {
  .shell { width: min(100% - 24px, 1180px); }
  .topbar { align-items: flex-start; padding: 18px 0; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .updated-at { width: 100%; margin: 0; text-align: right; }
  main { padding-top: 32px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 116px; padding: 17px; }
  .channel-row { grid-template-columns: 1fr auto; gap: 14px; }
  .channel-cell { display: none; }
  .channel-actions { grid-column: 1 / -1; justify-content: flex-start; padding-left: 21px; }
  .breaking-heading { align-items: flex-start; flex-direction: column; gap: 14px; padding: 20px; }
  .breaking-controls { width: 100%; justify-content: space-between; }
  .breaking-filter { flex: 1 1 220px; }
  .breaking-filter select { min-width: 0; flex: 1; }
  .breaking-status { max-width: 100%; padding: 6px 8px; }
  .breaking-list { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .breaking-card { padding: 17px; }
  .transcript-dialog { height: calc(100vh - 20px); }
  .transcript-heading, .transcript-list { padding-left: 18px; padding-right: 18px; }
  .stream-status { display: none; }
}
