/* DRONE MARKET DASHBOARD — Aerospace Data Theme */

/* --- Design Tokens --- */
:root,
[data-theme='light'] {
  --hero-bg: url('hero-bg-light.png');

  --hero-filter: none;
  /* Surfaces — light warm slate */
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-surface-2: #f8f9fb;
  --color-surface-offset: #eef0f3;
  --color-surface-dynamic: #e4e7ec;
  --color-divider: #dde0e5;
  --color-border: #c8ccd4;

  /* Text */
  --color-text: #1a1d24;
  --color-text-muted: #5c6370;
  --color-text-faint: #9aa1ac;
  --color-text-inverse: #ffffff;

  /* Accents — Aerospace Cyan */
  --color-primary: #0891b2;
  --color-primary-2: #06b6d4;
  --color-primary-hover: #0e7490;
  --color-primary-highlight: #cffafe;

  /* Status Colors */
  --color-success: #15803d;
  --color-success-bg: #dcfce7;
  --color-error: #b91c1c;
  --color-error-bg: #fee2e2;
  --color-warning: #b45309;
  --color-warning-bg: #fef3c7;

  /* Chart palette */
  --chart-1: #06b6d4;
  --chart-2: #f59e0b;
  --chart-3: #8b5cf6;
  --chart-4: #10b981;
  --chart-5: #ef4444;
  --chart-6: #64748b;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Fonts */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);

  /* Spacing */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme='dark'] {
  --hero-bg: url('hero-bg-dark.png');
  --hero-filter: none;
  --color-bg: #0d1117;
  --color-surface: #161b22;
  --color-surface-2: #1c232c;
  --color-surface-offset: #21262d;
  --color-surface-dynamic: #2d333b;
  --color-divider: #2d333b;
  --color-border: #3d444d;

  --color-text: #e6edf3;
  --color-text-muted: #8b949e;
  --color-text-faint: #6e7681;
  --color-text-inverse: #0d1117;

  --color-primary: #22d3ee;
  --color-primary-2: #67e8f9;
  --color-primary-hover: #67e8f9;
  --color-primary-highlight: #155e75;

  --color-success: #4ade80;
  --color-success-bg: rgba(34, 197, 94, 0.12);
  --color-error: #f87171;
  --color-error-bg: rgba(239, 68, 68, 0.12);
  --color-warning: #fbbf24;
  --color-warning-bg: rgba(245, 158, 11, 0.12);

  --chart-1: #22d3ee;
  --chart-2: #f59e0b;
  --chart-3: #a78bfa;
  --chart-4: #34d399;
  --chart-5: #f87171;
  --chart-6: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition), color var(--transition);
}

/* Hero background layer — fixed, behind all content, filter-only */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--hero-bg);
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;
  background-attachment: scroll;
  filter: var(--hero-filter, none);
  opacity: 0.35;
  transition: filter var(--transition), opacity var(--transition);
}

h1, h2, h3 { line-height: 1.2; text-wrap: balance; }
p, li { text-wrap: pretty; max-width: 80ch; }
ul { list-style: none; }

button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

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

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* --- Topbar --- */
.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: static; /* scrolls away with the page — only the navbar stays sticky */
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-icon {
  width: 36px;
  height: 36px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.brand h1 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 400;
}

.last-updated {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  white-space: nowrap;
}

[data-theme-toggle] {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  transition: all var(--transition);
}
[data-theme-toggle]:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* --- Refresh Button --- */
.refresh-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all var(--transition);
  white-space: nowrap;
}
.refresh-btn:hover:not(:disabled) {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.refresh-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.refresh-btn .spin {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --- Container --- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* --- KPI Cards --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  line-height: 1.1;
}

.kpi-delta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.kpi-restricted .kpi-value { color: var(--color-error); }
.kpi-compliant .kpi-value { color: var(--color-success); }
.kpi-leader .kpi-value { color: var(--color-primary); }

/* --- Viz Grid --- */
.viz-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--space-6);
}

@media (max-width: 900px) {
  .viz-grid { grid-template-columns: 1fr; }
}

.chart-card,
.filter-card,
.table-section,
.detail-section,
.sources-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.card-header h2 {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.q-num {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--color-primary) 50%, #0b0f14);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-num svg {
  width: 18px;
  height: 18px;
  display: block;
}
.section-head h2 {
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-note {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 400;
}

.chart-wrap {
  position: relative;
  height: 320px;
  width: 100%;
}

.chart-disclaimer {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-4);
  line-height: 1.5;
}

/* --- Filters --- */
.filter-group {
  margin-bottom: var(--space-5);
}
.filter-group:last-child { margin-bottom: 0; }

.filter-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

