:root {
  --bg: #030405;
  --bg-panel: #0b1113;
  --bg-panel-alt: #104b55;
  --navy: #12203f;
  --cyan: #6fe0ed;
  --ink: #f4f5f5;
  --muted: #a7b0b0;
  --border: rgba(244, 245, 245, 0.12);
  --border-soft: rgba(244, 245, 245, 0.08);
  --danger: #ff8a8a;
  --amber: #f6a15c;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--muted);
  background:
    radial-gradient(circle at 15% -10%, rgba(111, 224, 237, 0.08), transparent 45%),
    var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.brand:hover {
  opacity: 0.85;
}

.brand-seal {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.brand-text strong {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 800;
  color: var(--ink);
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.brand-text span {
  font-size: 0.78rem;
  color: var(--muted);
}

.panel {
  background: rgba(244, 245, 245, 0.03);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem 1.75rem 1.75rem;
}

h1 {
  margin: 0 0 0.35rem;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 800;
  color: var(--ink);
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.beta-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.5rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: default;
}

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

.beta-notice {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.beta-notice a {
  color: var(--cyan);
}

.acronym-key {
  margin: 0 0 1.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.85;
}

.acronym-key strong {
  color: var(--ink);
}

.guide-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  text-decoration: none;
}

.guide-trigger:hover { text-decoration: underline; }

.guide-trigger svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.prefill-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0 0 1.25rem;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius);
  border: 1px solid rgba(246, 161, 92, 0.4);
  background: rgba(246, 161, 92, 0.1);
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.5;
  animation: prefill-alert-pulse 1.4s ease-out 2;
}

.prefill-alert[hidden] { display: none; }

.prefill-alert-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: var(--amber);
}

@keyframes prefill-alert-pulse {
  0%, 100% { border-color: rgba(246, 161, 92, 0.4); }
  50% { border-color: rgba(246, 161, 92, 0.9); }
}

.field-row.is-highlighted input {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(246, 161, 92, 0.2);
}

form { display: flex; flex-direction: column; gap: 1rem; }
form[hidden] { display: none; }

.option-groups {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 1rem;
}

/* Arriving via a QR scan (?guin=) puts the relevant block - Document
   Number + GUIN/RIDN - first, right after the prefill alert, instead of
   after the (collapsed, irrelevant) GUIN/RIDN + Name block. Matters most
   on mobile, where the alert is at the top of the page and the form
   would otherwise still require a scroll past the other block first. */
.option-groups.qr-priority #block-b { order: -1; }
.option-groups.qr-priority #block-a { order: 1; }

.option-block {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 0;
  transition: border-color 0.2s ease;
}

.option-block[open] {
  padding-bottom: 1rem;
}

.option-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
  cursor: pointer;
  list-style: none;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.option-block summary::-webkit-details-marker { display: none; }

.option-block summary::after {
  content: '+';
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
  flex-shrink: 0;
}

.option-block[open] summary::after { content: '\2212'; }

.option-block.is-prominent {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(246, 161, 92, 0.15);
}

.option-block fieldset {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.75rem 0 0;
  padding: 0;
  border: 0;
}

.inline-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.inline-fields .field-row {
  flex: 1 1 150px;
  min-width: 0;
}

.field-row-full {
  width: 100%;
}

.or-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  align-self: stretch;
  min-height: 2.4rem;
}

.or-divider::before,
.or-divider::after {
  content: '';
  width: 1px;
  flex: 1;
  min-height: 0.5rem;
  background: var(--border);
}

.field-row { display: flex; flex-direction: column; gap: 0.3rem; }

.field-hint {
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.8;
}

label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}

label .optional {
  font-weight: 500;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
}

select,
input[type='text'] {
  appearance: none;
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--ink);
  background: rgba(244, 245, 245, 0.04);
  border: 1px solid var(--border);
  text-transform: uppercase;
  border-radius: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

select:disabled,
input[type='text']:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

select:focus,
input[type='text']:focus {
  outline: none;
  border-color: var(--cyan);
  background: rgba(244, 245, 245, 0.06);
}

