:root {
  --blauw: #154273;
  --blauw-donker: #0e2f54;
  --blauw-licht: #e8eef5;
  --groen: #2a7d46;
  --groen-licht: #e6f2ea;
  --oranje: #e17000;
  --oranje-licht: #fdeedd;
  --ink: #1b2a3a;
  --ink-zacht: #5a6b7d;
  --grijs-vlak: #f2f5f8;
  --lijn: #d8e0e8;
  --wit: #ffffff;
  --schaduw: 0 12px 32px rgba(21, 66, 115, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  color: var(--ink);
  background: var(--grijs-vlak);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 22px 18px;
  color: var(--wit);
  background: var(--blauw);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--wit);
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 56px;
  height: 28px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button,
.mobile-nav button {
  border: 0;
  color: inherit;
  background: transparent;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.86);
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  color: var(--wit);
  background: rgba(255, 255, 255, 0.14);
}

.nav-button .count {
  min-width: 24px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--blauw);
  background: var(--wit);
  font-size: 12px;
  text-align: center;
}

.guardrail {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12.5px;
  line-height: 1.4;
}

.guardrail strong {
  color: var(--wit);
  font-size: 14px;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar,
.section-heading,
.map-toolbar,
.admin-toolbar,
.table-actions,
.log-row,
.draft-row,
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin: 0 auto 20px;
  max-width: 1180px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: var(--blauw);
  font-size: 24px;
  line-height: 1.12;
}

h2 {
  color: var(--blauw);
  font-size: 19px;
  line-height: 1.2;
}

h3 {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--ink-zacht);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--lijn);
  border-radius: 999px;
  color: var(--ink-zacht);
  background: var(--wit);
  font-size: 12.5px;
}

.topbar-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--groen);
}

.page-help {
  position: relative;
}

.help-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--lijn);
  border-radius: 50%;
  color: var(--blauw);
  background: var(--wit);
  font-weight: 800;
  line-height: 1;
}

.help-button:hover,
.help-button[aria-expanded="true"] {
  color: var(--wit);
  border-color: var(--blauw);
  background: var(--blauw);
}

.help-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: min(286px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--lijn);
  border-radius: 8px;
  background: var(--wit);
  box-shadow: var(--schaduw);
}

.help-popover[hidden] {
  display: none;
}

.help-popover strong {
  display: block;
  margin-bottom: 4px;
  color: var(--blauw);
  font-size: 14px;
}

.help-popover p {
  color: var(--ink-zacht);
  font-size: 12.5px;
  line-height: 1.45;
}

.view,
.admin-view {
  display: none;
}

.view.active,
.admin-view.active {
  display: block;
}

.view {
  max-width: 1180px;
  margin: 0 auto;
}

.section-heading {
  margin-bottom: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--wit);
  background: var(--blauw);
  font-weight: 650;
}

.button:hover {
  background: var(--blauw-donker);
}

.button-outline {
  color: var(--blauw);
  border-color: var(--blauw);
  background: var(--wit);
}

.button-outline:hover {
  color: var(--wit);
}

.button-orange {
  background: var(--oranje);
}

.button-orange:hover {
  background: #b85c00;
}

.button-plain {
  min-height: 32px;
  padding: 0 10px;
  color: var(--blauw);
  border: 1px solid var(--lijn);
  background: var(--wit);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--lijn);
  border-radius: 4px;
  color: var(--blauw);
  background: var(--wit);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.icon-button:hover {
  color: var(--wit);
  border-color: var(--blauw);
  background: var(--blauw);
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--lijn);
  border-radius: 8px;
  background: var(--wit);
  box-shadow: var(--schaduw);
}

.filter-panel.compact {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.filter-check {
  grid-auto-rows: min-content;
  align-self: end;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.filter-check input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink-zacht);
  font-size: 12.5px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--lijn);
  border-radius: 4px;
  color: var(--ink);
  background: var(--wit);
}

input,
select {
  padding: 0 10px;
}

textarea {
  padding: 10px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(225, 112, 0, 0.28);
  outline-offset: 2px;
}

.discover-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.map-panel,
.list-panel,
.profile-panel,
.admin-panel,
.bucket-column,
.empty-state {
  min-width: 0;
  border: 1px solid var(--lijn);
  border-radius: 8px;
  background: var(--wit);
  box-shadow: var(--schaduw);
}

.map-panel {
  overflow: hidden;
}

.map-toolbar {
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--lijn);
  color: var(--ink-zacht);
  font-size: 12.5px;
}

.map-toolbar span:first-child {
  color: var(--ink);
  font-weight: 700;
}

.map-canvas {
  position: relative;
  min-height: 436px;
  background: var(--blauw-licht);
  z-index: 0;
}

.map-canvas .leaflet-container {
  height: 100%;
  min-height: inherit;
  font: inherit;
  background: var(--blauw-licht);
}

.map-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--wit);
  border-radius: 50%;
  background: var(--blauw);
  color: var(--wit);
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(27, 42, 58, 0.3);
}