.filter-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.chip {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all var(--transition);
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

/* --- Table --- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-divider);
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  backdrop-filter: blur(4px);
}

.data-table {
  width: 100%;
  font-size: var(--text-sm);
}

.data-table thead {
  background: var(--color-surface-offset);
}

.data-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  white-space: nowrap;
  border-bottom: 2px solid var(--color-border);
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}
.data-table th.sortable:hover { color: var(--color-primary); }
.data-table th.sortable::after {
  content: ' ↕';
  opacity: 0.3;
  font-size: 0.85em;
}
.data-table th.sortable.sort-asc::after { content: ' ↑'; opacity: 1; color: var(--color-primary); }
.data-table th.sortable.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--color-primary); }

.data-table .num-col { text-align: right; }

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
  vertical-align: top;
}

.data-table tbody tr {
  transition: background var(--transition);
}
.data-table tbody tr:hover {
  background: var(--color-surface-offset);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.company-cell {
  font-weight: 600;
  font-size: var(--text-sm);
}

.hq-cell {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.share-cell {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}

.retail-cell {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 280px;
  line-height: 1.4;
}

.segment-cell {
  font-size: var(--text-xs);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge-restricted {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.badge-compliant {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-neutral {
  background: var(--color-surface-dynamic);
  color: var(--color-text-muted);
}

/* --- Detail Cards --- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.detail-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.detail-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.detail-card h3 {
  font-size: var(--text-base);
  font-weight: 700;
}

.detail-card h3 a {
  font-size: var(--text-xs);
  font-weight: 400;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-value {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.5;
}

.detail-sources {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.detail-sources a {
  font-size: var(--text-xs);
  font-weight: 500;
}

/* --- Sources --- */
.sources-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sources-content a {
  font-size: var(--text-sm);
  display: block;
}

.methodology {
  margin-top: var(--space-6);
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  backdrop-filter: blur(4px);
}

.methodology h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.methodology ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.methodology li {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  padding-left: var(--space-4);
  position: relative;
}

.methodology li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
}

.disclaimer-text {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-style: italic;
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: var(--space-6);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  border-top: 1px solid var(--color-border);
}


/* --- Toast Notifications --- */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  max-width: 420px;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.4;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 250ms ease, transform 250ms ease;
}
.toast-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.toast-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}
.toast-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid var(--color-error);
}
.toast-info {
  background: rgba(var(--color-primary-rgb, 6, 182, 212), 0.12);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
@media (max-width: 600px) {
  .toast { left: var(--space-4); right: var(--space-4); max-width: none; bottom: var(--space-4); }
}


/* --- Region Selector --- */
.region-selector {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}
.region-chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.region-chip:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.region-chip.active {
  color: var(--color-bg);
  background: var(--color-primary);
  border-color: var(--color-primary);
}

/* --- Chart Meta (confidence + disclaimer) --- */
.chart-meta {
  margin-top: var(--space-2);
}
.confidence-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.confidence-badge.high {
  background: rgba(var(--color-success-rgb, 34, 197, 94), 0.15);
  color: var(--color-success);
}
.confidence-badge.medium {
  background: rgba(var(--color-warning-rgb, 245, 158, 11), 0.15);
  color: var(--color-warning);
}
.confidence-badge.low {
  background: rgba(var(--color-error-rgb, 239, 68, 68), 0.15);
  color: var(--color-error);
}


/* --- Communities & Producers Sections --- */
.communities-section,
.producers-section {
  margin-top: var(--space-6);
}
.communities-grid,
.producers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-3);
}
.community-card,
.producer-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  transition: border-color var(--transition);
}
.community-card:hover,
.producer-card:hover {
  border-color: var(--color-primary);
}
.community-card-header,
.producer-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.community-card h3,
.producer-card h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}
.community-type,
.producer-role {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  background: rgba(var(--color-primary-rgb, 6, 182, 212), 0.12);
  color: var(--color-primary);
}
.community-focus {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: var(--space-2) 0;
}
.focus-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.focus-anti-spy {
  background: rgba(var(--color-error-rgb, 239, 68, 68), 0.12);
  color: var(--color-error);
}
.focus-upgrade {
  background: rgba(var(--color-success-rgb, 34, 197, 94), 0.12);
  color: var(--color-success);
}
.focus-anti-obsolescence {
  background: rgba(var(--color-warning-rgb, 245, 158, 11), 0.12);
  color: var(--color-warning);
}
.community-desc,
.producer-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: var(--space-2) 0;
}
.community-risk {
  font-size: 11px;
  color: var(--color-warning);
  margin-top: var(--space-2);
  padding: var(--space-2);
  background: rgba(var(--color-warning-rgb, 245, 158, 11), 0.08);
  border-radius: var(--radius-sm);
  line-height: 1.4;
}
.producer-products {
  font-size: var(--text-xs);
  color: var(--color-text);
  margin: var(--space-1) 0;
}
.producer-sources {
  margin-top: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.producer-sources a {
  font-size: 11px;
}
.communities-disclaimer {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-4);
  padding: var(--space-3);
  background: rgba(var(--color-warning-rgb, 245, 158, 11), 0.06);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}


