/* ═══════════════════════════════════════════════════════════════════════
   FortiSec Dashboard — Agentic Design System
   Tokens: primary=#FF5701, surface=#FFFFFF, secondary=#F6F6F1, text=#111827
   Typography: Playfair Display (display), Inter (body), JetBrains Mono (data)
   Grid: 8pt baseline
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Color tokens (dark default) ── */
  --primary: #6D28D9;
  --primary-hover: #7C3AED;
  --primary-subtle: rgba(109, 40, 217, 0.12);
  --primary-glow: rgba(109, 40, 217, 0.18);

  --surface: #141418;
  --surface-secondary: #1A1A1F;
  --surface-elevated: #1E1E24;
  --surface-sunken: #111114;

  --text: #EDEDF0;
  --text-secondary: #9898A8;
  --text-muted: #5C5C6E;

  --border: #2A2A35;
  --border-hover: #3A3A48;
  --border-focus: var(--primary);

  --success: #34D399;
  --success-bg: rgba(52, 211, 153, 0.1);
  --warning: #FBBF24;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --danger: #F87171;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --warning-bg: rgba(217, 119, 6, 0.08);
  --danger: #DC2626;

  /* ── Spacing (8pt grid) ── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 40px;
  --sp-8: 48px;
  --sp-9: 64px;

  /* ── Typography ── */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 24px;
  --text-2xl: 32px;
  --text-3xl: 40px;

  /* ── Radii ── */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --radius-full: 9999px;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);

  /* ── Motion ── */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.15s;
}

/* ── Light mode tokens ── */
[data-theme="light"] {
  --primary: #8D2FFF;
  --primary-hover: #7C22F0;
  --primary-subtle: rgba(141, 47, 255, 0.08);
  --primary-glow: rgba(141, 47, 255, 0.12);

  --surface: #FFFFFF;
  --surface-secondary: #F6F6F1;
  --surface-elevated: #FFFFFF;
  --surface-sunken: #EEEEE8;

  --text: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;

  --border: #E5E5DC;
  --border-hover: #D1D1C7;

  --success: #16A34A;
  --success-bg: rgba(22, 163, 74, 0.08);
  --warning: #D97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --danger: #DC2626;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
}

/* ── Theme toggle button ── */
.theme-toggle {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color var(--duration) var(--ease),
              color var(--duration) var(--ease);
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Light mode: show moon, hide sun */
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Default & dark mode: show sun, hide moon */
.icon-sun { display: block; }
.icon-moon { display: none; }

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--surface-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Layout ── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--sp-5);
}

/* ══════════════════════════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════════════════════════ */

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) 0;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.logo-mark {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: white;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

/* Dark default: show white logo, hide black */
.logo-img-dark { display: block; }
.logo-img-light { display: none; }

[data-theme="light"] .logo-img-dark { display: none; }
[data-theme="light"] .logo-img-light { display: block; }

.logo-text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.logo-sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.meta-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════
   HERO / STATS
   ══════════════════════════════════════════════════════════════════════ */

.stats-section {
  padding: var(--sp-8) 0 var(--sp-6);
}

.hero-heading {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 900;
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -1px;
  margin-bottom: var(--sp-3);
}

.hero-accent {
  color: var(--primary);
}

.hero-sub {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--sp-6);
  max-width: 520px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}

.stat-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--sp-1);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

/* ══════════════════════════════════════════════════════════════════════
   CHARTS
   ══════════════════════════════════════════════════════════════════════ */

.charts-section {
  padding: var(--sp-4) 0;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: var(--sp-4);
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
}

.chart-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--sp-4);
  color: var(--text);
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow-y: auto;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  padding: 2px 0;
  border-radius: var(--radius-xs);
  transition: opacity var(--duration) var(--ease);
}

.bar-row:hover { opacity: 0.8; }

.bar-label {
  width: 180px;
  min-width: 180px;
  max-width: 180px;
  flex-shrink: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 24px;
  background: var(--surface-secondary);
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-xs);
  transition: width 0.5s var(--ease);
  min-width: 2px;
}

.bar-count {
  min-width: 48px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

/* ══════════════════════════════════════════════════════════════════════
   REPORTS TABLE
   ══════════════════════════════════════════════════════════════════════ */

.reports-section {
  padding: var(--sp-6) 0 var(--sp-8);
}

.reports-header {
  margin-bottom: var(--sp-4);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--sp-4);
}

.filters {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px var(--sp-4) 10px 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  outline: none;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.filter-select {
  padding: 10px var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  cursor: pointer;
  outline: none;
  min-width: 160px;
  transition: border-color var(--duration) var(--ease);
}

.filter-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.filter-select option {
  background: var(--surface);
  color: var(--text);
}

.reports-count {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
}

.reports-table th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.reports-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--surface-sunken);
  font-size: var(--text-sm);
  vertical-align: middle;
}

.reports-table tr:last-child td { border-bottom: none; }

.reports-table tbody tr {
  transition: background var(--duration) var(--ease);
}

.reports-table tbody tr:hover {
  background: var(--primary-subtle);
}

.th-rank { width: 48px; }
.th-upvotes { width: 96px; text-align: right; }
.th-bounty { width: 112px; text-align: right; }

.report-title {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  display: block;
  max-width: 480px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--duration) var(--ease);
}

.report-title:hover { color: var(--primary); }

.report-rank {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.report-program {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

.report-vuln {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: var(--primary-subtle);
  color: var(--primary);
  white-space: nowrap;
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-upvotes {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--warning);
  font-size: var(--text-sm);
}

.report-bounty {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--success);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.report-bounty.zero {
  color: var(--text-muted);
  font-weight: 400;
}

/* ══════════════════════════════════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════════════════════════════════ */

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: var(--sp-5);
  flex-wrap: wrap;
}

.page-btn {
  min-width: 44px;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: var(--font-body);
  font-weight: 500;
  transition: all var(--duration) var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.page-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════════════════ */

.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--sp-5) 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover { text-decoration: underline; }

.footer-brand {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════════════════ */

.loading {
  text-align: center;
  padding: var(--sp-8);
  color: var(--text-muted);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Focus visible ── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════════════
   POC BADGE
   ══════════════════════════════════════════════════════════════════════ */

.poc-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary);
  vertical-align: middle;
  margin-left: 6px;
}

.no-poc-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--surface-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-left: 6px;
}

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .hero-heading { font-size: var(--text-2xl); }

  .charts-grid { grid-template-columns: 1fr; }

  .bar-label { width: 120px; min-width: 120px; max-width: 120px; font-size: var(--text-xs); }

  .report-title { max-width: 240px; }

  .th-vuln, .report-vuln-cell { display: none; }

  .filters { flex-direction: column; }
  .search-wrapper { min-width: 100%; }
  .filter-select { min-width: 100%; }

  .header-inner { flex-direction: column; align-items: flex-start; }

  .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
  .th-program, .report-program-cell { display: none; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .stat-value { font-size: var(--text-xl); }
}