.map-popup {
  min-width: 200px;
}

.map-popup-title {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.map-popup-meta,
.map-popup-amount {
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--ink-zacht);
}

.map-popup-amount {
  font-weight: 600;
  color: var(--ink);
}

.map-popup-status {
  margin: 8px 0;
  padding: 6px 8px;
  border-radius: 6px;
  border-left: 3px solid var(--ink-zacht);
  background: var(--grijs-vlak);
  font-size: 12px;
  line-height: 1.35;
}

.map-popup-status strong {
  display: block;
}

.map-popup-status.eligible {
  border-left-color: var(--groen);
  background: var(--groen-licht);
}

.map-popup-status.maybe {
  border-left-color: var(--oranje);
  background: var(--oranje-licht);
}

.map-popup-status.not_eligible {
  border-left-color: var(--ink-zacht);
}

.map-popup-source {
  margin: 0;
  font-size: 11px;
  color: var(--ink-zacht);
}

.list-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.opportunity-card,
.action-card,
.project-card,
.draft-row,
.log-row,
.setting-row {
  border: 1px solid var(--lijn);
  border-radius: 8px;
  background: var(--wit);
}

.opportunity-card,
.action-card,
.project-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
}

.card-header,
.card-meta,
.card-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-meta,
.source-line,
.helper-text {
  min-width: 0;
  color: var(--ink-zacht);
  font-size: 12.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.amount {
  color: var(--groen);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.eligible,
.pill.done {
  color: var(--groen);
  background: var(--groen-licht);
}

.pill.maybe,
.pill.review {
  color: var(--oranje);
  background: var(--oranje-licht);
}

.pill.not_eligible,
.pill.neutral {
  color: var(--ink-zacht);
  background: var(--grijs-vlak);
}

.status-explain {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 4px;
  color: var(--ink);
  background: var(--grijs-vlak);
  font-size: 13px;
  line-height: 1.4;
}

.status-explain.eligible {
  background: var(--groen-licht);
}

.status-explain.maybe {
  background: var(--oranje-licht);
}

.tag-list,
.card-actions,
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--lijn);
  border-radius: 999px;
  color: var(--ink-zacht);
  background: var(--wit);
  font-size: 12.5px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.action-card .card-footer,
.project-card .card-footer {
  align-items: center;
}

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.bucket-column {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px;
}

.bucket-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}

.task-list {
  display: grid;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
  color: var(--ink-zacht);
  font-size: 12.5px;
}

.task-list li {
  display: flex;
  gap: 7px;
}

.task-list li::before {
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--groen);
  content: "";
  flex: 0 0 auto;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(260px, 0.7fr) minmax(320px, 1fr);
  gap: 14px;
  align-items: start;
}

.profile-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.chip {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--lijn);
  border-radius: 999px;
  color: var(--ink);
  background: var(--wit);
}

.chip.active {
  color: var(--groen);
  border-color: var(--groen);
  background: var(--groen-licht);
}

.save-state {
  color: var(--ink-zacht);
  font-size: 12.5px;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--lijn);
}

.tab {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--ink-zacht);
  background: transparent;
  font-weight: 700;
}

.tab.active {
  color: var(--blauw);
  border-bottom-color: var(--blauw);
}

.admin-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  overflow: visible;
}

.admin-toolbar {
  align-items: flex-start;
}

.column-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.column-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--lijn);
  border-radius: 999px;
  color: var(--ink-zacht);
  font-size: 12.5px;
}

.column-toggle input {
  width: auto;
  min-height: auto;
}

.table-note {
  max-width: 820px;
}

.admin-table-bar {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(220px, 1.5fr) minmax(110px, 0.5fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--lijn);
  border-radius: 8px;
  background: var(--grijs-vlak);
}

.admin-search-field {
  min-width: 0;
}

.table-scroll-frame {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.table-scroll-controls {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.table-wrap {
  max-width: 100%;
  max-height: clamp(320px, 58vh, 620px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--lijn);
  border-radius: 8px;
  scrollbar-color: var(--blauw) var(--blauw-licht);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.table-wrap::-webkit-scrollbar-track {
  background: var(--blauw-licht);
}

.table-wrap::-webkit-scrollbar-thumb {
  border: 3px solid var(--blauw-licht);
  border-radius: 999px;
  background: var(--blauw);
}

.table-wrap:focus-visible {
  outline: 3px solid rgba(225, 112, 0, 0.28);
  outline-offset: 2px;
}

table {
  width: max-content;
  min-width: 1880px;
  border-collapse: collapse;
  background: var(--wit);
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--lijn);
  text-align: left;
  vertical-align: top;
  font-size: 12.5px;
  line-height: 1.35;
  overflow-wrap: normal;
  word-break: normal;
  min-width: 126px;
  max-width: 280px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--blauw);
  background: var(--blauw-licht);
  font-weight: 800;
}

.header-label-row th {
  min-height: 52px;
}

.header-filter-row th {
  top: 52px;
  z-index: 3;
  padding-top: 6px;
  padding-bottom: 8px;
  background: #f6f9fc;
}

tr:last-child td {
  border-bottom: 0;
}

td:first-child,
th:first-child {
  width: 44px;
}

.select-column {
  left: 0;
  min-width: 44px;
  max-width: 44px;
  width: 44px;
  text-align: center;
}

td.select-column {
  position: sticky;
  z-index: 1;
  background: var(--wit);
}

th.select-column {
  z-index: 4;
}

.select-column input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.selected-page-count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  min-height: 24px;
  border-radius: 999px;
  color: var(--ink-zacht);
  background: var(--wit);
  font-size: 11.5px;
  font-weight: 800;
}

