/* ── Reset & variables ─────────────────────────────────────────────────── */
:root {
  --bg:           #07090f;
  --surface:      #0d1120;
  --surface-alt:  #111828;
  --border:       #1c2238;
  --accent:       #00e5a0;
  --accent-dim:   rgba(0, 229, 160, 0.08);
  --accent-glow:  rgba(0, 229, 160, 0.25);
  --blue:         #4facfe;
  --red:          #ff4757;
  --yellow:       #ffd32a;
  --text:         #c8d3e8;
  --text-bright:  #f0f4ff;
  --text-muted:   #566080;
  --mono:         'JetBrains Mono', 'Fira Mono', monospace;
  --sans:         'Inter', system-ui, sans-serif;
  --radius:       10px;
  --max-w:        1280px;
}

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

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0, 229, 160, 0.07), transparent),
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ────────────────────────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  background: rgba(7, 9, 15, 0.92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-bright);
  letter-spacing: -0.5px;
}

.logo-accent { color: var(--accent); }

.tagline {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 229, 160, 0.12);
  border: 1px solid rgba(0, 229, 160, 0.3);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: 999px;
}

.pulse {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.8s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.last-updated {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.refresh-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 16px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  line-height: 1;
}

.refresh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.refresh-btn.spinning {
  animation: spin 0.7s linear infinite;
  pointer-events: none;
}

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

/* ── Main ──────────────────────────────────────────────────────────────── */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Stats grid ────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.stat-card:hover { border-color: rgba(0, 229, 160, 0.3); box-shadow: 0 0 24px var(--accent-glow); }
.stat-card:hover::before { opacity: 1; }

.stat-card.highlight { border-color: rgba(0, 229, 160, 0.25); background: linear-gradient(135deg, var(--surface), var(--accent-dim)); }
.stat-card.highlight::before { opacity: 0.6; }

.stat-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.stat-value {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 500;
  color: var(--text-bright);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card.highlight .stat-value { color: var(--accent); }

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Panels ────────────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-bright);
}

.panel-badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* ── Table ─────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--accent-dim); }

tbody td {
  padding: 11px 16px;
  color: var(--text);
  vertical-align: middle;
}

td.url-cell {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.ip-cell {
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

td.date-cell {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

td.status-cell {
  font-family: var(--mono);
  font-size: 11px;
}

.status-ok   { color: var(--accent); }
.status-warn { color: var(--yellow); }
.status-err  { color: var(--red); }

.scan-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--blue);
  white-space: nowrap;
}

td.empty { text-align: center; color: var(--text-muted); padding: 32px; font-size: 13px; }

/* ── Charts row ────────────────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 24px;
}

.chart-panel canvas {
  display: block;
  padding: 20px;
  max-height: 280px;
}

/* ── Brands / tags ─────────────────────────────────────────────────────── */
.brands-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px;
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  transition: border-color 0.2s;
}

.brand-tag:hover { border-color: rgba(0, 229, 160, 0.3); }

.brand-count {
  background: rgba(0, 229, 160, 0.15);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
}

/* ── Feed ──────────────────────────────────────────────────────────────── */
.feed-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feed-desc {
  color: var(--text-muted);
  font-size: 13px;
  max-width: 640px;
  line-height: 1.7;
}

.feed-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: #07090f;
}

.btn-primary:hover {
  background: #00ffb0;
  box-shadow: 0 0 20px var(--accent-glow);
  text-decoration: none;
}

.feed-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--blue);
}

.feed-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Footer ────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 8px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-left {
  font-size: 12px;
  color: var(--text-muted);
}

.footer-right {
  font-size: 12px;
  color: var(--text-muted);
}

.footer-right a {
  color: var(--text-muted);
  border-bottom: 1px dashed var(--text-muted);
}

.footer-right a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* ── Error banner ──────────────────────────────────────────────────────── */
.error-banner {
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.3);
  color: var(--red);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--mono);
  display: none;
}

.error-banner.visible { display: block; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  main { padding: 16px 12px 48px; gap: 16px; }

  .header-inner { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .logo { font-size: 18px; }
  .last-updated { display: none; }
  .refresh-btn { display: none; }

  /* Stats: 2 columns, smaller numbers */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 9px; }

  /* Table: hide less important columns, allow horizontal scroll */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  td.status-cell, th:nth-child(7),
  td:nth-child(7) { display: none; }
  td.url-cell { max-width: 180px; font-size: 10.5px; }

  /* Charts: reduce height */
  .chart-panel canvas { max-height: 200px; padding: 12px; }

  /* Brands: smaller tags */
  .brands-grid { padding: 12px 14px; gap: 6px; }
  .brand-tag { font-size: 11px; padding: 4px 10px; }

  /* Feed */
  .feed-body { padding: 14px; }
  .feed-actions { flex-direction: column; align-items: flex-start; gap: 10px; }
  .feed-url-box { font-size: 11px; word-break: break-all; }

  /* Footer: stack vertically */
  .footer-inner { flex-direction: column; gap: 6px; text-align: center; }
}
