:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5b6773;
  --surface: #ffffff;
  --surface-muted: #f4f7fa;
  --surface-accent: #eef5ff;
  --border: #c7d1db;
  --border-strong: #8a9aaa;
  --accent: #155eef;
  --accent-dark: #1048b8;
  --danger: #b42318;
  --danger-surface: #fff1f0;
  --focus: #f79009;
  --shadow: 0 10px 30px rgba(23, 32, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #f2f5f9;
}

a {
  color: var(--accent-dark);
}

.site-header {
  background: #102a43;
  color: #fff;
  box-shadow: 0 2px 12px rgba(16, 42, 67, 0.18);
}

.site-header__inner,
.page-shell {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  min-height: 4.25rem;
  padding: 0.65rem 0;
}

.site-header__identity,
.site-header__actions,
.site-nav,
.logout-form {
  display: flex;
  align-items: center;
}

.site-header__identity {
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}

.site-header__actions {
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.site-nav {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.3rem;
}

.site-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.4rem 0.7rem;
  color: #e8f0f8;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.45rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}

.site-nav__link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.16);
}

.site-nav__logout {
  color: #ffd6d2;
  background: rgba(255, 125, 112, 0.08);
  border-color: rgba(255, 180, 172, 0.18);
}

.user-chip {
  max-width: 16rem;
  overflow: hidden;
  color: #bcd0e3;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand {
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.page-shell {
  padding: 1.5rem 0 3.5rem;
}

.card,
.form-page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
}

.card {
  max-width: 40rem;
  margin: 2rem auto;
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

.form-page {
  width: 100%;
  padding: clamp(1rem, 2.5vw, 2rem);
}

.page-heading {
  max-width: 70rem;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1.15;
  text-wrap: balance;
}

h2,
h3 {
  text-wrap: balance;
}

.intro {
  margin: 0;
  color: var(--muted);
}

.registry-form {
  width: 100%;
}

.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.form-section {
  min-width: 0;
  margin: 0;
  padding: 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
}

.form-section legend {
  max-width: 100%;
  padding: 0 0.45rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.form-section--classification {
  background: var(--surface-accent);
  border-color: #b9d0f4;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
}

.directory-fields,
.supporter-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.directory-fields > input[type="hidden"] {
  display: none;
}

.supporter-fields {
  padding-top: 0.9rem;
  border-top: 1px solid #b9d0f4;
}

.field,
.remote-picker,
.address-picker {
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
}

.field label,
.remote-picker label,
.address-picker label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 650;
}

.required-mark {
  color: var(--danger);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.7rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0.4rem;
}

select {
  color-scheme: light;
}

input::placeholder,
textarea::placeholder {
  color: #7b8794;
  opacity: 1;
}

input[readonly] {
  background: var(--surface-muted);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error,
.form-error {
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.875rem;
}

.form-error {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--danger-surface);
  border-left: 0.25rem solid var(--danger);
  border-radius: 0.25rem;
}

.form-warning,
.polling-station-confirmation {
  display: grid;
  gap: 0.2rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: #fff8e1;
  border-left: 0.25rem solid var(--focus);
  border-radius: 0.25rem;
}

.form-warning > *,
.polling-station-confirmation > * {
  display: block;
  margin: 0.35rem 0 0;
}

.form-warning > :first-child,
.polling-station-confirmation > :first-child {
  margin-top: 0;
}

.polling-station-confirmation .field {
  max-width: 52rem;
}

.polling-station-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.9rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}

.polling-station-picker__results {
  flex: 1 1 24rem;
  max-width: 52rem;
}