.action-column {
  right: 0;
  min-width: 96px;
  max-width: 96px;
  width: 96px;
}

td.action-column {
  position: sticky;
  z-index: 1;
  background: var(--wit);
}

th.action-column {
  z-index: 4;
}

.action-column .button {
  width: 100%;
}

.table-head-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  gap: 6px;
  align-items: center;
}

.sort-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-height: 30px;
  padding: 0;
  border: 0;
  color: var(--blauw);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.sort-button:hover {
  color: var(--blauw-donker);
}

.sort-state {
  flex: 0 0 auto;
  padding: 2px 5px;
  border: 1px solid var(--lijn);
  border-radius: 999px;
  color: var(--ink-zacht);
  background: var(--wit);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.column-help {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--lijn);
  border-radius: 50%;
  color: var(--blauw);
  background: var(--wit);
  font-size: 12px;
  font-weight: 900;
  cursor: help;
}

.column-help-text {
  position: absolute;
  top: 28px;
  left: 0;
  z-index: 8;
  display: none;
  width: min(320px, 72vw);
  padding: 10px;
  border: 1px solid var(--lijn);
  border-radius: 6px;
  color: var(--ink);
  background: var(--wit);
  box-shadow: var(--schaduw);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.column-help:hover .column-help-text,
.column-help:focus .column-help-text {
  display: block;
}

.header-filter {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.empty-table-cell {
  min-width: 0;
  max-width: none;
  padding: 20px;
  color: var(--ink-zacht);
  text-align: center;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-zacht);
  font-size: 12.5px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-column-key="title"] {
  min-width: 260px;
  max-width: 320px;
}

[data-column-key="sourceUrl"],
[data-column-key="applyUrl"] {
  min-width: 280px;
  max-width: 360px;
}

[data-column-key="sourceUrl"] a,
[data-column-key="applyUrl"] a {
  overflow-wrap: anywhere;
}

[data-column-key="providerName"],
[data-column-key="reviewStatus"],
[data-column-key="processingDecision"],
[data-column-key="researchFlag"],
[data-column-key="applicationStatus"],
[data-column-key="sourceHealth"],
[data-column-key="sourcePageType"],
[data-column-key="nextAction"] {
  min-width: 150px;
}

[data-column-key="amountLabel"],
[data-column-key="deadline"],
[data-column-key="rankingScore"],
[data-column-key="opportunityCount"],
[data-column-key="deletionCandidate"] {
  min-width: 112px;
}

[data-column-key="processingReason"],
[data-column-key="nextAction"],
[data-column-key="eligibilitySummary"],
[data-column-key="eligibilityQuestions"] {
  min-width: 240px;
  max-width: 360px;
}

.row-title {
  font-weight: 700;
}

.draft-list,
.log-list,
.settings-list {
  display: grid;
  gap: 10px;
}

.field-map {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--lijn);
}

.draft-row,
.log-row,
.setting-row {
  padding: 12px;
}

.log-row {
  align-items: flex-start;
}

.log-meta {
  color: var(--ink-zacht);
  font-size: 12.5px;
  white-space: nowrap;
}

.empty-state {
  padding: 18px;
  color: var(--ink-zacht);
  text-align: center;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 18px 14px 86px;
  }

  .discover-grid,
  .profile-grid,
  .bucket-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .map-canvas {
    min-height: 320px;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    min-height: 64px;
    border-top: 1px solid var(--lijn);
    background: var(--wit);
  }

  .mobile-nav button {
    display: grid;
    place-items: center;
    min-width: 0;
    padding: 8px 3px;
    color: var(--ink-zacht);
    font-size: 11.5px;
    font-weight: 700;
  }

  .mobile-nav button.active {
    color: var(--blauw);
    background: var(--blauw-licht);
  }
}

@media (max-width: 760px) {
  .topbar,
  .section-heading,
  .admin-toolbar,
  .table-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-panel,
  .filter-panel.compact,
  .admin-table-bar {
    grid-template-columns: 1fr;
  }

  .card-header,
  .card-footer,
  .draft-row,
  .log-row,
  .setting-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .phase-badge,
  .amount,
  .log-meta {
    white-space: normal;
  }

  .table-wrap {
    max-height: 52vh;
  }

  .table-footer,
  .pagination-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .help-popover {
    right: -2px;
  }
}
