/* FiveEyesAIR style.css */
/* Build version: 1.5 */
/* Build branch: stable-v1.4-to-v1.5 */

/* ═══════════════════════════════════════════════════════
   DESIGN SYSTEM — Intelligence Briefing Aesthetic
   ═══════════════════════════════════════════════════════ */
:root {
  /* Light mode (default) */
  --bg-base: #f4f3f0;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f9f8f6;
  --bg-elevated: #ffffff;
  --bg-input: #f4f3f0;
  --text-primary: #1a1a1a;
  --text-secondary: #5a5a5a;
  --text-muted: #8a8a8a;
  --text-inverse: #ffffff;
  --border-default: #e0ddd8;
  --border-strong: #ccc8c0;
  --accent: #2c5282;
  --accent-light: #ebf1fa;
  --accent-text: #1e3a5f;
  --danger: #c53030;
  --danger-bg: #fff5f5;
  --warn: #b7791f;
  --warn-bg: #fefcf0;
  --good: #276749;
  --good-bg: #f0fff4;
  --pill-higher: #c53030;
  --pill-higher-bg: #fff5f5;
  --pill-moderate: #b7791f;
  --pill-moderate-bg: #fefcf0;
  --pill-lower: #2c5282;
  --pill-lower-bg: #ebf1fa;
  --pill-nil: #718096;
  --pill-nil-bg: #f7f7f7;
  --pill-unknown: #805ad5;
  --pill-unknown-bg: #f5f0ff;
  --chart-1: #2c5282;
  --chart-2: #c53030;
  --chart-3: #b7791f;
  --chart-4: #276749;
  --chart-5: #805ad5;
  --chart-6: #d69e2e;
  --chart-7: #e53e3e;
  --chart-8: #38a169;
  --chart-9: #667eea;
  --chart-10: #ed8936;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-display: Arial, Helvetica, sans-serif;
  --font-body: Arial, Helvetica, sans-serif;
  --header-h: 0px;
  --tabs-h: 0px;
}

[data-theme="dark"] {
  --bg-base: #0f1117;
  --bg-surface: #181a20;
  --bg-surface-alt: #1e2028;
  --bg-elevated: #22242c;
  --bg-input: #1e2028;
  --text-primary: #e8e6e3;
  --text-secondary: #a0a0a0;
  --text-muted: #6a6a6a;
  --text-inverse: #0f1117;
  --border-default: #2a2c34;
  --border-strong: #3a3c44;
  --accent: #6b9bdb;
  --accent-light: #1a2640;
  --accent-text: #93bbef;
  --danger: #fc8181;
  --danger-bg: #2d1515;
  --warn: #ecc94b;
  --warn-bg: #2d2515;
  --good: #68d391;
  --good-bg: #152d1f;
  --pill-higher: #fc8181;
  --pill-higher-bg: #2d1b1b;
  --pill-moderate: #ecc94b;
  --pill-moderate-bg: #2d2815;
  --pill-lower: #6b9bdb;
  --pill-lower-bg: #1a2640;
  --pill-nil: #a0aec0;
  --pill-nil-bg: #252830;
  --pill-unknown: #b794f4;
  --pill-unknown-bg: #211a33;
  --chart-1: #6b9bdb;
  --chart-2: #fc8181;
  --chart-3: #ecc94b;
  --chart-4: #68d391;
  --chart-5: #b794f4;
  --chart-6: #f6e05e;
  --chart-7: #feb2b2;
  --chart-8: #9ae6b4;
  --chart-9: #a3bffa;
  --chart-10: #fbd38d;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.4);
}

/* ═══ RESET & BASE ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
canvas { display: block; }


/* ═══ LAYOUT ═══ */
.site-wrap {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

/* ═══ HEADER ═══ */
.site-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.header-titles h1 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.header-titles .subtitle {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 2px;
}
.header-titles .date-range {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 6px;
}
.header-cite {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 12px;
  line-height: 1.5;
}
.header-cite a { color: var(--accent); text-decoration: none; }
.header-cite a:hover { text-decoration: underline; }
.header-cite em { font-style: italic; }
.header-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.theme-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-body);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--accent-light); border-color: var(--accent); }