.field-hint,
.submit-status {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.remote-picker,
.address-picker {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #f7f9fc;
  border: 1px solid #dbe3eb;
  border-radius: 0.55rem;
}

.remote-picker__results,
.address-picker__results {
  margin-top: 0.5rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.6rem 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0.4rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.button:hover {
  background: var(--surface-muted);
  border-color: #63788b;
}

.button--primary {
  color: #fff;
  background: var(--accent);
}

.button--primary:hover {
  background: var(--accent-dark);
}

.button--secondary {
  color: var(--ink);
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

.button--secondary:hover {
  background: #e7edf3;
}

.button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.form-actions > form {
  margin: 0;
}

.form-actions .submit-status {
  flex: 1 1 100%;
}

.confirmation,
.error-page {
  text-align: center;
}

.confirmation p:not(.eyebrow),
.error-page p:not(.eyebrow) {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

@media (min-width: 768px) {
  .page-shell {
    padding-top: 2rem;
  }

  .form-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-section--comment .field-grid {
    grid-template-columns: 1fr;
  }
}

.registry-filters {
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.registry-filters .field-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.registry-filters .form-actions {
  margin-top: 1rem;
  padding-top: 1rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.registry-table {
  width: 100%;
  min-width: 48rem;
  border-collapse: collapse;
  background: var(--surface);
}

.registry-table--compact {
  min-width: 0;
  table-layout: fixed;
}

.registry-table--compact th,
.registry-table--compact td {
  white-space: normal;
  overflow-wrap: anywhere;
}

.registry-table--compact th:nth-child(1),
.registry-table--compact td:nth-child(1) {
  width: 28%;
}

.registry-table--compact th:nth-child(2),
.registry-table--compact td:nth-child(2) {
  width: 18%;
}

.registry-table--compact th:nth-child(3),
.registry-table--compact td:nth-child(3) {
  width: 27%;
}

.registry-table--compact th:nth-child(4),
.registry-table--compact td:nth-child(4) {
  width: 27%;
}

.registry-table--compact td:last-child .button {
  width: 100%;
  padding-inline: 0.45rem;
  font-size: 0.85rem;
}

.registry-table th,
.registry-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.selection-column {
  width: 3rem;
  text-align: center !important;
}

.selection-column input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin: 0.2rem;
}

.registry-table th {
  color: var(--ink);
  background: var(--surface-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

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

.registry-table tbody tr:hover {
  background: #f8fbff;
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-muted);
  white-space: nowrap;
}

.status-badge--review {
  color: #7a4b00;
  background: #fff1c2;
}

.registry-delete-form {
  margin-top: 1.25rem;
}

.registry-delete-actions {
  display: grid;
  grid-template-columns: auto auto minmax(16rem, 1fr) auto;
  align-items: end;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  padding: 1rem;
  background: #fff8e1;
  border: 1px solid #f2c66d;
  border-radius: 0.5rem;
}

.registry-delete-actions label {
  grid-column: 1 / -1;
  font-weight: 650;
}

.registry-delete-actions input[data-delete-confirmation] {
  min-width: 0;
}

.selected-count {
  color: var(--muted);
  font-weight: 650;
}

.record-values {
  display: grid;
  grid-template-columns: minmax(10rem, 0.4fr) minmax(0, 1fr);
  gap: 0.45rem 1rem;
}

.record-values dt {
  color: var(--muted);
  font-weight: 650;
}

.record-values dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.admin-page {
  width: 100%;
}

.card.registry-page,
.card.record-detail,
.card.admin-page {
  max-width: none;
  margin: 0;
}

.record-detail h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.25rem;
}

.compact-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem;
}

.compact-form input,
.compact-form select {
  min-width: 12rem;
}

.admin-page > h2 {
  margin: 2rem 0 0.9rem;
  font-size: 1.25rem;
}

.admin-create-form {
  display: grid;
  gap: 0.9rem;
  max-width: 36rem;
}

.admin-create-form .button {
  justify-self: start;
}

.duplicate-conflict {
  max-width: none;
  margin: 1.25rem 0;
}

.duplicate-conflict h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.duplicate-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.duplicate-card {
  min-width: 0;
  padding: 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.duplicate-card h3 {
  margin: 0;
}

.duplicate-card__values {
  grid-template-columns: minmax(8rem, 0.4fr) minmax(0, 1fr);
  font-size: 0.9rem;
}

.duplicate-conflict .form-actions {
  margin-top: 1rem;
}

@media (max-width: 767px) {
  .duplicate-cards {
    grid-template-columns: 1fr;
  }
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.pagination a {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  padding: 0.45rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0.4rem;
  font-weight: 650;
  text-decoration: none;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.65rem 0.85rem;
  color: #fff;
  background: var(--ink);
  border-radius: 0.4rem;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  accent-color: var(--accent);
}

.profile-toggle,
.form-warning label {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  line-height: 1.35;
}

.profile-toggle {
  width: fit-content;
  max-width: 100%;
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  color: #173b68;
  background: var(--surface-accent);
  border: 1px solid #b9d0f4;
  border-radius: 0.5rem;
  font-weight: 650;
  cursor: pointer;
}

.auth-card form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.25rem;
}

.auth-card form .button {
  width: 100%;
  margin-top: 0.25rem;
}

.field--invalid label {
  color: var(--danger);
}

.field-hint:empty,
.submit-status:empty {
  display: none;
}

[hidden] {
  display: none !important;
}

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

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

@media (max-width: 767px) {
  .site-header__inner {
    align-items: flex-start;
  }

  .site-header__actions {
    width: 100%;
    justify-content: flex-start;
    align-items: stretch;
  }

  .site-nav {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .site-nav__link {
    flex: 0 1 auto;
  }

  .logout-form {
    margin-left: auto;
  }

  .form-page {
    padding: 1rem 0.8rem;
  }

  .directory-fields,
  .supporter-fields {
    grid-template-columns: 1fr;
  }

  .form-actions .button,
  .form-actions > form,
  .form-actions > form .button {
    width: 100%;
  }

  .admin-create-form .button {
    width: 100%;
  }

  .registry-delete-actions {
    grid-template-columns: 1fr;
  }

  .registry-delete-actions label {
    grid-column: auto;
  }

  .registry-delete-actions .button,
  .registry-delete-actions input[data-delete-confirmation] {
    width: 100%;
  }

  .duplicate-cards {
    grid-template-columns: 1fr;
  }
}
