:root {
  color-scheme: light;
  --ink: #14243a;
  --muted: #52657b;
  --paper: #f7f9fc;
  --field: #e7edf4;
  --rule: #aebac8;
  --rule-dark: #667a91;
  --cobalt: #164fd6;
  --cobalt-dark: #103ba2;
  --green: #12664f;
  --green-wash: #dcefe8;
  --red: #9c2e37;
  --red-wash: #f5dfe2;
  --amber: #805700;
  --amber-wash: #f5eac8;
  --radius: 12px;
  --font-display: Charter, "Bitstream Charter", "Sitka Text", Cambria, serif;
  font-family: "Aptos", "Segoe UI", Helvetica, Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--field); color: var(--ink); }
body { margin: 0; min-height: 100vh; }
a { color: var(--cobalt-dark); text-underline-offset: .2em; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #f0a620; outline-offset: 3px; }

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: #11223a;
}

.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 0 48%, rgba(82, 126, 180, .17) 48% 49%, transparent 49% 100%);
}

.login-sheet { width: min(100%, 560px); position: relative; }
.login-ledger, .error-sheet {
  background: var(--paper);
  border-top: 7px solid var(--cobalt);
  border-radius: 2px 2px var(--radius) var(--radius);
  box-shadow: 0 22px 70px rgba(2, 12, 26, .34);
  padding: clamp(28px, 7vw, 58px);
}

