/* ============================================================================
   VIC Capital Investment Dashboard — Forged Earth design system
   Sitesmith Labs · DESIGN.md canonical values (Decisions Log 2026-04-08)
   ============================================================================ */

:root {
  /* ── Brand ── */
  --primary: #1B4332;           /* Deep Forest */
  --primary-light: #2D6A4F;
  --primary-dim: #143526;
  --accent: #D95B1A;            /* Ember Orange (canonical, NOT #EA580C) */
  --accent-hover: #B84D16;

  /* ── Surfaces ── */
  --surface: #FFFDF8;           /* Warm White */
  --surface-alt: #F7F5F0;       /* Stone */
  --surface-deep: #1B4332;
  --surface-elevated: #FFFFFF;

  /* ── Text ── */
  --text: #1C1917;
  --text-muted: #57534E;
  --text-dim: #78716C;
  --text-faint: #A8A29E;
  --text-inverse: #FFFDF8;

  /* ── Borders ── */
  --border: rgba(27, 67, 50, 0.10);
  --border-strong: rgba(27, 67, 50, 0.20);
  --border-accent: rgba(217, 91, 26, 0.25);

  /* ── Semantic ── */
  --info: #3B82F6;
  --positive: #10B981;
  --warn: #F59E0B;

  /* ── Sector palette (CB-safe, AA on warm white) ── */
  --sector-transport: #1B4332;
  --sector-health: #D95B1A;
  --sector-education: #3D5A80;
  --sector-justice: #7B2D26;
  --sector-culture: #5B7553;
  --sector-energy: #2E8B8B;
  --sector-environment: #A06CD5;
  --sector-water: #8C7355;

  /* ── Type ── */
  --font-display: 'Cabinet Grotesk', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* ── Spacing (4-base scale) ── */
  --s-1: 4px; --s-2: 6px; --s-3: 8px; --s-4: 12px; --s-5: 16px;
  --s-6: 20px; --s-7: 24px; --s-8: 32px; --s-9: 48px; --s-10: 64px; --s-11: 96px;

  /* ── Radius ── */
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px; --r-pill: 20px;

  /* ── Motion ── */
  --t-fast: 150ms;
  --t-base: 220ms;
  --t-slow: 300ms;
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(27, 67, 50, 0.06);
  --shadow-md: 0 4px 12px rgba(27, 67, 50, 0.08);
  --shadow-lg: 0 16px 48px rgba(27, 67, 50, 0.12);

  /* ── Layout ── */
  --topbar-h: 56px;
  --max-w: 1280px;
}

/* ============================================================================
   Reset & base
   ============================================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--text);
  background: var(--surface-alt);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: rgba(27, 67, 50, 0.25);
  text-underline-offset: 2px;
  transition: color var(--t-fast) var(--ease), text-decoration-color var(--t-fast) var(--ease);
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

img, svg { display: block; max-width: 100%; }

table { border-collapse: collapse; width: 100%; }

/* Tabular numerals for any element marked .num or inside money display */
.num, .stat-value, .money, .progress-text, .tei-cell {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ============================================================================
   A11y utilities
   ============================================================================ */

.sr-only, .vh {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -10000px;
  top: 8px;
  z-index: 1000;
  background: var(--primary);
  color: var(--text-inverse);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  text-decoration: none;
  font-weight: 500;
}
.skip-link:focus { left: 8px; outline: 2px solid var(--accent); outline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

button:focus-visible, [role="tab"]:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

/* ============================================================================
   Topbar
   ============================================================================ */

.topbar {
  height: var(--topbar-h);
  background: var(--primary);
  color: var(--text-inverse);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-8);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--text-inverse);
  text-decoration: none;
}
.brand:hover { color: var(--text-inverse); text-decoration: none; }
.brand img { filter: brightness(0) invert(1); opacity: 0.95; }
.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-year {
  color: var(--accent);
  margin-left: var(--s-1);
}