/* Native <select> popups follow the OS/browser theme, not page CSS, unless
   told otherwise - without this the dropdown panel renders white-on-white. */
select {
  color-scheme: dark;
}

select option {
  color: var(--ink);
  background: var(--bg-panel);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a7b0b0' stroke-width='1.5' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.2rem;
}

.terms-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.terms-row input[type='checkbox'] {
  margin-top: 0.15rem;
  width: 16px;
  height: 16px;
  accent-color: var(--cyan);
  flex-shrink: 0;
  cursor: pointer;
}

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--cyan);
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-btn:hover { color: var(--ink); }

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

button[type='submit'] {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.1rem;
  padding: 0.65rem 1.4rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: #001417;
  background: var(--cyan);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button[type='submit']:hover { transform: translateY(-1px); }
button[type='submit']:active { transform: translateY(0); }
button[type='submit']:disabled { opacity: 0.6; cursor: progress; transform: none; }

.btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

#clear-btn {
  margin-top: 0.1rem;
  padding: 0.65rem 1.2rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

#clear-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.search-summary[hidden] { display: none; }

.search-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(244, 245, 245, 0.03);
  font-size: 0.85rem;
  color: var(--muted);
}

.search-summary strong { color: var(--ink); }

.search-summary button {
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.search-summary button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.result {
  margin-top: 1.25rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(244, 245, 245, 0.03);
  font-size: 0.9rem;
}

.result.is-error {
  border-color: rgba(255, 138, 138, 0.35);
  background: rgba(255, 138, 138, 0.06);
  color: var(--danger);
}

.result.is-ok {
  border-color: rgba(111, 224, 237, 0.35);
  background: rgba(111, 224, 237, 0.06);
  color: var(--ink);
}

.result pre {
  margin: 0.6rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  max-height: 60vh;
  overflow-y: auto;
}

.record-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
}

.status-badge {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-valid {
  color: #0a3a2a;
  background: #6fedb0;
}

.status-invalid {
  color: #3a0a0a;
  background: #ed6f6f;
}


.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.8rem 1.25rem;
}

.field-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.field-item-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-item-value {
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 500;
}

.foot {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.7;
}

.foot-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.foot-links a,
.foot-links .link-btn {
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 1;
}

.foot-links a {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.foot-links a:hover,
.foot-links .link-btn:hover { color: var(--ink); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(3, 4, 5, 0.75);
  backdrop-filter: blur(2px);
}

.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid var(--border-soft);
}

.modal-header h2 {
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 800;
  color: var(--ink);
  font-size: 1.1rem;
}

.modal-close {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--ink);
  background: rgba(244, 245, 245, 0.06);
}

.modal-body {
  padding: 1.3rem;
  overflow-y: auto;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.65;
}

.modal-body p:first-child { margin-top: 0; }
.modal-body p:last-child { margin-bottom: 0; }

.guide-modal { max-width: 820px; }

.guide-toggle {
  display: flex;
  gap: 0.5rem;
  padding: 0.9rem 1.3rem 0;
}

.guide-toggle-btn {
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.guide-toggle-btn.is-active {
  border-color: var(--cyan);
  color: var(--ink);
  background: rgba(111, 224, 237, 0.1);
}

.guide-body { font-size: 0.9rem; }

.guide-section { margin-bottom: 1.75rem; }
.guide-section:last-child { margin-bottom: 0; }

.guide-section h3 {
  margin: 0 0 0.4rem;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-size: 0.98rem;
  color: var(--ink);
}

.guide-section p { margin: 0 0 0.75rem; }

.guide-section img {
  display: block;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.guide-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.guide-pair img { flex: 1 1 280px; width: auto; min-width: 0; }

@media (max-width: 720px) {
  .option-groups {
    grid-template-columns: 1fr;
  }
  .or-divider {
    flex-direction: row;
    padding-top: 0;
  }
  .or-divider::before,
  .or-divider::after {
    width: auto;
    height: 1px;
    min-height: 0;
    min-width: 0.5rem;
  }
}

@media (max-width: 420px) {
  .panel { padding: 1.25rem 1.1rem; }
  .search-summary { flex-direction: column; align-items: flex-start; }
}