.wordmark { color: inherit; display: inline-grid; line-height: 1; text-decoration: none; }
.wordmark span { color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.wordmark strong { font-family: var(--font-display); font-size: 1.55rem; letter-spacing: -.025em; }
.login-rule, .guide-words { border-bottom: 1px solid var(--rule-dark); display: flex; justify-content: space-between; margin-top: 32px; padding-bottom: 7px; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.login-ledger h1, .error-sheet h1 { font-family: var(--font-display); font-size: clamp(2.5rem, 8vw, 4.8rem); font-weight: 500; letter-spacing: -.035em; line-height: .98; margin: 52px 0 18px; }
.login-copy { color: var(--muted); font-size: 1.05rem; line-height: 1.6; max-width: 46ch; }
.login-error { background: var(--red-wash); border: 1px solid #d19aa0; border-radius: 8px; color: #72212a; margin: 24px 0; padding: 12px 14px; }
.login-form { display: grid; gap: 9px; margin-top: 34px; }
.login-form label { color: var(--muted); font-size: .77rem; font-weight: 750; letter-spacing: .05em; margin-top: 12px; text-transform: uppercase; }
.login-form input { background: white; border: 1px solid var(--rule-dark); border-radius: 6px; color: var(--ink); padding: 13px 14px; }
.login-form button, .filters button {
  align-items: center;
  background: var(--cobalt);
  border: 0;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: flex;
  font-weight: 750;
  justify-content: space-between;
  margin-top: 22px;
  padding: 14px 16px;
}
.login-form button:hover, .filters button:hover { background: var(--cobalt-dark); }
.security-note { border-top: 1px solid var(--rule); color: var(--muted); font-size: .78rem; line-height: 1.5; margin: 34px 0 0; padding-top: 18px; }

.admin-page { background: var(--paper); }
.masthead { align-items: center; background: var(--ink); color: white; display: grid; gap: 30px; grid-template-columns: 210px 1fr auto; min-height: 82px; padding: 17px clamp(20px, 4vw, 64px); }
.masthead .wordmark span { color: #9fb0c4; }
.masthead .guide-words { border-color: #52677f; color: #b9c6d4; margin: 0; }
.text-button { align-items: center; background: transparent; border: 0; color: white; cursor: pointer; display: inline-flex; font-size: .82rem; font-weight: 700; min-height: 44px; padding: 8px 0; text-decoration: underline; text-underline-offset: .25em; }
.admin-page main { margin: 0 auto; max-width: 1680px; padding: 0 clamp(20px, 4vw, 64px) 80px; }
.health-rule { align-items: center; border-bottom: 1px solid var(--rule-dark); display: flex; justify-content: space-between; min-height: 72px; }
.health-rule > div, .health-actions { align-items: center; display: flex; gap: 18px; }
.health-components { align-items: center; display: inline-flex; flex-wrap: wrap; gap: 14px; }
.health-components .status-mark { color: var(--muted); font-size: .65rem; }
.health-components .status-mark.accepted { color: var(--green); }
.health-components .status-mark.failed { color: var(--red); }
.auto-refresh { color: var(--muted); font-size: .78rem; }
.status-mark { align-items: center; display: inline-flex; font-size: .72rem; font-weight: 800; gap: 7px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.status-mark::before { background: currentColor; border-radius: 50%; content: ""; height: 7px; width: 7px; }
.status-mark.accepted { color: var(--green); }
.status-mark.failed { color: var(--red); }
.status-mark.pending { color: var(--amber); }
.status-mark.duplicate, .status-mark.muted { color: var(--muted); }
.register-head { align-items: end; display: grid; gap: 42px; grid-template-columns: minmax(280px, 1fr) auto; padding: 54px 0 28px; }
h1, h2 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.025em; }
.register-head h1 { font-size: clamp(2.4rem, 4.8vw, 5.2rem); line-height: .95; margin: 0 0 18px; }
.register-head p, .section-title p, .payload-section p, .detail-title p { color: var(--muted); line-height: 1.55; margin: 0; max-width: 72ch; }
.page-totals { border-bottom: 1px solid var(--rule-dark); border-top: 1px solid var(--rule-dark); display: grid; grid-template-columns: repeat(4, minmax(90px, 1fr)); margin: 0; min-width: 500px; }
.page-totals div { padding: 12px 18px; }
.page-totals div + div { border-left: 1px solid var(--rule); }
.page-totals dt { color: var(--muted); font-size: .68rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.page-totals dd { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 1.02rem; font-variant-numeric: tabular-nums; margin: 7px 0 0; }
.filters { align-items: end; background: var(--field); border-bottom: 1px solid var(--rule-dark); border-top: 1px solid var(--rule-dark); display: grid; gap: 1px; grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.5fr) 180px 95px auto auto; margin-bottom: 18px; }
.filters label { color: var(--muted); display: grid; font-size: .68rem; font-weight: 750; gap: 7px; letter-spacing: .05em; padding: 11px 13px; text-transform: uppercase; }
.filters input, .filters select { background: transparent; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; color: var(--ink); min-width: 0; padding: 6px 0; }
.filters button { align-self: stretch; border-radius: 0; justify-content: center; margin: 0; min-height: 63px; }
.clear-filter { align-self: center; font-size: .78rem; padding: 14px; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { border-bottom: 1px solid var(--rule-dark); color: var(--muted); font-size: .67rem; font-weight: 800; letter-spacing: .055em; padding: 10px 12px; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { border-bottom: 1px solid #ccd5df; font-size: .82rem; padding: 13px 12px; vertical-align: middle; }
tbody tr { background: linear-gradient(90deg, rgba(22, 79, 214, .05), transparent 18%) no-repeat -40vw 0 / 40vw 100%; transition: background-position .35s cubic-bezier(.16, 1, .3, 1); }
tbody tr:hover { background-position: 0 0; }
td code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .76rem; }
.number { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.route { border: 1px solid var(--rule); border-radius: 4px; font-size: .65rem; font-weight: 800; letter-spacing: .05em; padding: 3px 5px; }
.row-action { text-align: right; }
.row-action a { align-items: center; display: inline-flex; font-weight: 750; min-height: 44px; }
.empty-register { color: var(--muted); padding: 72px 20px; text-align: center; }
.pagination { align-items: center; border-bottom: 1px solid var(--rule-dark); display: flex; justify-content: space-between; min-height: 72px; }
.page-next { font-weight: 750; }
.page-disabled { color: var(--muted); font-size: .82rem; }
.accounts { padding-top: 72px; }
.section-title { align-items: end; display: flex; justify-content: space-between; padding-bottom: 20px; }
.section-title h2, .error-register h2, .payload-section h2 { font-size: clamp(1.8rem, 3vw, 3rem); margin: 0 0 8px; }
.cell-note { color: var(--muted); display: block; font-size: .7rem; margin-top: 3px; }
.truncate { display: block; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
footer { background: var(--field); border-top: 1px solid var(--rule-dark); color: var(--muted); display: flex; font-size: .72rem; justify-content: space-between; padding: 22px clamp(20px, 4vw, 64px); }

.detail-main { max-width: 1280px !important; }
.detail-title { align-items: end; border-bottom: 1px solid var(--rule-dark); display: flex; justify-content: space-between; padding: 54px 0 26px; }
.detail-title h1 { font-size: clamp(2.5rem, 5vw, 5.4rem); line-height: .95; margin: 0 0 10px; }
.evidence-grid { display: grid; grid-template-columns: 1fr 1fr; }
.evidence-grid > dl { margin: 0; }
.evidence-grid > dl + dl { border-left: 1px solid var(--rule-dark); }
.evidence-grid dl div, .error-register dl div { border-bottom: 1px solid var(--rule); display: grid; gap: 20px; grid-template-columns: 150px 1fr; min-height: 54px; padding: 15px 18px; }
dt { color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
dd { margin: 0; overflow-wrap: anywhere; }
.signature-plate { align-items: center; background: var(--cobalt); color: white; display: flex; justify-content: space-between; margin: 48px 0; padding: 28px 30px; }
.signature-plate span { display: block; font-size: .68rem; font-weight: 800; letter-spacing: .06em; margin-bottom: 10px; text-transform: uppercase; }
.signature-plate code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; }
.plate-actions { align-items: center; display: flex; gap: 18px; margin-left: 30px; white-space: nowrap; }
.plate-actions button, .payload-box button, .reveal-payload { align-items: center; background: white; border: 0; border-radius: 5px; color: var(--cobalt-dark); cursor: pointer; display: inline-flex; font-weight: 750; min-height: 44px; padding: 10px 12px; text-decoration: none; }
.external-link { align-items: center; color: white; display: inline-flex; min-height: 44px; }
.error-register { margin-top: 62px; }
.error-register dl { border-top: 1px solid var(--rule-dark); margin: 20px 0 0; }
.payload-section { align-items: start; border-top: 1px solid var(--rule-dark); display: grid; gap: 60px; grid-template-columns: minmax(250px, .75fr) 1.5fr; margin-top: 72px; padding-top: 28px; }
.reveal-payload { background: var(--ink); color: white; display: inline-block; }
.payload-warning { background: var(--amber-wash); border: 1px solid #c6aa63; border-radius: 8px; color: #674700; display: grid; gap: 5px; margin-bottom: 12px; padding: 13px 14px; }
.payload-warning span { font-size: .82rem; }
.payload-box { position: relative; }
.payload-box button { position: absolute; right: 10px; top: 10px; }
.payload-box textarea { background: #0e1c30; border: 0; border-radius: 8px; color: #dfe8f3; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .75rem; line-height: 1.55; min-height: 280px; padding: 58px 16px 16px; resize: vertical; width: 100%; }
.error-sheet { width: min(100%, 650px); }
.error-sheet p { color: var(--muted); line-height: 1.55; }
.visually-hidden { height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 980px) {
  .masthead { grid-template-columns: 1fr auto; }
  .masthead .guide-words { display: none; }
  .register-head { align-items: start; grid-template-columns: 1fr; }
  .page-totals { min-width: 0; width: 100%; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters button { min-height: 54px; }
  .evidence-grid { grid-template-columns: 1fr; }
  .evidence-grid > dl + dl { border-left: 0; }
  .payload-section { gap: 30px; grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .login-page { padding: 0; }
  .login-ledger, .error-sheet { border-radius: 0; min-height: 100vh; padding: 30px 22px; }
  .masthead { min-height: 70px; padding: 13px 18px; }
  .masthead .wordmark strong { font-size: 1.25rem; }
  .admin-page main { padding-left: 16px; padding-right: 16px; }
  .health-rule { align-items: flex-start; flex-direction: column; gap: 10px; padding: 15px 0; }
  .health-rule > div { align-items: flex-start; flex-direction: column; gap: 9px; }
  .health-components { gap: 8px 13px; }
  .auto-refresh { display: none; }
  .register-head { gap: 24px; padding-top: 36px; }
  .page-totals { grid-template-columns: 1fr 1fr; }
  .page-totals div:nth-child(3) { border-left: 0; border-top: 1px solid var(--rule); }
  .page-totals div:nth-child(4) { border-top: 1px solid var(--rule); }
  .filters { grid-template-columns: 1fr; }
  .filters label { border-bottom: 1px solid var(--rule); }
  .request-table thead, .account-table thead { display: none; }
  .request-table, .request-table tbody, .request-table tr, .request-table td,
  .account-table, .account-table tbody, .account-table tr, .account-table td { display: block; width: 100%; }
  .request-table tr, .account-table tr { border-bottom: 1px solid var(--rule-dark); padding: 13px 0; }
  .request-table td, .account-table td { align-items: baseline; border: 0; display: grid; gap: 16px; grid-template-columns: 92px 1fr; padding: 6px 4px; }
  td::before { color: var(--muted); content: attr(data-label); font-size: .66rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
  .row-action { display: block !important; padding-top: 13px !important; text-align: left; }
  .row-action::before { content: none; }
  .section-title { align-items: start; gap: 20px; }
  .signature-plate { align-items: flex-start; gap: 22px; flex-direction: column; margin: 32px 0; padding: 22px 18px; }
  .plate-actions { margin: 0; }
  .evidence-grid dl div, .error-register dl div { grid-template-columns: 105px 1fr; padding-left: 4px; padding-right: 4px; }
  footer { gap: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}