.topbar-source {
  font-size: 11px;
  color: rgba(255, 253, 248, 0.7);
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topbar-source:hover { color: var(--accent); text-decoration: none; }

/* ============================================================================
   Tab nav
   ============================================================================ */

.tab-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--s-8);
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
}
.tab-nav [role="tablist"] {
  display: flex;
  gap: 0;
  max-width: var(--max-w);
  margin: 0 auto;
}
.tab {
  padding: var(--s-5) var(--s-6);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  color: var(--primary);
  border-bottom-color: var(--accent);
}
.tab-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--r-pill);
}
.tab[aria-selected="true"] .tab-count {
  background: rgba(217, 91, 26, 0.12);
  color: var(--accent);
}

/* ============================================================================
   Main panels
   ============================================================================ */

main {
  flex: 1;
  background: var(--surface-alt);
}
.panel {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s-8) var(--s-8) var(--s-10);
}
@media (max-width: 768px) {
  .panel { padding: var(--s-5) var(--s-4) var(--s-8); }
}

/* ============================================================================
   Overview — lede, stats, scale anchor
   ============================================================================ */

.lede {
  max-width: 760px;
  margin: 0 0 var(--s-8);
}
.lede p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-muted);
}
.lede strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-5);
  list-style: none;
  margin: 0 0 var(--s-6);
}
@media (max-width: 968px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; gap: var(--s-3); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.stat-card-clickable {
  cursor: pointer;
}
.stat-card-clickable:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card-clickable:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: var(--s-3);
}
.stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.1;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.stat-suffix {
  font-size: 0.55em;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 2px;
}
.stat-anchor {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--s-3);
  line-height: 1.4;
}

.scale-anchor {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 var(--s-8);
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  border-left: 3px solid var(--accent);
  max-width: 720px;
}
.scale-anchor strong { color: var(--text); font-weight: 600; }
.dot-sep { margin: 0 var(--s-2); color: var(--text-faint); }

/* ============================================================================
   Overview search
   ============================================================================ */

.overview-search {
  display: flex;
  gap: var(--s-3);
  margin: 0 0 var(--s-8);
  max-width: 720px;
}
.overview-search label {
  flex: 1;
  display: block;
}
.overview-search input[type="search"] {
  width: 100%;
  padding: var(--s-4) var(--s-5);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast) var(--ease);
}
.overview-search input[type="search"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  padding: var(--s-4) var(--s-6);
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-light); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  padding: var(--s-3) var(--s-5);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-weight: 500;
  font-size: 13px;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-text {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  padding: var(--s-2) 0;
  text-decoration: underline;
  text-decoration-color: transparent;
}
.btn-text:hover { text-decoration-color: var(--accent); }

/* ============================================================================
   Chart section
   ============================================================================ */

.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-7);
  margin: 0 0 var(--s-8);
}
.chart-header { margin-bottom: var(--s-5); }
.chart-header h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  color: var(--primary);
  letter-spacing: -0.02em;
  margin-bottom: var(--s-2);
}
.chart-sub {
  font-size: 13px;
  color: var(--text-muted);
}
.chart-figure { margin: 0; }
.chart-canvas {
  width: 100%;
  height: 480px;
  background: var(--surface);
  border-radius: var(--r-md);
}
.chart-canvas-compact {
  height: 320px;
}
@media (max-width: 768px) {
  .chart-canvas { height: 360px; }
  .chart-canvas-compact { height: 280px; }
}

.chart-section-secondary {
  margin-top: 0;
}
figcaption {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* ============================================================================
   Insights
   ============================================================================ */

.section-h {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--primary);
  letter-spacing: -0.02em;
  margin: 0 0 var(--s-5);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-5);
  list-style: none;
  margin: 0 0 var(--s-8);
}
@media (max-width: 1200px) { .insight-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .insight-grid { grid-template-columns: 1fr; } }

.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.insight-clickable { cursor: pointer; }
.insight-clickable:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.insight-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.insight-tag-positive {
  color: var(--primary);
}
.insight-body {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  flex: 1;
}
.insight-body strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.insight-cta {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  margin-top: auto;
}

/* ============================================================================
   Methodology disclosure
   ============================================================================ */