/* ═══ NAVIGATION TABS ═══ */
.nav-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 16px 0 12px;
  padding: 8px 0;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-base);
}
.tab-btn {
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  transition: all .15s;
  white-space: nowrap;
}
.tab-btn:hover { background: var(--accent-light); color: var(--accent-text); border-color: var(--accent); }
.tab-btn.active {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
  font-weight: 600;
}
.tab-btn.priority-tab {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-surface));
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border-default));
  color: var(--accent-text);
  font-weight: 700;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}
.tab-btn.priority-tab:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-surface));
  border-color: var(--accent);
}
.tab-btn.priority-tab.active {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

/* ═══ TAB PANELS ═══ */
.tab-panel {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  animation: fadeIn .2s ease-out;
}
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.panel-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* ═══ FILTERS / CONTROLS ═══ */
.controls-bar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.control-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.control-group.search-wide {
  grid-column: span 2;
}
.control-group label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.control-group select,
.control-group input[type="text"] {
  width: 100%;
  border: 1px solid var(--border-default);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 0.8rem;
  font-family: var(--font-body);
  transition: border-color .15s;
  appearance: auto;
}
.control-group select:focus,
.control-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.actions-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}
.action-btn {
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--font-body);
  transition: all .15s;
}
.action-btn:hover { background: var(--accent-light); color: var(--accent-text); border-color: var(--accent); }

/* ═══ SUMMARY CARDS ═══ */
.summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.stat-card .stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ═══ MINI YEAR CHART ═══ */
.year-chart-wrap {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.year-chart-wrap .chart-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.year-chart-wrap canvas { width: 100% !important; height: 180px !important; }

/* ═══ TABLES ═══ */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  table-layout: fixed;
}
thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 8px;
  text-align: left;
  border-bottom: 2px solid var(--border-strong);
  z-index: 2;
  white-space: nowrap;
}
td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-default);
  vertical-align: top;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--accent-light); }
tbody tr:last-child td { border-bottom: 0; }

/* Column widths - attacks/plots (19 cols) */
/* No, Date, Country, City, T-Loc, T-Grp, H-Vec, Offender, Ideology, ImmStat, Refugee?, Religion, Convert?, Notes, AIR, K, I, S1, S2 */
th:nth-child(1), td:nth-child(1) { width: 2.5%; }
th:nth-child(2), td:nth-child(2) { width: 5.5%; }
th:nth-child(3), td:nth-child(3) { width: 5%; }
th:nth-child(4), td:nth-child(4) { width: 5.5%; }
th:nth-child(5), td:nth-child(5) { width: 5%; }
th:nth-child(6), td:nth-child(6) { width: 5.5%; }
th:nth-child(7), td:nth-child(7) { width: 5%; }
th:nth-child(8), td:nth-child(8) { width: 8%; }
th:nth-child(9), td:nth-child(9) { width: 7%; }
th:nth-child(10), td:nth-child(10) { width: 5.5%; }
th:nth-child(11), td:nth-child(11) { width: 4%; }
th:nth-child(12), td:nth-child(12) { width: 4.5%; }
th:nth-child(13), td:nth-child(13) { width: 3%; }
th:nth-child(14), td:nth-child(14) { width: 19%; }
th:nth-child(15), td:nth-child(15) { width: 4%; }
th:nth-child(16), td:nth-child(16) { width: 2.5%; }
th:nth-child(17), td:nth-child(17) { width: 2.5%; }
th:nth-child(18), td:nth-child(18) { width: 3%; }
th:nth-child(19), td:nth-child(19) { width: 3%; }

