/* CSS Styles for CORDIS → SDG Static Prototype */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;

  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-alt: #f1f5f9;
  --bg-elevated: #ffffff;

  --border-color: #e2e8f0;
  --border-dark: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-border: #86efac;

  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-border: #fde68a;

  --danger: #dc2626;
  --danger-bg: #fee2e2;

  --neutral-bg: #f1f5f9;
  --neutral-border: #cbd5e1;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

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

.mono {
  font-family: var(--font-mono);
}

/* A shortened hash: dotted underline says there is more, a click shows it all */
.hash-short {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.hash-short:hover,
.hash-short:focus-visible {
  color: var(--primary);
  outline: none;
}
.hash-open {
  overflow-wrap: anywhere;
}

/* Top bar: one slim line that stays; everything else scrolls */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.wordmark {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
  background-color: var(--bg-alt);
  outline: none;
}

.menu-lines {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 22px;
}

.menu-lines i {
  display: block;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 1px;
}

.site-menu {
  position: fixed;
  top: 56px;
  right: 0;
  z-index: 50;
  min-width: 280px;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 0;
}

.menu-list {
  list-style: none;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  color: var(--text-primary);
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background-color: var(--bg-alt);
  outline: none;
}

.menu-item.active {
  color: var(--primary);
  font-weight: 600;
}

.menu-backdrop {
  position: fixed;
  inset: 56px 0 0 0;
  z-index: 45;
  background: rgb(15 23 42 / 0.15);
}

/* Page head */
.page-head {
  max-width: 1400px;
  margin: 1.5rem auto 0 auto;
  padding: 0 1.5rem;
}

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

.header-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  background-color: var(--primary-light);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
}

.header-titles h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  max-width: 680px;
}