.methodology {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
}
.methodology[open] { padding-bottom: var(--s-6); }
.methodology summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--primary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.methodology summary::before {
  content: '+';
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 18px;
  transition: transform var(--t-fast) var(--ease);
}
.methodology[open] summary::before { content: '−'; }
.methodology summary::-webkit-details-marker { display: none; }
.methodology-body { margin-top: var(--s-5); }
.methodology-body p, .methodology-body ul {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--s-4);
}
.methodology-body ul { padding-left: var(--s-5); }
.methodology-body li { margin-bottom: var(--s-2); }
.methodology-body strong { color: var(--text); font-weight: 600; }

.methodology-h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  letter-spacing: -0.01em;
  margin-top: var(--s-6);
  margin-bottom: var(--s-4);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
}

.glossary {
  margin-bottom: var(--s-4);
}
.glossary dt {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-top: var(--s-4);
  margin-bottom: var(--s-2);
}
.glossary dt:first-of-type { margin-top: 0; }
.glossary dt .glossary-long {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-left: var(--s-2);
}
.glossary dd {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--s-2);
  padding-left: 0;
}
.glossary dd strong { color: var(--text); }

/* abbr styling — dotted underline cue */
abbr[title] {
  text-decoration: underline dotted;
  text-decoration-color: rgba(27, 67, 50, 0.4);
  text-underline-offset: 2px;
  cursor: help;
  text-decoration-thickness: 1px;
}
.topbar abbr[title], .stat-card abbr[title] {
  text-decoration: underline dotted;
  text-decoration-color: rgba(255, 253, 248, 0.5);
}
.stat-card abbr[title] {
  text-decoration-color: rgba(217, 91, 26, 0.5);
}

/* ============================================================================
   Filter bar (Explore)
   ============================================================================ */

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  margin: 0 0 var(--s-5);
  padding: var(--s-5) var(--s-6);
  position: sticky;
  top: calc(var(--topbar-h) + 53px);  /* tab nav is 53px tall */
  z-index: 30;
  box-shadow: var(--shadow-sm);
}
.filter-bar-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
@media (max-width: 968px) {
  .filter-bar-inner { grid-template-columns: repeat(2, 1fr); }
  .filter-search { grid-column: 1 / -1; }
}
.filter-control { display: flex; flex-direction: column; gap: var(--s-2); }
.filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.filter-control select, .filter-control input[type="search"] {
  padding: var(--s-3) var(--s-4);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.filter-control select {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" fill="none"><path d="M1 1.5L6 6.5L11 1.5" stroke="%2378716C" stroke-width="1.5" stroke-linecap="round"/></svg>');
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  padding-right: var(--s-7);
}
.filter-control select:focus, .filter-control input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.filter-bar-meta {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
}
.result-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.active-chips {
  display: flex;
  gap: var(--s-2);
  flex: 1;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--text);
}
.chip-remove {
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1;
  padding: 0 0 0 var(--s-1);
  margin-left: var(--s-1);
}
.chip-remove:hover { color: var(--accent); }

/* ============================================================================
   Table (Explore)
   ============================================================================ */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.project-table {
  width: 100%;
  font-size: 13px;
}
.project-table thead {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-strong);
}
.project-table th {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
}
.project-table th.num { text-align: right; }
.project-table th.progress-col { min-width: 140px; }

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}
.sort-btn::after {
  content: '↕';
  opacity: 0.3;
  font-size: 10px;
  margin-left: var(--s-1);
}
.sort-btn[data-sort-active="asc"]::after { content: '↑'; opacity: 1; color: var(--accent); }
.sort-btn[data-sort-active="desc"]::after { content: '↓'; opacity: 1; color: var(--accent); }
.sort-btn:hover { color: var(--text); }

.project-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.project-table tbody tr:hover {
  background: var(--surface-alt);
}
.project-table tbody tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.project-table td {
  padding: var(--s-4);
  vertical-align: top;
}
.project-table td.num { text-align: right; }
.project-table .name-cell {
  font-weight: 500;
  color: var(--text);
  max-width: 280px;
}
.project-table .name-cell .name-location {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 2px;
}
.project-table .tei-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
}
.project-table .tei-tbc {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-dim);
  font-weight: 400;
  font-size: 12px;
}