/* All Cases table (20 cols) */
/* Type, No, Date, Country, City, T-Loc, T-Grp, H-Vec, Offender, Ideology, ImmStat, Refugee?, Religion, Convert?, Notes, AIR, K, I, S1, S2 */
table.tbl-allcases th:nth-child(1), table.tbl-allcases td:nth-child(1) { width: 3.5%; }
table.tbl-allcases th:nth-child(2), table.tbl-allcases td:nth-child(2) { width: 2.5%; }
table.tbl-allcases th:nth-child(3), table.tbl-allcases td:nth-child(3) { width: 5%; }
table.tbl-allcases th:nth-child(4), table.tbl-allcases td:nth-child(4) { width: 4.5%; }
table.tbl-allcases th:nth-child(5), table.tbl-allcases td:nth-child(5) { width: 5%; }
table.tbl-allcases th:nth-child(6), table.tbl-allcases td:nth-child(6) { width: 5%; }
table.tbl-allcases th:nth-child(7), table.tbl-allcases td:nth-child(7) { width: 5%; }
table.tbl-allcases th:nth-child(8), table.tbl-allcases td:nth-child(8) { width: 5%; }
table.tbl-allcases th:nth-child(9), table.tbl-allcases td:nth-child(9) { width: 7%; }
table.tbl-allcases th:nth-child(10), table.tbl-allcases td:nth-child(10) { width: 6.5%; }
table.tbl-allcases th:nth-child(11), table.tbl-allcases td:nth-child(11) { width: 5%; }
table.tbl-allcases th:nth-child(12), table.tbl-allcases td:nth-child(12) { width: 4%; }
table.tbl-allcases th:nth-child(13), table.tbl-allcases td:nth-child(13) { width: 4.5%; }
table.tbl-allcases th:nth-child(14), table.tbl-allcases td:nth-child(14) { width: 3%; }
table.tbl-allcases th:nth-child(15), table.tbl-allcases td:nth-child(15) { width: 17%; }
table.tbl-allcases th:nth-child(16), table.tbl-allcases td:nth-child(16) { width: 4%; }
table.tbl-allcases th:nth-child(17), table.tbl-allcases td:nth-child(17) { width: 2.5%; }
table.tbl-allcases th:nth-child(18), table.tbl-allcases td:nth-child(18) { width: 2.5%; }
table.tbl-allcases th:nth-child(19), table.tbl-allcases td:nth-child(19) { width: 2.5%; }
table.tbl-allcases th:nth-child(20), table.tbl-allcases td:nth-child(20) { width: 2.5%; }

/* CIVM table (13 cols): No, Date, Country, City, T-Loc, T-Grp, H-Vec, Offender, Ideology, Notes, AIR, S1, S2 */
table.tbl-civm th:nth-child(8), table.tbl-civm td:nth-child(8) { width: 10%; }
table.tbl-civm th:nth-child(9), table.tbl-civm td:nth-child(9) { width: 9%; }
table.tbl-civm th:nth-child(10), table.tbl-civm td:nth-child(10) { width: 25%; }
table.tbl-civm th:nth-child(11), table.tbl-civm td:nth-child(11) { width: 4%; }


/* ═══ PILLS ═══ */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.pill-higher { color: var(--pill-higher); background: var(--pill-higher-bg); border: 1px solid var(--pill-higher); }
.pill-moderate { color: var(--pill-moderate); background: var(--pill-moderate-bg); border: 1px solid var(--pill-moderate); }
.pill-lower { color: var(--pill-lower); background: var(--pill-lower-bg); border: 1px solid var(--pill-lower); }
.pill-nil { color: var(--pill-nil); background: var(--pill-nil-bg); border: 1px solid var(--pill-nil); }
.pill-unknown { color: var(--pill-unknown); background: var(--pill-unknown-bg); border: 1px solid var(--pill-unknown); }

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

/* ═══ OVERVIEW ═══ */
.overview-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.overview-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.chart-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 16px;
}
.chart-card .chart-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.chart-card canvas { width: 100% !important; height: 300px !important; }
.chart-card.mini canvas { height: 100px !important; }
.filtered-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 14px;
}

