:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --line: #d8dee4;
  --text: #1f2933;
  --muted: #66737f;
  --accent: #256f84;
  --accent-strong: #19596c;
  --selected: #e2f0f4;
  --focus: #b45f28;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

body.auth-page {
  display: grid;
  grid-template-rows: 1fr;
  min-height: 100%;
  overflow: auto;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 50px rgba(31, 41, 51, 0.12);
}

.auth-card h1 {
  margin-bottom: 8px;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-form input {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  text-transform: none;
}

.auth-form .checkbox-label,
.admin-form .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  text-transform: none;
}

.auth-form .checkbox-label input,
.admin-form .checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.auth-card button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.auth-card button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.auth-card button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.auth-message {
  min-height: 20px;
  margin-top: 16px;
  color: var(--focus);
  font-weight: 650;
}

button,
input {
  font: inherit;
}

textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 28vw) 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.view-tabs {
  display: flex;
  gap: 4px;
  min-height: 44px;
  padding: 6px 20px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.view-tab {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
}

.view-tab.active {
  border-color: var(--line);
  background: var(--bg);
  color: var(--text);
}

.data-view {
  display: none;
  min-height: 0;
  overflow: hidden;
}

.data-view.active {
  display: grid;
}

.snapshot-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto auto;
  align-items: center;
  gap: 16px;
  min-height: 54px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff8e8;
  color: var(--text);
}

.snapshot-bar strong {
  display: block;
}

.snapshot-bar span {
  color: var(--muted);
}

.snapshot-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 220px;
}

.user-status span {
  max-width: 300px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refresh-button {
  min-width: 132px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: var(--focus);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
}

.refresh-button:hover:not(:disabled) {
  background: #934816;
}

.refresh-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.logout-button {
  min-width: 76px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
}

.logout-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.logout-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.people-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.panel-header,
.record-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 80px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 650;
}

h2 {
  font-size: 24px;
  font-weight: 650;
}

p {
  margin-top: 4px;
  color: var(--muted);
}

.search-label {
  padding: 14px 20px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.search-input {
  width: calc(100% - 40px);
  height: 38px;
  margin: 0 20px 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.search-input:focus,
.reference-search:focus,
.refresh-button:focus,
.review-button:focus,
.secondary-button:focus,
.nav-button:focus,
.person-row:focus,
.view-tab:focus,
.tab-button:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.people-list {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  min-height: 0;
  padding: 0 8px 12px;
}

.person-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  min-height: 54px;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.person-row:hover,
.person-row.selected {
  background: var(--selected);
}

.person-row.review-flagged {
  border-left: 4px solid var(--focus);
  padding-left: 8px;
}

.person-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.person-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-marker {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff1d9;
  color: #7a390f;
  font-size: 11px;
  font-weight: 700;
}

.person-detail {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-panel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.record-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-button {
  min-width: 96px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
}

.nav-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

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

.review-button,
.secondary-button {
  min-width: 112px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 650;
}

.review-button {
  background: var(--focus);
  color: #ffffff;
}

.review-button:hover:not(:disabled) {
  background: #934816;
}

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

.secondary-button {
  background: #e7ecef;
  color: var(--text);
}

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

.review-panel {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr auto;
  align-items: end;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #fffdf8;
}

.review-panel[hidden] {
  display: none;
}

.review-fields {
  display: contents;
}

.review-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.review-fields input,
.review-fields textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  text-transform: none;
}

.review-fields textarea {
  resize: vertical;
}

.review-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.review-status {
  min-width: 120px;
  color: var(--muted);
  font-size: 12px;
}

.review-flag-summary {
  color: #7a390f;
  font-weight: 650;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.tab-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}

.tab-button.active {
  border-color: var(--line);
  background: var(--bg);
  color: var(--text);
}

.tab-panel {
  display: none;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 20px;
}

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

.field-grid {
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.field-section {
  margin-bottom: 24px;
}

.field-section-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.member-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  background: var(--surface);
}

.member-table th,
.member-table td {
  min-height: 34px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  overflow-wrap: anywhere;
}

.member-table th {
  background: #eef2f4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.member-table td:last-child,
.member-table th:last-child {
  width: 90px;
}

.empty-table-message {
  color: var(--muted);
}

.field-label,
.field-value {
  min-height: 38px;
  padding: 9px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.field-label {
  background: #eef2f4;
  color: var(--muted);
  font-weight: 650;
}

.field-value.empty {
  background: #fbfcfd;
}

.raw-json {
  min-height: 100%;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #111827;
  color: #dbeafe;
  font: 12px/1.5 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
}

.reference-view {
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.reference-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.reference-search {
  width: min(420px, 42vw);
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.reference-pager {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
  vertical-align: middle;
}

.reference-pager button {
  min-width: 64px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.reference-pager button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
}

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

.reference-table-wrap {
  min-height: 0;
  overflow: auto;
  padding: 16px 20px;
}

.reference-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
  table-layout: auto;
}

.reference-table th,
.reference-table td {
  padding: 7px 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.reference-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2f4;
  color: var(--muted);
  font-weight: 700;
}

.admin-view {
  min-height: 0;
  overflow: auto;
  padding: 20px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 20px;
  align-items: start;
}

.admin-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.admin-form input {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  text-transform: none;
}

.admin-form button[type="submit"] {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.admin-form button[type="submit"]:hover:not(:disabled) {
  background: var(--accent-strong);
}

.admin-status {
  min-height: 20px;
  color: var(--focus);
  font-weight: 650;
}

.users-table-wrap {
  overflow: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  font-size: 13px;
}

.users-table th,
.users-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.users-table th {
  background: #eef2f4;
  color: var(--muted);
  font-weight: 700;
}

.admin-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.admin-checkbox:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.jump-person-button {
  min-width: 58px;
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.jump-person-button:hover {
  background: var(--accent-strong);
}

.addressed-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.addressed-checkbox:disabled {
  cursor: wait;
  opacity: 0.7;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 44vh 1fr;
    height: 100%;
  }

  .snapshot-bar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .snapshot-meta {
    justify-content: flex-start;
  }

  .user-status {
    justify-content: space-between;
    min-width: 0;
    width: 100%;
  }

  .user-status span {
    max-width: none;
    text-align: left;
  }

  .reference-header {
    align-items: stretch;
    flex-direction: column;
  }

  .reference-search {
    width: 100%;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .people-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .field-label {
    min-height: 30px;
    padding-bottom: 4px;
  }
}