.provenance-badges {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.badge-item {
  background: var(--bg-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  display: flex;
  flex-direction: column;
}

.badge-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.badge-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.badge-link {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease, text-decoration 0.15s ease;
}

.badge-link:hover,
.badge-link:focus {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Main Content */
.app-main {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  min-height: calc(100vh - 250px);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.pane-intro {
  margin-bottom: 1.5rem;
}

.pane-intro h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pane-intro p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.2rem 0;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.stat-total { border-left: 4px solid var(--primary); }
.stat-target { border-left: 4px solid var(--success); }
.stat-goal { border-left: 4px solid var(--warning); }
.stat-none { border-left: 4px solid var(--text-muted); }

.stat-card.is-active {
  background-color: var(--bg-alt);
  box-shadow: var(--shadow-md);
}

/* Filters Card */
.filters-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.filters-main {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.search-box {
  flex: 2;
  min-width: 280px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.55rem 2rem 0.55rem 2.2rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  position: absolute;
  right: 0.5rem;
}

.icon-btn:hover {
  color: var(--text-primary);
}

.filter-group {
  flex: 1;
  min-width: 150px;
  display: flex;
  flex-direction: column;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.filter-group select {
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background-color: var(--bg-surface);
  outline: none;
  cursor: pointer;
}

.filter-group select:focus {
  border-color: var(--primary);
}

.quick-presets {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.preset-btn {
  background: var(--bg-alt);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.preset-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.preset-reset {
  margin-left: auto;
  color: var(--danger);
  border-color: var(--danger-bg);
}

.preset-reset:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Results Header */
.results-header, .results-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: -0.25rem;
  margin-bottom: 0.6rem;
}

.results-footer {
  margin-top: 1rem;
}

.results-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.page-size-selector select {
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

/* Pagination Controls */
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.page-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

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

.projects-table th {
  background-color: var(--bg-alt);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.projects-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.projects-table tbody tr.project-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.projects-table tbody tr.project-row:hover {
  background-color: var(--primary-light);
}

.projects-table tbody tr.project-row:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background-color: var(--primary-light);
}

.projects-table tbody tr.project-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background-color: var(--primary-light);
}

.project-title-link {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.project-title-link:hover,
.projects-table tbody tr.project-row:hover .project-title-link {
  color: var(--primary-hover);
  text-decoration: underline;
}

.col-id { width: 110px; }
.col-acronym { width: 140px; }
.projects-table td.col-id,
.projects-table td.col-acronym { color: var(--text-secondary); font-weight: 500; }
.col-title { min-width: 340px; }
.col-level { width: 130px; }
.col-sdgs { width: 150px; }
.col-band { width: 110px; }

.loading-cell {
  text-align: center;
  padding: 2.5rem !important;
  color: var(--text-muted);
  font-style: italic;
}

/* Status Badges */
.badge-level {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.badge-target {
  background-color: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-goal {
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-none {
  background-color: var(--neutral-bg);
  color: var(--text-muted);
  border: 1px solid var(--neutral-border);
}

.badge-band {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.band-high {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.band-medium {
  background: #fef9c3;
  color: #a16207;
  border: 1px solid #fde047;
}

.band-low {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.band-none {
  color: var(--text-muted);
}

.sdg-chip {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  margin-right: 0.25rem;
  margin-bottom: 0.2rem;
  background: var(--text-muted);
}

.btn {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border-dark);
  color: var(--text-secondary);
}

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

/* SDG Grid */
.sdg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.sdg-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.sdg-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.sdg-card.is-open {
  border-color: var(--border-dark);
  box-shadow: var(--shadow-md);
  background-color: var(--bg-alt);
}

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

.sdg-card-hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}
.sdg-card-hint::after { content: "Show targets \2193"; }
.sdg-card.is-open .sdg-card-hint::after { content: "Hide targets \2191"; }

/* While open, the breakdown sits inside the grid, under the clicked card's row */
.sdg-grid > .target-breakdown-card {
  grid-column: 1 / -1;
  margin-bottom: 0.25rem;
}

.target-label {
  font-weight: 400;
  color: var(--text-secondary);
}

.target-row { cursor: pointer; }

.means-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background-color: var(--bg-alt);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  margin-left: 0.4rem;
  vertical-align: middle;
  white-space: nowrap;
}

.note-link {
  color: var(--primary);
  text-decoration: underline;
}
.target-row:hover td { background-color: var(--bg-alt); }

.share-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.share-cell .progress-bar-bg { flex: 1; }
.share-pct {
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-width: 2.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.goal-statement {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

.goal-counts {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.un-outbound-link {
  color: inherit;
  text-decoration: none;
}
.un-outbound-link:hover,
.un-outbound-link:focus {
  color: var(--primary);
  text-decoration: underline;
}
.un-outbound-link .external-icon {
  font-size: 0.75em;
  color: var(--text-muted);
}

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

.target-chip {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background-color: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.target-chip:hover { background-color: var(--bg-alt); }

.targets-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.sdg-card-bar {
  height: 6px;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.sdg-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.sdg-num-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.sdg-count-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sdg-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.sdg-card-pct {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Target Breakdown Drawer */
.target-breakdown-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.target-breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.target-breakdown-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.target-breakdown-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.targets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.targets-table th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border-color);
}

.targets-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
}

.bar-cell {
  width: 40%;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background-color: var(--bg-alt);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: 999px;
}

/* Evaluation & Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* The edge colour says where the number comes from, as on Home: blue for a
   figure measured on the held-out 100, amber for a limit of the method, grey
   for a development-set figure. */
.highlight-box {
  border-left: 4px solid var(--primary);
}

.warning-box {
  border-left: 4px solid var(--warning);
}

.dev-box {
  border-left: 4px solid var(--text-muted);
}

.metric-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.metric-number {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0.25rem 0;
  font-variant-numeric: tabular-nums;
}

.metric-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.eval-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.eval-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.eval-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.eval-list li {
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.repro-box {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.code-block {
  background: #0f172a;
  color: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin: 0.75rem 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

/* Figures Gallery */
.figures-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.figure-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.figure-media {
  background: #ffffff;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 320px;
}

.responsive-svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.figure-info {
  padding: 1.25rem 1.5rem;
}

.figure-info h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.fig-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  margin-bottom: 0.6rem;
}

.fig-file {
  font-weight: 600;
  color: var(--primary);
}

.fig-hash {
  color: var(--text-muted);
}

.fig-caption {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Provenance Grid */
.provenance-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.provenance-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.provenance-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.contract-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

/* A 64-character digest has no break opportunity; on a narrow window it must
   wrap inside its cell rather than push the page sideways. */
.contract-table td {
  overflow-wrap: anywhere;
}

.contract-table th {
  background: var(--bg-alt);
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.contract-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
}

.covenant-list li {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Modal / Drawer */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-content {
  background: var(--bg-surface);
  width: 100%;
  max-width: 880px;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  background: var(--bg-alt);
}

.modal-title-group {
  flex: 1;
}

.modal-meta-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.modal-id {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.modal-title-link {
  color: inherit;
  text-decoration: none;
  display: inline;
  transition: color 0.15s ease, text-decoration 0.15s ease;
}

.modal-title-link:hover,
.modal-title-link:focus {
  color: var(--primary);
  text-decoration: underline;
}

.project-title-link.cordis-outbound-link {
  display: inline;
  text-decoration: underline;
}

.cordis-outbound-link {
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  transition: color 0.15s ease, text-decoration 0.15s ease;
}

.cordis-outbound-link:hover,
.cordis-outbound-link:focus {
  color: var(--primary-hover);
  text-decoration: underline;
}

.external-icon {
  font-size: 0.8em;
  opacity: 0.85;
}

.modal-acronym {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Modal Detail Cards */
.detail-assignment-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  overflow: hidden;
  background: var(--bg-surface);
}

.assignment-header {
  background: var(--bg-alt);
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.assignment-target-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.assignment-scores {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.score-badge {
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.assignment-body {
  padding: 1.25rem;
}

/* What the record contains: one small block under the evidence */
.record-fields {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.record-fields-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.record-fields-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

.record-fields-label {
  white-space: nowrap;
}

.record-fields-none {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pill-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.source-pill-present {
  background-color: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.source-pill-absent {
  background-color: var(--bg-alt);
  color: var(--text-muted);
  border: 1px solid var(--border-dark);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-style: italic;
}

/* Evidence text block */
.evidence-block {
  background: var(--bg-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.45;
  margin-top: 0.5rem;
}

/* Unassigned Project Notice */
.unassigned-notice {
  background: var(--bg-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
}

.unassigned-notice h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.unassigned-notice p {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* Footer */
.app-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.footer-sub {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .page-head { padding: 0 1rem; }
  .app-main { padding: 0 1rem; }
  .filters-main { flex-direction: column; align-items: stretch; }
  .figures-gallery { grid-template-columns: 1fr; }
  .eval-cards-container { grid-template-columns: 1fr; }
}