/* Sector badges */
.sector-badge, .status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--s-3);
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.sector-badge {
  background: var(--surface-alt);
  color: var(--text);
  position: relative;
  padding-left: var(--s-5);
}
.sector-badge::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--sector-color, var(--text-dim));
}

.status-badge {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.status-existing { background: rgba(59, 130, 246, 0.10); color: #2A56C0; border-color: rgba(59, 130, 246, 0.25); }
.status-new      { background: rgba(217, 91, 26, 0.10); color: var(--accent-hover); border-color: var(--border-accent); }
.status-completed{ background: rgba(16, 185, 129, 0.10); color: #047857; border-color: rgba(16, 185, 129, 0.25); }

/* Spent / remaining progress bar */
.progress-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: 11px;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}
.progress-text {
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 11px;
}

/* Notes column with tag chips */
.notes-cell {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.5;
}
.notes-cell-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notes-empty {
  color: var(--text-faint);
  font-style: italic;
  font-size: 11px;
}
.notes-highlight {
  background: rgba(217, 91, 26, 0.15);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}

.tag-list {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-top: var(--s-2);
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 2px var(--s-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface-alt);
  color: var(--primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  cursor: help;
  position: relative;
}
.tag-chip-eta_revised { background: rgba(245, 158, 11, 0.10); color: #B45309; border-color: rgba(245, 158, 11, 0.30); }
.tag-chip-reclassified { background: rgba(59, 130, 246, 0.10); color: #1E40AF; border-color: rgba(59, 130, 246, 0.25); }
.tag-chip-cic { background: rgba(120, 113, 108, 0.12); color: var(--text); border-color: var(--border-strong); }

.tag-chip:hover {
  background: var(--surface);
  z-index: 1;
}
.tag-chip-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--primary);
  color: var(--text-inverse);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  max-width: 320px;
  width: max-content;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease);
  z-index: 10;
  box-shadow: var(--shadow-md);
}
.tag-chip:hover .tag-chip-tooltip,
.tag-chip:focus-within .tag-chip-tooltip {
  opacity: 1;
}

.empty-state {
  padding: var(--s-10) var(--s-5);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state .btn-text { margin-left: var(--s-2); }

/* ============================================================================
   View toggle (Explore — Table / Cards)
   ============================================================================ */

.view-toggle {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.view-btn {
  padding: var(--s-2) var(--s-4);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.view-btn + .view-btn { border-left: 1px solid var(--border); }
.view-btn:hover { color: var(--text); background: var(--surface-alt); }
.view-btn[aria-checked="true"] {
  background: var(--primary);
  color: var(--text-inverse);
}
.view-btn[aria-checked="true"]:hover {
  background: var(--primary-light);
  color: var(--text-inverse);
}

/* ============================================================================
   Card view (<768px or manual toggle)
   ============================================================================ */

/* Card styling — applies whenever cards are visible (auto on mobile OR manual toggle on any width) */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}
.project-card:hover { border-color: var(--accent); }
.project-card .pc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.project-card .pc-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  line-height: 1.35;
}
.project-card .pc-tei {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  white-space: nowrap;
}
.project-card .pc-meta {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}
.project-card .pc-entity {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: var(--s-2);
}
.project-card .pc-progress { margin: var(--s-3) 0; }
.project-card .pc-notes {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.project-card .tag-list { margin-top: var(--s-3); }

/* On desktop with manual cards toggle, use a 2-column grid to make better use of width */
@media (min-width: 769px) {
  .table-wrap[data-view="cards"] .card-list {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: var(--s-4);
    padding: var(--s-5);
  }
  .table-wrap[data-view="cards"] .project-card { margin-bottom: 0; }
}

/* Default: auto-swap via matchMedia */
.card-list { display: none; }
@media (max-width: 768px) {
  .project-table { display: none; }
  .card-list { display: block; padding: var(--s-4); }
}

/* Manual override (data-view set by app.js when state.viewMode !== 'auto') */
.table-wrap[data-view="table"] .project-table { display: table; }
.table-wrap[data-view="table"] .card-list { display: none; }
.table-wrap[data-view="cards"] .project-table { display: none; }
.table-wrap[data-view="cards"] .card-list { display: block; padding: var(--s-4); }

/* ============================================================================
   Drawer
   ============================================================================ */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
.drawer[aria-hidden="false"] { pointer-events: auto; }
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0);
  transition: background var(--t-slow) var(--ease);
  cursor: pointer;
}
.drawer[aria-hidden="false"] .drawer-backdrop {
  background: rgba(28, 25, 23, 0.5);
}
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-slow) var(--ease);
  overflow: hidden;
}
.drawer[aria-hidden="false"] .drawer-panel { transform: translateX(0); }
.drawer-header {
  padding: var(--s-7);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.drawer-close {
  position: absolute;
  top: var(--s-5);
  right: var(--s-5);
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  color: var(--text-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.drawer-close:hover { background: var(--surface-alt); color: var(--text); }
.drawer-sector {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: var(--s-3);
}
.drawer-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.25;
  color: var(--primary);
  letter-spacing: -0.02em;
  margin-bottom: var(--s-3);
  padding-right: 40px;
}
.drawer-entity {
  font-size: 13px;
  color: var(--text-muted);
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-7);
  font-size: 13px;
}
.drawer-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--s-4);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--border);
}
.drawer-row:last-of-type { border-bottom: none; }
.drawer-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.drawer-value {
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.drawer-value.money {
  font-family: var(--font-mono);
  font-weight: 600;
}
.drawer-notes-section {
  margin-top: var(--s-7);
  padding-top: var(--s-6);
  border-top: 1px solid var(--border-strong);
}
.drawer-notes-section h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--s-4);
}
.drawer-note-block {
  padding: var(--s-5);
  background: var(--surface-alt);
  border-radius: var(--r-md);
  margin-bottom: var(--s-3);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.drawer-note-disclosure {
  border-left: 3px solid var(--accent);
}
.drawer-note-disclosure-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: var(--s-2);
}
.drawer-progress {
  margin-top: var(--s-4);
}
.drawer-progress .progress-track { height: 10px; }
.drawer-progress-text {
  display: flex;
  justify-content: space-between;
  margin-top: var(--s-2);
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Project history table in drawer */
.history-table {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  font-size: 12px;
}
.history-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr 1.1fr;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.history-row:last-child { border-bottom: none; }
.history-row-header {
  background: var(--surface-alt);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.history-row-current {
  background: rgba(217, 91, 26, 0.04);
  font-weight: 500;
}
.history-budget {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.history-budget small {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-left: var(--s-1);
}
.history-tei {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  text-align: right;
}
.history-completion {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================================
   Footer
   ============================================================================ */

.site-footer {
  background: var(--surface-deep);
  color: rgba(255, 253, 248, 0.7);
  padding: var(--s-8) var(--s-8);
  margin-top: var(--s-10);
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  font-size: 12px;
  line-height: 1.6;
}
.site-footer a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(217, 91, 26, 0.4);
}
.site-footer a:hover { color: var(--text-inverse); }
.footer-meta {
  color: rgba(255, 253, 248, 0.5);
  font-size: 11px;
}
.footer-meta code {
  font-family: var(--font-mono);
  background: rgba(255, 253, 248, 0.1);
  padding: 1px var(--s-2);
  border-radius: var(--r-sm);
  font-size: 11px;
}

/* ============================================================================
   Print stylesheet
   ============================================================================ */

@media print {
  body { background: white; color: black; }
  .topbar, .tab-nav, .filter-bar, .overview-search, .btn-primary, .btn-secondary,
  .stat-card-clickable, .insight-clickable, .drawer { display: none !important; }
  .panel { padding: 0; max-width: none; }
  .panel-explore[hidden] { display: block !important; }
  .project-table tbody tr { cursor: default; page-break-inside: avoid; }
  .notes-cell-text {
    -webkit-line-clamp: unset;
    display: block;
    overflow: visible;
  }
  .site-footer {
    background: white;
    color: black;
    border-top: 1px solid black;
  }
}
