:root {
  --bg: #f8fafc;
  --bg-subtle: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: #1e3a8a;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;

  --crimson: #be123c;
  --crimson-soft: #fff1f2;
  --crimson-border: #fecdd3;

  --emerald: #047857;
  --emerald-soft: #ecfdf5;
  --emerald-border: #a7f3d0;

  --sky: #0369a1;
  --sky-soft: #f0f9ff;
  --sky-border: #bae6fd;

  --amber: #b45309;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;

  --violet: #6d28d9;
  --violet-soft: #f5f3ff;
  --violet-border: #ddd6fe;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-subtle: #111827;
  --surface: #151f32;
  --surface-hover: #1b2840;
  --border: #24324b;
  --border-strong: #334155;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --primary: #60a5fa;
  --primary-hover: #93c5fd;
  --primary-soft: rgba(59, 130, 246, 0.14);
  --primary-border: rgba(96, 165, 250, 0.35);

  --crimson: #fb7185;
  --crimson-soft: rgba(244, 63, 94, 0.14);
  --crimson-border: rgba(251, 113, 133, 0.35);

  --emerald: #34d399;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --emerald-border: rgba(52, 211, 153, 0.35);

  --sky: #38bdf8;
  --sky-soft: rgba(14, 165, 233, 0.14);
  --sky-border: rgba(56, 189, 248, 0.35);

  --amber: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --amber-border: rgba(251, 191, 36, 0.35);

  --violet: #a78bfa;
  --violet-soft: rgba(139, 92, 246, 0.15);
  --violet-border: rgba(167, 139, 250, 0.35);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 42px rgba(0, 0, 0, 0.55);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-subtle);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

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

.hidden {
  display: none !important;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none !important;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1e3a8a 0%, #be123c 100%);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 1.35rem;
}

.nav-link {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none !important;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none !important;
  white-space: nowrap;
}

.btn-sm {
  font-size: 0.82rem;
  padding: 0.42rem 0.75rem;
}

.btn-primary {
  background: #1e3a8a;
  color: #ffffff;
  border-color: #1e3a8a;
}

.btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

[data-theme="dark"] .btn-primary {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
}

[data-theme="dark"] .btn-primary:hover {
  background: #3b82f6;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--primary);
}

.btn-outline[aria-pressed="true"] {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber-border);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.count-pill {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.74rem;
  font-family: var(--font-mono);
}

/* Hero */
.hero {
  padding: 2.5rem 0 2rem;
  background:
    radial-gradient(circle at 8% 0%, var(--primary-soft), transparent 45%),
    radial-gradient(circle at 92% 10%, var(--crimson-soft), transparent 40%),
    var(--surface);
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 2rem;
  align-items: center;
}

.eyebrow-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.eyebrow-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.updated-tag {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.auto-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 500;
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 24%, transparent);
}

.badge-auto {
  background: var(--sky-soft);
  color: var(--sky);
  border-color: var(--sky-border);
}

.hero h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.65rem, 2.8vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.18;
}

.hero-lead {
  margin: 0 0 1.35rem;
  font-size: 0.98rem;
  color: var(--text-secondary);
  max-width: 68ch;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

.kpi-card {
  text-align: left;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.kpi-label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1.1;
  color: var(--text);
}

.kpi-emerald .kpi-value {
  color: var(--emerald);
}

.kpi-crimson .kpi-value {
  color: var(--crimson);
}

.kpi-indigo .kpi-value {
  color: var(--primary);
}

.kpi-meta {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* Explorer Section */
.explorer-section {
  padding: 1.75rem 0 3.5rem;
}

.presets-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.presets-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.presets-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.preset-chip {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.preset-chip.active {
  background: #1e3a8a;
  color: #ffffff;
  border-color: #1e3a8a;
}

[data-theme="dark"] .preset-chip.active {
  background: #2563eb;
  border-color: #3b82f6;
}

/* Filter Panel */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.search-row {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 0.95rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1 1 340px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.05rem;
  pointer-events: none;
}

#searchInput {
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0.65rem 2.2rem 0.65rem 2.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#searchInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.clear-search-btn {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.88rem;
  padding: 0.25rem;
}

.view-sort-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.control-select {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.58rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  width: 100%;
}

.control-select:focus {
  outline: none;
  border-color: var(--primary);
}

.view-switcher {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}

.view-btn {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.55rem 0.8rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-right: 1px solid var(--border);
}

.view-btn:last-child {
  border-right: none;
}

.view-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
}

.facets-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.facet-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.facet-item label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.results-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.results-count-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.shortlist-active-banner {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid var(--amber-border);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.link-btn {
  background: none;
  border: none;
  color: var(--crimson);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

/* Cards Grid */
.grants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1.1rem;
}

.grant-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  cursor: pointer;
  position: relative;
}

.grant-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
}