/* --- Navigation Bar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(8px);
}
.navbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  height: 44px;
}
.nav-menu {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: space-between;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: var(--space-3);
  flex-shrink: 0;
}
.topbar-actions .refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.topbar-actions .refresh-btn:hover:not(:disabled) { background: var(--color-primary); color: #fff; }
.topbar-actions [data-theme-toggle] {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-1);
}
.topbar-actions [data-theme-toggle]:hover { color: var(--color-primary); }
.nav-links {
  display: flex;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
  flex-shrink: 0;
}
.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-links a svg {
  flex-shrink: 0;
  display: block;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--color-primary);
  background: rgba(var(--color-primary-rgb, 6, 182, 212), 0.08);
}
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--color-text);
  border-radius: 1px;
  transition: all 250ms ease;
}
.hamburger.open span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
.hamburger.open span:nth-child(2) {
  opacity: 0;
}
.hamburger.open span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}
@media (max-width: 1200px) {
  .navbar.collapsed .hamburger,
  .hamburger { display: flex; }
  .nav-menu {
    position: fixed;
    top: 44px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-3);
    gap: var(--space-1);
    transform: translateY(-200%);
    transition: transform 300ms ease;
    z-index: 99;
    box-shadow: var(--shadow-md);
  }
  .nav-menu.open {
    transform: translateY(0);
  }
  .nav-links {
    position: static;
    flex-direction: column;
    gap: var(--space-1);
  }
  .nav-links a {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    width: 100%;
    border-radius: var(--radius-md);
  }
  
}

/* --- Responsive --- */

/* Section scroll offset for navbar */
section[id] {
  scroll-margin-top: 70px;
}
@media (max-width: 768px) {
  .topbar-inner { padding: var(--space-3) var(--space-4); }
  .container { padding: var(--space-4); gap: var(--space-4); }
  .brand h1 { font-size: var(--text-base); }
  .subtitle { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .data-table th, .data-table td { padding: var(--space-2) var(--space-3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Nav / subnav horizontal overflow guard --- */
.nav-links { flex-wrap: nowrap; flex-shrink: 0; }
.nav-menu { min-width: 0; }
.navbar-inner { height: auto; }
#refresh-btn { display: none; }
.nav-item.subnav-right > .subnav { left: auto !important; right: 0 !important; }
.nav-item.subnav-right > .subnav.subnav-nested { left: auto !important; right: 100% !important; }
html.nav-collapsed .hamburger { display: flex; }
html.nav-collapsed .nav-menu { position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 8px 12px; transform: translateY(-200%); transition: transform 300ms ease; z-index: 99; }
html.nav-collapsed .nav-menu.open { transform: translateY(0); }
html.nav-collapsed .nav-links { flex-direction: column; gap: 2px; }
html.nav-collapsed .nav-links a { padding: 10px 12px; }


/* --- Hero Background Transparency Overrides (20% transparent = 80% opaque) --- */
body {
  background-color: color-mix(in srgb, var(--color-bg) 85%, transparent);
}

.topbar,
.kpi-card {
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  backdrop-filter: blur(8px);
}

.navbar {
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  backdrop-filter: blur(24px);
}

.chart-card,
.filter-card,
.table-section,
.detail-section,
.sources-section {
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  backdrop-filter: blur(4px);
}

.community-card,
.producer-card {
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  backdrop-filter: blur(4px);
}

.detail-card {
  background: color-mix(in srgb, var(--color-surface-2) 80%, transparent);
  backdrop-filter: blur(4px);
}

.data-table thead {
  background: color-mix(in srgb, var(--color-surface-offset) 80%, transparent);
  backdrop-filter: blur(4px);
}

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--color-surface-offset) 70%, transparent);
  backdrop-filter: blur(4px);
}

.nav-menu {
  background: color-mix(in srgb, var(--color-surface) 85%, transparent);
  backdrop-filter: blur(32px);
}

.toast {
  backdrop-filter: blur(16px);
}

.footer {
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  backdrop-filter: blur(4px);
}

/* --- Subnav dropdown (subsection sub-items) --- */
.nav-item { position: relative; }
.subnav {
  position: absolute; top: 100%; left: 0; min-width: 240px; max-height: 70vh; overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 8px; box-shadow: var(--shadow-md);
  display: none; flex-direction: column; padding: 6px; z-index: 300;
}
.nav-item:hover .subnav,
.nav-item:focus-within .subnav,
.nav-item.subnav-open .subnav { display: flex; }
.subnav a {
  padding: 7px 12px; font-size: 0.76rem; border-radius: 6px;
  color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.subnav a:hover { background: var(--color-surface-offset); color: var(--color-primary); }
@media (max-width: 1200px) {
  .subnav { position: static; min-width: 0; max-height: none; box-shadow: none; border: none; border-left: 1px solid var(--color-divider); margin: 0 0 4px 14px; padding: 2px 0 2px 8px; display: none; }
  .nav-item.subnav-open .subnav { display: flex; }
}
