:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --paper: #ffffff;
  --ink: #17211c;
  --muted: #69736d;
  --line: #d9ded8;
  --blue: #1f5f9f;
  --blue-dark: #12426f;
  --green: #22735d;
  --amber: #b66a17;
  --shadow: 0 12px 28px rgb(23 33 28 / 9%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

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

a {
  color: inherit;
}

.app-shell,
.admin-shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 96px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 20px;
}

.topbar-actions,
.details-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef2ee;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.details-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 560px;
}

.action-help {
  flex-basis: 100%;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.admin-link,
.primary-button,
.ghost-button,
.quiet-button,
.icon-button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.admin-link,
.ghost-button {
  color: var(--blue);
  background: transparent;
  font-weight: 700;
}

.ghost-button.danger {
  color: #9d2f2f;
}

.quiet-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f7;
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.quiet-button:hover {
  color: var(--blue-dark);
  border-color: #c9d2cc;
}

.quiet-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 7px;
  background: var(--blue);
  color: white;
  font-weight: 800;
}

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

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 7px;
  background: #eef2ee;
  color: var(--muted);
  font-size: 22px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel.inset {
  box-shadow: none;
}

.hidden {
  display: none;
}

.field-grid {
  display: grid;
  gap: 12px;
}

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

label,
fieldset {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  padding: 0 6px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgb(31 95 159 / 14%);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.matches {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.match-row {
  display: grid;
  grid-template-columns: 1.1fr 0.5fr 1.3fr 40px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.section-header,
.details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
  padding: 14px 0;
  background: linear-gradient(180deg, rgb(244 246 243 / 20%), var(--bg) 45%);
}

#formStatus {
  margin: 0;
  color: var(--green);
  font-weight: 700;
}

.admin-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 12px 14px 10px;
}

.tab-button.active {
  border-bottom-color: var(--blue);
  color: var(--blue-dark);
}

.tab-view {
  display: none;
}

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

.report-list,
.report-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
  box-shadow: var(--shadow);
}

.reference-page {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 18px;
  box-shadow: var(--shadow);
}

.reference-block {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.reference-list {
  display: grid;
  gap: 8px;
}

.reference-form,
.reference-row,
.user-row {
  display: grid;
  gap: 7px;
}

.reference-form-wide,
.reference-row {
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.55fr) auto auto;
  align-items: center;
}

.reference-row {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.user-form {
  grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1fr) minmax(150px, 0.8fr) minmax(160px, 1fr) auto;
  align-items: center;
}

.user-row {
  grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1fr) minmax(150px, 0.8fr) minmax(120px, 0.7fr) minmax(160px, 1fr) auto auto;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.user-row .muted {
  grid-column: 1 / -1;
  margin: 0;
}

.utility-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 10px 14px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.utility-title {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.utility-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.utility-panel .muted {
  margin: 0;
}

#exportStatus {
  grid-column: 1 / -1;
  min-height: 18px;
}

.reference-list-wide {
  margin-top: 14px;
}

.reports-list {
  display: grid;
  gap: 10px;
}

.filters {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.report-card {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
  text-align: left;
}

.report-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgb(31 95 159 / 14%);
}

.report-card-title {
  font-weight: 800;
}

.report-card-meta,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  width: fit-content;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue-dark);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}

.text-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.text-block strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.text-block p {
  margin-bottom: 0;
  line-height: 1.45;
}

.match-list {
  margin: 0;
  padding-left: 20px;
}

.field-note {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.publication-links {
  margin-top: 12px;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(23 33 28 / 42%);
}

.confirm-dialog {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 20px;
  box-shadow: var(--shadow);
}

.confirm-dialog p {
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 22px;
  box-shadow: var(--shadow);
}

#loginStatus {
  min-height: 20px;
  color: var(--amber);
  font-weight: 700;
}

@media (max-width: 760px) {
  .app-shell,
  .admin-shell {
    width: min(100% - 18px, 1120px);
    padding-top: 8px;
  }

  .topbar,
  .section-header,
  .details-header,
  .topbar-actions,
  .details-actions,
  .sticky-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid.two,
  .detail-grid,
  .admin-layout,
  .match-row,
  .reference-form-wide,
  .reference-row,
  .utility-panel,
  .user-form,
  .user-row {
    grid-template-columns: 1fr;
  }

  .utility-actions {
    justify-content: stretch;
  }

  .quiet-button {
    width: 100%;
  }

  .icon-button {
    width: 100%;
  }

  .action-help {
    text-align: left;
  }

  .confirm-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