.status-open {
  background: var(--emerald-soft);
  color: var(--emerald);
  border-color: var(--emerald-border);
}

.status-rolling {
  background: var(--sky-soft);
  color: var(--sky);
  border-color: var(--sky-border);
}

.status-upcoming {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber-border);
}

.status-paused {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-color: var(--border-strong);
}

.pathway-direct {
  background: var(--crimson-soft);
  color: var(--crimson);
  border-color: var(--crimson-border);
}

.pathway-consortium {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

.pathway-compute {
  background: var(--violet-soft);
  color: var(--violet);
  border-color: var(--violet-border);
}

.pathway-fellowship {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.bookmark-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 0.98rem;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.bookmark-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.bookmark-btn.saved {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  color: var(--amber);
}

.card-title {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 700;
  line-height: 1.32;
  color: var(--text);
}

.card-funder {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.metrics-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}

.metric-col {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.metric-label {
  font-size: 0.69rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  color: var(--text-muted);
}

.metric-val {
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.urgent-chip {
  display: inline-block;
  margin-top: 0.15rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--crimson);
}

.card-summary {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.strategy-snippet {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  padding: 0.5rem 0.65rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.79rem;
  color: var(--text-secondary);
}

.strategy-snippet strong {
  color: var(--text);
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: auto;
}

.group-tag {
  font-size: 0.71rem;
  font-weight: 600;
  padding: 0.16rem 0.48rem;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  font-size: 0.81rem;
}

.fit-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--emerald);
}

.card-actions-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.card-link-btn:hover {
  text-decoration: underline;
}

/* Table View */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.grants-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.grants-table th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.grants-table td {
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.grants-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.grants-table tbody tr:hover {
  background: var(--surface-hover);
}

.table-title {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.18rem;
}

.table-funder {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Timeline View */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.timeline-bucket {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem;
}

.timeline-bucket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
}

.timeline-bucket-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.timeline-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}

.timeline-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.empty-state h3 {
  margin: 0 0 0.4rem;
}

.empty-state p {
  margin: 0 0 1.1rem;
  color: var(--text-secondary);
}

/* Playbook & External Databases */
.playbook-section,
.databases-section {
  padding: 3rem 0;
  border-top: 1px solid var(--border);
}

.playbook-section {
  background: var(--surface);
}

.section-header {
  margin-bottom: 1.75rem;
  max-width: 68ch;
}

.section-header h2 {
  margin: 0.5rem 0 0.45rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.section-header p {
  margin: 0;
  color: var(--text-secondary);
}

.playbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.1rem;
}

.playbook-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.playbook-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.45rem;
}

.playbook-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.playbook-card p {
  margin: 0;
  font-size: 0.87rem;
  color: var(--text-secondary);
}

.databases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.db-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.db-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.db-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.db-cat {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.db-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.db-card p {
  margin: 0;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

/* Footer */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-inner p {
  margin: 0.35rem 0 0;
  max-width: 65ch;
}

.footer-links {
  display: flex;
  gap: 1.15rem;
  flex-wrap: wrap;
  font-weight: 600;
}

/* Slide-Over Drawer & Modal */
.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: flex-end;
}

.modal-backdrop {
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.drawer {
  width: min(640px, 100vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-header,
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--border);
}

.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.drawer-body {
  padding: 1.4rem;
  overflow-y: auto;
  flex: 1;
}

.drawer-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  line-height: 1.28;
}

.drawer-funder {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 1.15rem;
}

.drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.drawer-stat {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
}

.drawer-section {
  margin-bottom: 1.2rem;
}

.drawer-section h4 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.drawer-section p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
}

.drawer-callout {
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.05rem;
  margin-bottom: 1.2rem;
}

.drawer-callout h4 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.drawer-callout p {
  margin: 0;
  font-size: 0.9rem;
}

.drawer-cta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Modal Form */
.modal {
  width: min(620px, 100%);
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header h3 {
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
}

.modal-body {
  padding: 1.25rem 1.4rem;
  overflow-y: auto;
}

.modal-helper {
  margin: 0 0 1rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label,
.generated-output label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-field input,
.form-field select,
.form-field textarea,
.generated-output textarea {
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
}

.generated-output {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.generated-output textarea {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.modal-footer {
  margin-top: 1.1rem;
  display: flex;
  gap: 0.65rem;
  justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  background: #0f172a;
  color: #ffffff;
  padding: 0.7rem 1.05rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}

/* Responsive */
@media (max-width: 1060px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .facets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .topbar-nav {
    display: none;
  }
}

@media (max-width: 640px) {
  .grants-grid {
    grid-template-columns: 1fr;
  }
  .facets-grid,
  .kpi-grid,
  .form-grid,
  .drawer-grid {
    grid-template-columns: 1fr;
  }
  .metrics-box {
    grid-template-columns: 1fr;
  }
}