/* ═══ OVERVIEW NOTE ═══ */
.overview-note {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ═══ CONTENT PANELS (Methodology, Glossary, References) ═══ */
.content-panel {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 24px;
  line-height: 1.65;
}
.content-panel h2 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; margin-bottom: 14px; }
.content-panel h3 { font-family: var(--font-display); font-size: 1rem; font-weight: 600; color: var(--accent); margin: 20px 0 8px; }
.content-panel p { margin-bottom: 12px; font-size: 0.88rem; }

/* Glossary table */
.glossary-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; table-layout: auto; }
.glossary-table th, .glossary-table td { border-bottom: 1px solid var(--border-default); padding: 10px 10px; text-align: left; vertical-align: top; }
.glossary-table th { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); background: var(--bg-elevated); }
.glossary-table td:first-child { white-space: nowrap; width: 1%; padding-right: 20px; }

/* References */
.refs-search {
  width: 100%;
  border: 1px solid var(--border-default);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 0.85rem;
  font-family: var(--font-body);
}
.refs-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.refs-list { display: grid; gap: 8px; }
.ref-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.84rem;
  line-height: 1.5;
}

/* ═══ FOOTER ═══ */
.footer-row{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}
.admin-link-footer{color:var(--text-muted);font-size:inherit;text-decoration:none}
.admin-link-footer:hover{color:var(--text-secondary);text-decoration:none}
.panel-footer {
  margin-top: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding-top: 12px;
  border-top: 1px solid var(--border-default);
}

/* ═══ COLLAPSIBLE SECTIONS ═══ */
.collapse-section { margin-bottom: 12px; }
.collapse-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  width: 100%;
  text-align: left;
  transition: all .15s;
}
.collapse-toggle:hover { background: var(--accent-light); color: var(--accent-text); }
.collapse-toggle .arrow { transition: transform .2s; font-size: 0.65rem; }
  .toggle-state { display:none !important; }
  .admin-fab{position:fixed;left:12px;bottom:10px;z-index:80;font-size:0.75rem;color:var(--text-muted);text-decoration:none;background:var(--bg-surface);border:1px solid var(--border-default);padding:6px 10px;border-radius:999px;box-shadow:var(--shadow-sm)}
  .admin-fab:hover{color:var(--accent-text);background:var(--accent-light);text-decoration:none}

.context-table-wrap{overflow-x:auto}
.context-chart-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin-top:12px}
.context-chart-card{background:var(--bg-surface-alt);border:1px solid var(--border-default);border-radius:var(--radius-md);padding:14px}
.context-chart-card canvas{width:100%!important;height:240px!important}
.context-table{width:100%;border-collapse:collapse;table-layout:auto;font-size:.82rem}
.context-table.compact th,.context-table.compact td{font-size:0.76rem;padding:8px 9px;white-space:nowrap}
.context-table th,.context-table td{padding:8px 10px;border-bottom:1px solid var(--border-default);text-align:left;vertical-align:top;white-space:nowrap}
.context-table th:last-child,.context-table td:last-child{white-space:normal}
@media (max-width:900px){.context-chart-grid{grid-template-columns:1fr}}

.collapse-toggle.open .arrow { transform: rotate(90deg); }
.collapse-body { overflow: hidden; }
.collapse-body.hidden { display: none; }


