/* SKYup News - Feed Analyst & Telemetry System
 * Executive Dark-Mode Design System
 */

:root {
  --bg-base: #080c14;
  --bg-surface: #0f172a;
  --bg-card: rgba(18, 26, 44, 0.75);
  --bg-card-hover: rgba(26, 38, 64, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(59, 130, 246, 0.35);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(59, 130, 246, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 85% 60%, rgba(139, 92, 246, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 15, 25, 0.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 1.5rem;
}

.header-container {
  max-width: 1560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2), 0 2px 8px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-logo-badge:hover {
  transform: scale(1.06);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-company {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  color: var(--accent-cyan);
}

.brand-app {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.version-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-family: var(--font-mono);
}

.header-center {
  display: flex;
  align-items: center;
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulseGlow 1.8s infinite;
}

.pulse-dot-sm {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
  animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; filter: drop-shadow(0 0 5px #10b981); }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.live-text {
  color: #10b981;
  letter-spacing: 0.05em;
}

.live-fps {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding-left: 0.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.time-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  max-width: 420px;
}

.time-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.time-btn:hover {
  color: white;
  background: rgba(255,255,255,0.08);
}

.time-btn.active {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* Special style for "All Time" button */
.time-btn[data-hours="0"].active {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.5);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* Dashboard Container */
.dashboard-main {
  max-width: 1560px;
  margin: 1.5rem auto 3rem;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Top KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.15rem;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
}

.kpi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  font-family: var(--font-display);
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-views { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.icon-clicks { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.icon-likes { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.icon-comments { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.icon-dwell { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

.kpi-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.trend-badge {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

.trend-badge.positive {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.trend-badge.neutral {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
}

.ctr-details {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.live-readers-tag {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.kpi-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Visualizer Grid (Charts & Geo) */
.visualizer-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 1.25rem;
}

.panel-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  gap: 0.75rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  color: #ffffff;
}

.panel-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.chart-legend-custom {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.views { background: var(--accent-cyan); }
.dot.clicks { background: var(--accent-blue); }
.dot.likes { background: var(--accent-rose); }

.chart-container {
  position: relative;
  height: 275px;
  width: 100%;
}

/* Area-Wise Section */
.geo-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px;
  border-radius: var(--radius-md);
}

.geo-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.geo-tab-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.geo-content-container {
  overflow-y: auto;
  max-height: 275px;
  padding-right: 0.35rem;
}

.geo-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.geo-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}

.geo-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.geo-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.geo-name-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.geo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-cyan);
}

.geo-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: #f1f5f9;
}

.geo-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.geo-metrics-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.geo-views {
  color: #ffffff;
  font-weight: 600;
}

.geo-share {
  color: var(--accent-cyan);
  font-weight: 600;
}

.geo-progress-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  overflow: hidden;
}

.geo-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #06b6d4, #3b82f6);
  border-radius: 9999px;
}

/* Secondary Grid (Categories + Live Ticker) */
.secondary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.category-bars {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.category-bar-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.category-row-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
}

.cat-name { color: #f8fafc; }
.cat-stats { font-family: var(--font-mono); color: var(--text-secondary); font-size: 0.76rem; }

.cat-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease;
}

.fill-tech { background: linear-gradient(90deg, #06b6d4, #3b82f6); }
.fill-business { background: linear-gradient(90deg, #10b981, #059669); }
.fill-politics { background: linear-gradient(90deg, #8b5cf6, #ec4899); }
.fill-sports { background: linear-gradient(90deg, #f59e0b, #ea580c); }
.fill-general { background: linear-gradient(90deg, #64748b, #94a3b8); }

/* Live Ticker */
.ticker-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stream-event-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.stream-event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.stream-event-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.event-type-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

.badge-view { background: rgba(6, 182, 212, 0.2); color: #22d3ee; }
.badge-click { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.badge-like { background: rgba(244, 63, 94, 0.2); color: #fb7185; }
.badge-comment { background: rgba(139, 92, 246, 0.2); color: #c084fc; }
.badge-share { background: rgba(52, 211, 153, 0.2); color: #34d399; }

.stream-story-title {
  color: #e2e8f0;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-event-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.stream-geo {
  color: var(--text-secondary);
}

/* Feed Performance Table */
.feed-table-section {
  width: 100%;
}

.table-panel {
  padding: 1.5rem;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.table-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.category-pills {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.cat-pill {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.cat-pill.active {
  background: var(--accent-blue);
  color: white;
}

.sort-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.custom-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: white;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
}

.custom-select option {
  background: #0f172a;
  color: white;
}

.table-responsive {
  overflow-x: auto;
  /* overflow-x makes this a scroll container on both axes, so the sticky header
     below pins to this box rather than the page. Give it a viewport-relative
     height so that header actually has something to stick to. */
  max-height: calc(100vh - 12rem);
  overscroll-behavior: contain;
}

.feed-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.feed-table th {
  position: sticky;
  /* Pins to the top of .table-responsive. Any offset here pushes the header
     down over the first row instead, since sticky does not reflow siblings. */
  top: 0;
  z-index: 20;
  background: #0d1527;
  text-align: left;
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.feed-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.feed-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.text-right { text-align: right; }
.text-center { text-align: center; }

.story-col-content {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.story-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #1e293b;
  flex-shrink: 0;
}

.story-meta-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.story-row-title {
  color: #f8fafc;
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-row-author {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Dateline: where the story was reported from, not where it was read */
.story-row-dateline {
  align-self: flex-start;
  margin-top: 3px;
  max-width: 100%;
  font-size: 0.68rem;
  font-weight: 600;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.22);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.num-cell {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 600;
  color: #f1f5f9;
}

.ctr-badge {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.ctr-high { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.ctr-med { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.ctr-low { background: rgba(255, 255, 255, 0.08); color: #94a3b8; }

.btn-inspect {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #60a5fa;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-inspect:hover {
  background: var(--accent-blue);
  color: white;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal-container {
  background: #0f172a;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  animation: modalScale 0.2s ease-out;
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-cat-tag {
  background: var(--accent-blue);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
}

.modal-id-tag {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: white;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.35;
}

.modal-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.modal-funnel-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.funnel-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.funnel-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.funnel-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
}

.funnel-val.highlight {
  color: var(--accent-cyan);
}

.funnel-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
}

.modal-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.modal-stat-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: #f1f5f9;
}

.modal-section-title {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  margin-top: 0.5rem;
}

.modal-comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 180px;
  overflow-y: auto;
}

.comment-bubble {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.comment-bubble-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
}

.comment-author {
  font-weight: 600;
  color: #cbd5e1;
}

.comment-sentiment-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 9999px;
  font-weight: 600;
}

.sentiment-positive { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.sentiment-neutral { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }

.comment-bubble-text {
  font-size: 0.78rem;
  color: #e2e8f0;
}

.empty-state {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .visualizer-grid, .secondary-grid {
    grid-template-columns: 1fr;
  }
}

/* Location Filter Box */
.location-filter-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  padding: 3px 8px;
  border-radius: var(--radius-md);
}

/* The dateline filter sits beside the audience-location one and answers the
   opposite question, so it carries the amber of the dateline chips rather than
   the cyan used for reader geography. */
.dateline-filter-box {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.28);
}

.dateline-filter-box .loc-label {
  color: #fbbf24;
}

.dateline-filter-box .loc-select {
  max-width: 190px;
}

.loc-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.loc-select {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #f8fafc;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  outline: none;
}

.loc-select:focus {
  border-color: var(--accent-cyan);
}

.location-active-banner {
  background: rgba(6, 182, 212, 0.08);
  border-left: 3px solid var(--accent-cyan);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.location-share-badge {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.15);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

/* Modal Geo Breakdown */
.modal-geo-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  max-height: 160px;
  overflow-y: auto;
}

.modal-geo-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.modal-geo-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
}

.modal-geo-city {
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.modal-geo-stats {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--accent-cyan);
}

.modal-geo-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  overflow: hidden;
}

.modal-geo-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #06b6d4, #3b82f6);
  border-radius: 9999px;
}

/* Live Telemetry Pulse Highlighting */
@keyframes livePulsePink {
  0% { transform: scale(1); color: #f43f5e; text-shadow: 0 0 10px rgba(244, 63, 94, 0.8); }
  50% { transform: scale(1.28); color: #fda4af; text-shadow: 0 0 18px rgba(244, 63, 94, 1); font-weight: 800; }
  100% { transform: scale(1); }
}

@keyframes livePulseCyan {
  0% { transform: scale(1); color: #06b6d4; text-shadow: 0 0 10px rgba(6, 182, 212, 0.8); }
  50% { transform: scale(1.28); color: #67e8f9; text-shadow: 0 0 18px rgba(6, 182, 212, 1); font-weight: 800; }
  100% { transform: scale(1); }
}

@keyframes livePulseBlue {
  0% { transform: scale(1); color: #3b82f6; text-shadow: 0 0 10px rgba(59, 130, 246, 0.8); }
  50% { transform: scale(1.28); color: #93c5fd; text-shadow: 0 0 18px rgba(59, 130, 246, 1); font-weight: 800; }
  100% { transform: scale(1); }
}

@keyframes livePulseEmerald {
  0% { transform: scale(1); color: #10b981; text-shadow: 0 0 10px rgba(16, 185, 129, 0.8); }
  50% { transform: scale(1.28); color: #6ee7b7; text-shadow: 0 0 18px rgba(16, 185, 129, 1); font-weight: 800; }
  100% { transform: scale(1); }
}

.pulse-pink {
  animation: livePulsePink 1.2s ease-out;
  display: inline-block;
}

.pulse-cyan {
  animation: livePulseCyan 1.2s ease-out;
  display: inline-block;
}

.pulse-blue {
  animation: livePulseBlue 1.2s ease-out;
  display: inline-block;
}

.pulse-emerald {
  animation: livePulseEmerald 1.2s ease-out;
  display: inline-block;
}


/* ==========================================================================
   Audience Recommendations panel
   ========================================================================== */

.reco-section { margin-bottom: 1.5rem; }

.reco-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.reco-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.reco-mode-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.mode-warm { background: rgba(52, 211, 153, 0.14); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.28); }
.mode-cold { background: rgba(56, 189, 248, 0.14); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.28); }

.reco-body {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1rem 1.25rem 1.25rem;
}

@media (max-width: 1100px) {
  .reco-body { grid-template-columns: minmax(0, 1fr); }
}

.reco-col { min-width: 0; }

.reco-col-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.15rem;
}
.reco-col-title-spaced { margin-top: 1.5rem; }

.reco-col-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.75;
  margin: 0 0 0.6rem;
}

.reco-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.6rem; }

.reco-empty {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.reco-item {
  display: grid;
  grid-template-columns: 26px 46px minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
  padding: 0.7rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.reco-item:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(59, 130, 246, 0.28); }

.reco-rank {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  padding-top: 2px;
}

.reco-thumb {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.reco-main { min-width: 0; }

.reco-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.reco-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reco-score {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: #60a5fa;
  flex-shrink: 0;
}

.reco-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--text-muted);
}
.reco-geo { color: #fbbf24; font-weight: 600; }

/* Signal bars: the four inputs to the score, so the ranking is auditable */
.reco-bars {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.reco-bar-item { display: flex; flex-direction: column; gap: 2px; }

.reco-bar-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.8;
}

.reco-bar-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.reco-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s ease; }
.bar-geo      { background: #fbbf24; }
.bar-local    { background: #34d399; }
.bar-interest { background: #a78bfa; }
.bar-fresh    { background: #38bdf8; }

.reco-reasons { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 0.5rem; }

.reco-reason {
  font-size: 0.63rem;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: rgba(148, 163, 184, 0.1);
  color: #cbd5e1;
}

/* Coverage gaps: a diverging bar around a centre line */
.reco-gaps { display: flex; flex-direction: column; gap: 5px; }

.gap-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 40px;
  gap: 0.5rem;
  align-items: center;
}

.gap-cat {
  font-size: 0.7rem;
  color: #cbd5e1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gap-track {
  position: relative;
  height: 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.gap-center {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.gap-fill { position: absolute; top: 2px; bottom: 2px; border-radius: 2px; }
.gap-under { background: rgba(52, 211, 153, 0.65); }
.gap-over  { background: rgba(244, 63, 94, 0.55); }

.gap-value {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: right;
}
.gap-under-text { color: #34d399; }
.gap-over-text  { color: #fb7185; }

.gap-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Dateline health: the ceiling on geographic matching */
.reco-health { display: flex; flex-direction: column; gap: 0.7rem; }

.health-headline {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}
.health-good { background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.25); }
.health-warn { background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.25); }
.health-bad  { background: rgba(244, 63, 94, 0.1);  border-color: rgba(244, 63, 94, 0.25); }

.health-pct {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  color: #f8fafc;
}

.health-label { font-size: 0.7rem; color: var(--text-muted); line-height: 1.35; }

.health-list-title {
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.health-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 0.5rem;
  padding: 3px 0;
  font-size: 0.68rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.health-item-loc {
  color: #fb7185;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-item-title {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
