:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --bg-hover: #1e2a42;
  --border: #2a3550;
  --text-primary: #f0f4f8;
  --text-secondary: #8b9dc3;
  --text-muted: #5a6a8a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: baseline; gap: 0.75rem; }
header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.header-sub { color: var(--text-muted); font-size: 0.8rem; }
.header-right { display: flex; align-items: center; gap: 0.5rem; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}
.status-dot.online { background: var(--success); }
.status-dot.error { background: var(--danger); }
.status-text { color: var(--text-muted); font-size: 0.75rem; }

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1.25rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.stat-card {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* Navigation */
nav {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn.active { background: var(--accent); color: white; }

/* Main */
main { max-width: 1400px; margin: 0 auto; padding: 1.5rem 2rem; }

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.view-header h2 { font-size: 1.125rem; font-weight: 600; }

.search-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  width: 250px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 0.25rem;
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }

/* Video Grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1rem;
}
.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}
.video-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.video-card .title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-card .channel { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.75rem; }
.video-card .summary {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.video-card .meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 500;
}
.badge-success { background: #064e3b; color: #34d399; }
.badge-warning { background: #78350f; color: #fbbf24; }
.badge-danger { background: #7f1d1d; color: #f87171; }
.badge-info { background: #1e3a5f; color: #60a5fa; }

/* Channel List */
.channel-list { display: flex; flex-direction: column; gap: 0.75rem; }
.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  transition: border-color 0.2s;
}
.channel-row:hover { border-color: var(--accent); }
.channel-info { flex: 1; }
.channel-info .name { font-weight: 600; font-size: 0.95rem; }
.channel-info .id { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.25rem; }
.channel-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Toggle Switch */
.toggle {
  position: relative;
  width: 40px; height: 22px;
  cursor: pointer;
}
.toggle input { display: none; }
.toggle .slider {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 11px;
  transition: background 0.2s;
}
.toggle .slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .slider { background: var(--success); }
.toggle input:checked + .slider::before { transform: translateX(18px); }

/* Report */
.report-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  line-height: 1.7;
  white-space: pre-wrap;
}
.report-content h3 { margin: 1.5rem 0 0.75rem; color: var(--accent); font-size: 1.1rem; }
.report-content ul { padding-left: 1.5rem; }
.report-content li { margin-bottom: 0.5rem; }
.report-empty { text-align: center; padding: 4rem; color: var(--text-muted); }

/* Log List */
.log-list { display: flex; flex-direction: column; gap: 0.5rem; }
.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
}
.log-entry .log-time { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; min-width: 140px; }
.log-entry .log-type { font-weight: 600; min-width: 180px; }
.log-entry .log-detail { color: var(--text-secondary); flex: 1; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; align-items: flex-start; justify-content: center; padding: 2rem; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 900px;
  padding: 2rem;
  position: relative;
}
.modal-sm { max-width: 480px; }
.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text-primary); }
.modal-header { margin-bottom: 1.25rem; }
.modal-header h2 { font-size: 1.25rem; line-height: 1.4; }
.modal-meta {
  display: flex; gap: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* Tabs */
.modal-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.tab-btn {
  background: none; border: none;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.summary-section { margin-bottom: 1.5rem; }
.summary-section h3 { font-size: 0.9rem; color: var(--accent); margin-bottom: 0.5rem; }
.summary-section p, .summary-section div {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.9rem;
}

.transcript-box {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-height: 500px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.insights-grid { display: flex; flex-direction: column; gap: 1.25rem; }
.insight-card h3 { font-size: 0.9rem; color: var(--accent); margin-bottom: 0.5rem; }
.insight-card div { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.6; }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag {
  background: var(--bg-hover);
  color: var(--text-primary);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
}

/* Form */
form label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 1rem 0 0.25rem;
}
form input[type="text"] {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
}
form input[type="text"]:focus { border-color: var(--accent); }
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
}
.form-check label { margin: 0; }
form .btn-primary { margin-top: 1.25rem; width: 100%; padding: 0.625rem; }

/* Loading & Empty */
.loading, .empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .video-grid { grid-template-columns: 1fr; }
  header, nav, main, .stats-bar { padding-left: 1rem; padding-right: 1rem; }
  .modal { padding: 1.25rem; }
}