/* ═══ ENHANCED ANALYTICS / UX ═══ */
.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-light);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border-default));
  color: var(--accent-text);
  font-size: 0.74rem;
  font-weight: 600;
}
.filter-chip.empty {
  background: var(--bg-surface-alt);
  border-color: var(--border-default);
  color: var(--text-muted);
}
.summary-text,
.compare-note {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
  margin: 0 0 12px;
}
.summary-grid-6 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.overview-tools,
.compare-grid {
  display: grid;
  gap: 14px;
  margin: 14px 0 16px;
}
.overview-tools { grid-template-columns: 1.1fr .9fr; }
.executive-brief,
.compare-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 16px;
}
.executive-brief h3,
.compare-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.executive-brief ul {
  margin-left: 18px;
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.55;
}
.executive-brief li { margin-bottom: 6px; }
.compare-grid { grid-template-columns: repeat(2, 1fr); }
.compare-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.compare-metric {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.compare-metric .k {
  display:block;
  font-size:0.68rem;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.05em;
  color:var(--text-muted);
  margin-bottom:4px;
}
.compare-metric .v {
  font-size:0.96rem;
  font-weight:700;
  color:var(--text-primary);
}
.muted-inline {
  color: var(--text-muted);
  font-size: 0.76rem;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1200px) {
  .overview-stats { grid-template-columns: repeat(3, 1fr); }
  .summary-grid-6 { grid-template-columns: repeat(3, 1fr); }
  .overview-tools, .compare-grid { grid-template-columns: 1fr; }
  .overview-chart-grid { grid-template-columns: 1fr; }
  .filtered-chart-grid { grid-template-columns: 1fr; }
  .controls-bar { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@media (max-width: 900px) {
  .site-wrap { padding: 10px 12px 30px; }
  .summary-grid-6 { grid-template-columns: repeat(2, 1fr); }
  .site-header { padding: 18px 20px; }
  .header-titles h1 { font-size: 1.35rem; }
  .header-titles .subtitle { font-size: 1rem; }
  .header-top { flex-direction: column; }
  .overview-stats { grid-template-columns: repeat(2, 1fr); }
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .controls-bar { grid-template-columns: repeat(2, 1fr); }
  .control-group.search-wide { grid-column: 1 / -1; }
  .nav-tabs { position: static; }
  .tab-panel { padding: 16px; }
  .chart-card canvas { height: 240px !important; }
}
@media (max-width: 640px) {
  .site-wrap { padding: 6px; }
  .summary-grid-6, .compare-metrics { grid-template-columns: 1fr 1fr; }
  .filter-chip-row { gap: 6px; }
  .site-header { padding: 14px 16px; border-radius: var(--radius-md); }
  .header-titles h1 { font-size: 1.1rem; }
  .header-titles .subtitle { font-size: 0.88rem; }
  .header-cite { font-size: 0.72rem; }
  .header-meta { font-size: 0.7rem; }

  /* Horizontal scrolling tabs instead of wrapping */
  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 8px 0;
    gap: 6px;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    font-size: 0.73rem;
    padding: 8px 14px;
    flex-shrink: 0;
    min-height: 38px;
  }

  .tab-panel { padding: 10px; border-radius: var(--radius-md); }
  .panel-title { font-size: 1.15rem; }

  /* Stats */
  .overview-stats { grid-template-columns: 1fr 1fr; gap: 6px; }
  .summary-row { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-card { padding: 10px 12px; }
  .stat-card .stat-value { font-size: 1.3rem; }

  /* Filters - larger touch targets */
  .controls-bar { grid-template-columns: 1fr; gap: 6px; }
  .control-group.search-wide { grid-column: 1; }
  .control-group select,
  .control-group input[type="text"] {
    padding: 10px 10px;
    font-size: 0.88rem;
    min-height: 42px;
    border-radius: var(--radius-md);
  }
  .control-group label { font-size: 0.7rem; margin-bottom: 3px; }

  /* Larger touch targets for buttons */
  .action-btn {
    padding: 10px 16px;
    font-size: 0.82rem;
    min-height: 42px;
  }
  .collapse-toggle {
    padding: 12px 14px;
    font-size: 0.85rem;
    min-height: 44px;
  }

  /* Charts */
  .overview-chart-grid { gap: 10px; }
  .filtered-chart-grid { grid-template-columns: 1fr; gap: 10px; }

  .chart-card { padding: 12px; }
  .chart-card canvas { height: 200px !important; }
  .year-chart-wrap canvas { height: 140px !important; }

  /* Mobile card view for tables */
  .table-container { border: 0; overflow: visible; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  table { font-size: 0.84rem; table-layout: auto; }
  tbody tr {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    background: var(--bg-surface-alt);
    padding: 4px 0;
  }
  td {
    display: grid;
    grid-template-columns: 35% 1fr;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-default);
    line-height: 1.45;
  }
  td:last-child { border-bottom: 0; }
  td::before {
    content: attr(data-label);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding-top: 2px;
  }

  /* Content panels (glossary, methodology, about) */
  .content-panel { padding: 16px; font-size: 0.86rem; }
  .content-panel h2 { font-size: 1.1rem; }
  .content-panel h3 { font-size: 0.95rem; }
  .content-panel p { font-size: 0.84rem; }

  /* Glossary table mobile card view */
  .glossary-table, .glossary-table thead, .glossary-table tbody,
  .glossary-table th, .glossary-table td, .glossary-table tr { display: block; }
  .glossary-table thead { display: none; }
  .glossary-table tr {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    background: var(--bg-elevated);
    padding: 0;
  }
  .glossary-table td:first-child {
    white-space: normal;
    width: auto;
    padding: 10px 12px 4px;
    border-bottom: 0;
    font-size: 0.88rem;
  }
  .glossary-table td:last-child {
    padding: 4px 12px 12px;
    font-size: 0.82rem;
  }

  /* References */
  .refs-search { font-size: 0.88rem; padding: 10px 12px; min-height: 42px; }
  .ref-item { padding: 10px 12px; font-size: 0.8rem; }

  /* AIR diagram smaller on mobile */
  .content-panel div[style*="max-width:380px"] { max-width: 280px !important; }

  /* Research notice banner */
  .site-header div[style*="warn-bg"] { font-size: 0.74rem; padding: 6px 10px; }
}

/* ═══ PRINT ═══ */
@media print {
  body { background: white; color: black; }
  .nav-tabs, .theme-toggle, .actions-bar, .collapse-toggle { display: none; }
  .tab-panel { display: block !important; break-inside: avoid; border: 1px solid #ccc; margin-bottom: 20px; box-shadow: none; }
  .chart-card { break-inside: avoid; }
}

/* Current layout safety */
.overview-chart-grid { align-items: stretch; }
@media (max-width: 767px) {
  .overview-chart-grid { grid-template-columns: 1fr !important; }
  .overview-chart-grid > .chart-card { grid-column: span 1 !important; }
}
@media (min-width: 768px) {
  .overview-chart-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}


/* Current chart stability tweaks */
.chart-card canvas { width: 100% !important; min-height: 280px; }
.overview-chart-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:16px; }
@media (max-width: 900px) { .overview-chart-grid { grid-template-columns: 1fr; } .chart-card[style*="grid-column: span 2"] { grid-column:auto !important; } }


/* Current release markers and tab architecture */
.site-version-marker {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent-light);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border-default));
  border-radius: 999px;
  padding: 4px 10px;
}
.site-notice {
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--warn-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.site-notice strong { color: var(--warn); }

.dataset-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.dataset-tab {
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all .15s;
}
.dataset-tab:hover {
  background: var(--accent-light);
  color: var(--accent-text);
  border-color: var(--accent);
}
.dataset-tab.active {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}
.context-note {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
  margin-top: 10px;
}

@media (max-width: 900px) {
  .site-version-marker { margin-top: 12px; }
}
@media (max-width: 640px) {
  .dataset-switcher { flex-direction: column; }
  .dataset-tab { width: 100%; min-height: 42px; }
}


/* AIR Overview stability and release markers */
.header-titles .date-range {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.site-version-marker {
  font-size: 0.74rem;
  padding: 5px 12px;
}
.chart-card {
  min-height: 360px;
}
.chart-card canvas,
.year-chart-wrap canvas {
  touch-action: manipulation;
}
@media (max-width: 900px) {
  .chart-card {
    min-height: 320px;
  }
}
