:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #141416;
  --surface-2: #1b1b1e;
  --line: #2a2a2e;
  --line-strong: #3a3a3f;
  --text: #f7f3ea;
  --muted: #a8a5a0;
  --faint: #716f6b;
  --red: #e4262d;
  --red-deep: #aa0000;
  --gold: #d6b46a;
  --green: #56d69a;
  --amber: #ffc15a;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 85% -10%, rgba(170, 0, 0, 0.22), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  padding: 0.65rem 1rem;
}

.skip-link:focus {
  top: 1rem;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 0 28px 36px;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--gold);
  border-radius: 12px 4px 12px 4px;
  background: var(--red-deep);
  color: white;
  font-weight: 900;
  letter-spacing: -0.08em;
  transform: skew(-4deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(86, 214, 154, 0.12);
}

.command-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  padding: 32px 0 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(1.7rem, 4vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}

.status-message {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-pill {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  padding: 9px 13px;
  font-size: 0.75rem;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.status-pill[data-status="ok"] span {
  background: var(--green);
}

.status-pill[data-status="error"] span {
  background: var(--red);
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(250px, 1.5fr) repeat(4, minmax(120px, 0.7fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  box-shadow: var(--shadow);
}

.filter-panel label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  background: var(--surface);
  padding: 12px 14px;
}

.filter-panel label > span {
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.filter-panel input,
.filter-panel select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
}

.filter-panel select {
  cursor: pointer;
}

.filter-panel option {
  background: var(--surface);
}

.filter-panel label:focus-within {
  background: var(--surface-2);
  box-shadow: inset 0 -2px var(--red);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.kpi-card {
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  padding: 17px 18px;
}

.kpi-card > span,
.kpi-card small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.kpi-card > strong {
  display: block;
  overflow: hidden;
  margin: 11px 0 8px;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  line-height: 1;
  letter-spacing: -0.05em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-featured {
  border-color: rgba(228, 38, 45, 0.58);
  background: linear-gradient(145deg, rgba(170, 0, 0, 0.92), rgba(87, 0, 0, 0.88));
}

.kpi-featured > span,
.kpi-featured small {
  color: rgba(255, 255, 255, 0.74);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(20, 20, 22, 0.94);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 78px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-heading.compact {
  min-height: 70px;
}

.panel-heading .eyebrow {
  margin-bottom: 5px;
}

.result-count {
  color: var(--muted);
  font-size: 0.74rem;
}

.video-labels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 100px;
  gap: 18px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.video-labels span:nth-child(n + 2) {
  text-align: right;
}

.video-list {
  min-height: 260px;
}

.video-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 100px;
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  transition: background 150ms ease;
}

.video-row:last-child {
  border-bottom: 0;
}

.video-row:hover {
  background: rgba(255, 255, 255, 0.025);
}

.video-main {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.thumbnail {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 9px;
  background: linear-gradient(135deg, #26262a, #101012);
}

.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail .format-tag {
  position: absolute;
  right: 5px;
  bottom: 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.82);
  color: white;
  padding: 3px 5px;
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
}

.video-copy {
  min-width: 0;
}

.video-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 720;
  line-height: 1.34;
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.video-title:hover {
  color: #fff;
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-underline-offset: 3px;
}

.video-meta,
.video-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.video-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.68rem;
}

.video-badges {
  margin-top: 7px;
}

.badge {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px 6px;
  color: var(--muted);
  font-size: 0.59rem;
  font-weight: 700;
}

.badge.topic {
  border-color: rgba(214, 180, 106, 0.38);
  color: var(--gold);
}

.badge.hot {
  border-color: rgba(228, 38, 45, 0.45);
  color: #ff7d82;
}

.metric {
  text-align: right;
}

.metric strong,
.metric small {
  display: block;
}

.metric strong {
  font-size: 0.94rem;
}

.metric small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.64rem;
}

.velocity strong {
  color: var(--green);
}

.side-stack {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
}

.topic-list,
.channel-list {
  padding: 8px 18px 16px;
}

.topic-button {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 11px 0;
  text-align: left;
  cursor: pointer;
}

.topic-button:last-child {
  border-bottom: 0;
}

.topic-button:hover strong,
.topic-button.active strong {
  color: var(--gold);
}

.topic-copy {
  min-width: 0;
}

.topic-copy strong,
.topic-copy small {
  display: block;
}

.topic-copy strong {
  font-size: 0.78rem;
}

.topic-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.64rem;
}

.topic-bar {
  height: 3px;
  overflow: hidden;
  margin-top: 8px;
  border-radius: 99px;
  background: var(--line);
}

.topic-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.topic-value {
  align-self: center;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
}

.trend-chart {
  min-height: 150px;
  padding: 16px 18px 18px;
}

.trend-chart svg {
  display: block;
  width: 100%;
  height: 90px;
  overflow: visible;
}

.trend-chart .trend-value {
  margin-bottom: 10px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.trend-chart small {
  color: var(--muted);
}

.channel-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.channel-item:last-child {
  border-bottom: 0;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.health-dot.error {
  background: var(--red);
}

.health-dot.disabled {
  background: var(--faint);
}

.channel-item strong,
.channel-item small {
  display: block;
}

.channel-item strong {
  overflow: hidden;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-item small,
.channel-count {
  color: var(--muted);
  font-size: 0.63rem;
}

.loading-state,
.empty-state,
.error-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.error-state strong {
  color: var(--text);
}

.empty-state p,
.error-state p {
  max-width: 430px;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.6;
}

.loader {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 25px 2px 0;
  color: var(--faint);
  font-size: 0.7rem;
}

footer p {
  margin-bottom: 0;
}

footer a:hover {
  color: var(--text);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1050px) {
  .filter-panel {
    grid-template-columns: repeat(4, 1fr);
  }

  .search-control {
    grid-column: span 4;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .side-stack {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0 14px 24px;
  }

  .topbar {
    min-height: 68px;
  }

  .brand small,
  .topbar-meta .live-dot {
    display: none;
  }

  .topbar-meta {
    max-width: 120px;
    text-align: right;
  }

  .command-bar {
    align-items: flex-start;
    padding: 25px 0 18px;
  }

  .status-pill {
    padding: 8px 10px;
  }

  .status-pill strong {
    display: none;
  }

  .filter-panel {
    grid-template-columns: repeat(2, 1fr);
  }

  .search-control {
    grid-column: span 2;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-card {
    min-height: 112px;
    padding: 15px;
  }

  .video-labels {
    display: none;
  }

  .video-row {
    grid-template-columns: 1fr 1fr;
    gap: 11px;
    padding: 14px;
  }

  .video-main {
    grid-column: 1 / -1;
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .metric {
    border-top: 1px solid var(--line);
    padding-top: 10px;
    text-align: left;
  }

  .metric:last-child {
    text-align: right;
  }

  .side-stack {
    grid-template-columns: 1fr;
  }

  footer {
    flex-direction: column;
  }
}

@media (max-width: 430px) {
  .brand-mark {
    width: 38px;
    height: 38px;
  }

  h1 {
    font-size: 1.65rem;
  }

  .status-message {
    font-size: 0.78rem;
  }

  .filter-panel label {
    padding: 11px;
  }

  .kpi-card > strong {
    font-size: 1.45rem;
  }

  .video-main {
    grid-template-columns: 98px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

