:root {
  color-scheme: light;
  --ink: #251e19;
  --muted: #62554c;
  --paper: #fffdf8;
  --surface: #f7f0e7;
  --line: #c9b9a7;
  --mesa: #8d5136;
  --mesa-dark: #69361f;
  --sage: #596f57;
  --danger: #8a2f23;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--mesa);
  color: var(--white);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--mesa-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.packet-link:focus-visible {
  outline: 3px solid #2f675f;
  outline-offset: 3px;
}

button:disabled {
  background: #aaa097;
  cursor: not-allowed;
}

.secondary-action {
  border: 2px solid var(--mesa);
  background: var(--white);
  color: var(--mesa-dark);
}

.secondary-action:hover {
  background: var(--surface);
  color: var(--ink);
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  padding: 0 12px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 24px;
  align-items: end;
  padding: 12px 0 22px;
  border-bottom: 4px solid var(--mesa);
}

.header-side {
  display: grid;
  gap: 12px;
}

.account-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 800;
}

.account-panel button {
  min-height: 40px;
}

.admin-indicator {
  border-radius: 999px;
  padding: 2px 10px;
  background: var(--sage);
  color: var(--white);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.login-shell {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 56px 16px;
}

.login-card {
  border: 1px solid var(--line);
  border-top: 4px solid var(--mesa);
  border-radius: 6px;
  background: var(--white);
  padding: 28px;
}

.login-card h1 {
  margin-bottom: 14px;
}

.login-form {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.login-form label:not(:first-child) {
  margin-top: 10px;
}

.login-form button {
  margin-top: 14px;
}

.form-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.account-section {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.account-section h2 {
  margin-bottom: 10px;
}

.account-details {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 14px 16px;
}

.account-details p {
  margin: 4px 0;
}

.invitation-summary,
.new-invitation {
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 14px 16px;
}

.invitation-summary h2,
.new-invitation h3 {
  margin: 0 0 10px;
}

.invitation-summary p {
  margin: 4px 0;
}

.new-invitation input {
  margin-bottom: 10px;
}

.new-invitation button {
  margin: 8px 8px 0 0;
}

.admin-form {
  display: grid;
  gap: 10px;
  max-width: 780px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.admin-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 14px;
}

.admin-card h3 {
  margin: 0 0 6px;
  color: var(--ink);
}

.admin-card p {
  margin: 0 0 10px;
  color: var(--muted);
}

.admin-card .actions {
  justify-content: flex-start;
}

.account-records {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

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

.record {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 10px 12px;
  overflow-wrap: anywhere;
}

.record p {
  margin: 0;
}

.record .meta {
  display: block;
  margin-top: 3px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--sage);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2.1rem;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
  letter-spacing: 0;
}

h3 {
  margin: 24px 0 10px;
  font-size: 1rem;
  color: var(--mesa-dark);
  letter-spacing: 0;
}

.source-note {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.band {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.search-form {
  margin-bottom: 16px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 130px;
  gap: 10px;
  align-items: end;
}

.api-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  max-width: 580px;
}

.api-row label {
  margin: 0;
}

.status-line {
  margin: 14px 0 0;
  color: var(--sage);
  font-weight: 800;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.candidate-list {
  display: grid;
  gap: 12px;
}

.candidate {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 14px;
}

.candidate h3 {
  margin: 0 0 8px;
  color: var(--ink);
}

.candidate p {
  margin: 4px 0;
}

.candidate button {
  margin-top: 12px;
}

.field {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 12px;
  min-height: 76px;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.field strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.result-view {
  display: grid;
  gap: 18px;
}

.property-header {
  padding: 8px 0 2px;
}

.property-header h3 {
  margin: 0 0 14px;
  max-width: 760px;
  color: var(--ink);
  font-size: 1.65rem;
  line-height: 1.12;
}

.property-meta,
.provenance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.balance-card {
  border: 2px solid var(--mesa-dark);
  border-radius: 6px;
  background: #fff8ef;
  padding: 18px;
}

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

.summary-label,
.source-line {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.source-line {
  margin: -4px 0 10px;
}

.balance-card h3,
.result-block h3,
.provenance-strip h3,
.review-banner h3,
.warning-panel h3 {
  margin: 0 0 10px;
}

.balance-amount {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  color: var(--mesa-dark);
  font-size: 2.25rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.balance-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.result-block {
  min-width: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.9rem;
}

tbody tr:nth-child(even) {
  background: #fbf4eb;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.warning-panel,
.review-banner {
  border-radius: 6px;
  padding: 14px 16px;
}

.warning-panel {
  border-left: 5px solid var(--danger);
  background: #fff8f4;
}

.review-banner {
  border: 2px solid #6c5829;
  background: #fff6d9;
}

.warning-panel ul,
.review-banner ul {
  margin: 0;
  padding-left: 20px;
}

.review-banner p {
  margin-bottom: 10px;
  font-weight: 700;
}

.section-notice {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 14px;
  color: var(--muted);
  font-weight: 700;
}

.amount-cell,
.status-cell {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #7c6c5e;
  background: #f4eee6;
  color: var(--ink);
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.badge-warning {
  border-color: var(--danger);
  background: #ffe7dc;
  color: var(--danger);
}

.provenance-strip {
  border-top: 3px solid var(--sage);
  padding-top: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.provenance-strip p {
  margin-bottom: 12px;
  color: var(--ink);
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.packet-link {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  border: 2px solid var(--mesa);
  padding: 0 16px;
  color: var(--mesa-dark);
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 760px) {
  .topbar,
  .search-row,
  .api-row,
  .balance-grid,
  .property-meta,
  .provenance-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .account-records {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: block;
  }

  button,
  .packet-link {
    width: 100%;
    justify-content: center;
  }

  .property-header h3 {
    font-size: 1.35rem;
  }

  .balance-amount {
    font-size: 1.8rem;
  }
}

@media print {
  :root {
    --ink: #000000;
    --muted: #333333;
    --paper: #ffffff;
    --surface: #ffffff;
    --line: #8a8a8a;
  }

  html {
    font-size: 12pt;
  }

  body {
    background: #ffffff;
  }

  .shell {
    width: auto;
    padding: 0;
  }

  .topbar,
  .band {
    border-color: #000000;
  }

  .search-form,
  .api-row,
  #candidates-section,
  #job-section,
  .actions,
  .status-line {
    display: none !important;
  }

  #result-section {
    display: block;
    padding-top: 0;
  }

  #result-section[hidden] {
    display: none;
  }

  button,
  .packet-link {
    display: none;
  }

  .balance-card,
  .field,
  .table-wrap,
  .section-notice,
  .warning-panel,
  .review-banner {
    background: #ffffff;
    break-inside: avoid;
  }

  .result-block,
  .provenance-strip,
  .property-header {
    break-inside: avoid;
  }

  .table-wrap {
    overflow: visible;
  }
}
