/* =============================================================================
   Apex Lawyers — Document Verification Portal
   Design system / theme file.
   -----------------------------------------------------------------------------
   This is the ONLY file you should need to edit to change how the portal
   looks. index.php contains no visual rules — only semantic class names.
   Served same-origin (self), so it needs no CSP nonce and no CSP change.

   Direction: a verification-terminal / scanner aesthetic — dark by default,
   corner-bracket "scan target" framing, monospace for anything that is data
   (reference IDs, dates, status), a single restrained cyan accent used only
   for active/verified states so it still reads as trustworthy, not gimmicky.
   ============================================================================= */

/* ---- Tokens: dark (default) ------------------------------------------------- */
:root {
  color-scheme: dark;

  --bg: #05070C;
  --bg-mesh: #0A1220;
  --surface: #0C1220;
  --surface-2: #0F1728;
  --surface-inset: #080D18;
  --ink: #E8ECF7;
  --ink-muted: #8C97B3;
  --ink-faint: #5C6785;
  --border: rgba(140, 180, 255, .14);
  --border-strong: rgba(140, 180, 255, .28);

  --accent: #35E7C6;
  --accent-ink: #04211B;
  --accent-glow: rgba(53, 231, 198, .35);
  --accent-2: #5B8CFF;

  --focus: #5B8CFF;

  --success-bg: rgba(53, 231, 198, .10);
  --success-ink: #35E7C6;
  --success-border: rgba(53, 231, 198, .35);

  --warn-bg: rgba(255, 176, 32, .10);
  --warn-ink: #FFB020;
  --warn-border: rgba(255, 176, 32, .35);

  --error-bg: rgba(255, 84, 112, .10);
  --error-ink: #FF6B85;
  --error-border: rgba(255, 84, 112, .35);

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 4px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 24px 60px rgba(0, 0, 0, .6);
  --shadow-glow: 0 0 0 1px var(--border), 0 0 40px -12px var(--accent-glow);

  --font-display: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
}

/* ---- Tokens: light ------------------------------------------------------------ */
[data-theme="light"] {
  color-scheme: light;

  --bg: #F3F5FA;
  --bg-mesh: #E7EBF5;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --surface-inset: #EEF1F8;
  --ink: #0E1424;
  --ink-muted: #545E78;
  --ink-faint: #8791A8;
  --border: #DCE1EE;
  --border-strong: #C3CADF;

  --accent: #0E9C82;
  --accent-ink: #FFFFFF;
  --accent-glow: rgba(14, 156, 130, .25);
  --accent-2: #2E5FE0;

  --focus: #2E5FE0;

  --success-bg: #E6F7F2;
  --success-ink: #0E7A64;
  --success-border: #BFE9DC;

  --warn-bg: #FDF1DF;
  --warn-ink: #8A5A1F;
  --warn-border: #F0D6AC;

  --error-bg: #FDEBEE;
  --error-ink: #B02040;
  --error-border: #F3C6D1;

  --shadow-1: 0 1px 2px rgba(16, 20, 31, .05);
  --shadow-2: 0 20px 45px rgba(16, 20, 31, .10);
  --shadow-glow: 0 0 0 1px var(--border), 0 0 30px -14px var(--accent-glow);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #F3F5FA; --bg-mesh: #E7EBF5; --surface: #FFFFFF; --surface-2: #F7F9FC; --surface-inset: #EEF1F8;
    --ink: #0E1424; --ink-muted: #545E78; --ink-faint: #8791A8;
    --border: #DCE1EE; --border-strong: #C3CADF;
    --accent: #0E9C82; --accent-ink: #FFFFFF; --accent-glow: rgba(14, 156, 130, .25); --accent-2: #2E5FE0;
    --focus: #2E5FE0;
    --success-bg: #E6F7F2; --success-ink: #0E7A64; --success-border: #BFE9DC;
    --warn-bg: #FDF1DF; --warn-ink: #8A5A1F; --warn-border: #F0D6AC;
    --error-bg: #FDEBEE; --error-ink: #B02040; --error-border: #F3C6D1;
    --shadow-1: 0 1px 2px rgba(16,20,31,.05); --shadow-2: 0 20px 45px rgba(16,20,31,.10);
    --shadow-glow: 0 0 0 1px var(--border), 0 0 30px -14px var(--accent-glow);
  }
}

/* ---- Reset / base ----------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 15% -5%, var(--bg-mesh), transparent 60%),
    radial-gradient(700px 420px at 105% 20%, var(--bg-mesh), transparent 55%),
    var(--bg);
  transition: background-color .25s ease, color .25s ease;
  -webkit-font-smoothing: antialiased;
}

/* Fine circuit/ledger grid, low contrast, decorative only */
.grid-veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .6;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(1100px 650px at 50% 0%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(1100px 650px at 50% 0%, #000 0%, transparent 70%);
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---- Shell layout ------------------------------------------------------------ */
.shell {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.5rem) clamp(1rem, 4vw, 1.5rem) 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .25rem 0 clamp(1.5rem, 4vw, 2.25rem);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .4rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-logo {
  height: 34px;
  width: auto;
  flex: none;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
@media (min-width: 480px) {
  .brand-logo { height: 40px; }
}

/* ---- Theme toggle: futuristic sliding pill switch ---------------------------- */
.theme-toggle {
  position: relative;
  width: 64px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-inset);
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.theme-toggle:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.theme-toggle svg { width: 15px; height: 15px; position: relative; z-index: 1; flex: none; }
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { opacity: .55; transition: opacity .2s ease; }

/* Sliding knob */
.theme-toggle::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
[data-theme="light"] .theme-toggle::before { transform: translateX(30px); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle::before { transform: translateX(30px); }
}

[data-theme="dark"] .theme-toggle .icon-moon,
:root:not([data-theme]) .theme-toggle .icon-moon { opacity: .9; }
[data-theme="light"] .theme-toggle .icon-sun { opacity: .9; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle .icon-sun { opacity: .9; }
}

/* ---- Panel: scan-target framing ------------------------------------------------ */
.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2), var(--shadow-glow);
  overflow: hidden;
}

/* Corner brackets, like a viewfinder framing the panel */
.panel::before,
.panel::after,
.panel-body::before,
.panel-body::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--accent);
  border-style: solid;
  opacity: .8;
  z-index: 2;
  pointer-events: none;
}
.panel::before      { top: -1px; left: -1px;  border-width: 2px 0 0 2px; }
.panel::after        { top: -1px; right: -1px; border-width: 2px 2px 0 0; }
.panel-body::before  { bottom: -1px; left: -1px;  border-width: 0 0 2px 2px; }
.panel-body::after   { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

/* One deliberate scan-line sweep on load, not repeated */
.panel .scan-sweep {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  z-index: 3;
}
@media (prefers-reduced-motion: no-preference) {
  .panel .scan-sweep { animation: scan-sweep 1.6s ease-out .1s 1 both; }
}
@keyframes scan-sweep {
  0%   { top: 0; opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.panel-body {
  position: relative;
  padding: clamp(1.5rem, 4vw, 2.5rem);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--accent);
  margin-bottom: .8rem;
}
.eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

h1.title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.35rem, 2.4vw, 1.65rem);
  margin: 0 0 .5rem;
  color: var(--ink);
  margin-bottom: 3.5rem;
}

/* ---- Alerts ------------------------------------------------------------------ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: .9rem;
  line-height: 1.45;
  border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: .1rem; }
.alert-error { background: var(--error-bg); color: var(--error-ink); border-color: var(--error-border); }
.alert-success { background: var(--success-bg); color: var(--success-ink); border-color: var(--success-border); }

/* ---- Form: fields + submit in one row on desktop -----------------------------
   Mobile (default): each field is its own stacked row (label above input),
   then the cube button, then Turnstile — everything sorted into rows.
   Desktop (>=720px): Reference ID | Issue date | cube button share one row,
   each field still labeled above its own input, aligned along one baseline —
   matching the reference layout. */
.field {
  display: block;
  margin-bottom: 1.1rem;
}
.field-line .field { margin-bottom: 0; }

/* Mobile: date field + cube submit share one row instead of each stacking
   on its own full-width line. margin-top restores the gap after the
   Reference ID field above it, since .field-line .field { margin-bottom: 0 }
   (needed for desktop's flex row) would otherwise zero that space out here too. */
.field-line-actions {
  display: flex;
  align-items: flex-end;
  gap: .7rem;
  margin-top: 1.1rem;
}
.field-line-actions .field-date { flex: 1 1 auto; min-width: 0; }
.field-line-actions .submit-cube { flex: none; }

@media (min-width: 720px) {
  .field-line {
    display: flex;
    align-items: flex-end;
    gap: .9rem;
    margin-bottom: 1.1rem;
  }
  .field-line .field { flex: 1 1 auto; min-width: 0; }
  .field-line .field-date { flex: 0 0 200px; }
  .field-line .submit-cube { flex: none; }
  /* Dissolve the mobile-only wrapper so field-date and submit-cube become
     direct flex children of .field-line again, exactly as before. */
  .field-line-actions {
    display: contents;
  }
}

.field label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .03em;
  color: var(--ink-muted);
  margin-bottom: .5rem;
}
.field label::before { content: "// "; opacity: .55; color: var(--accent); }

.field-control { position: relative; min-width: 0; }

.field input[type="text"],
.field input[type="date"] {
  width: 100%;
  padding: .78rem .85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  background: var(--surface-inset);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field input[type="text"] {
  font-family: var(--font-mono);
  letter-spacing: .03em;
  text-transform: uppercase;
  padding-right: 3rem; /* room for the QR scan button inside the field */
  text-overflow: ellipsis;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

.field input::placeholder { color: var(--ink-faint); }

.hp-field { position: absolute; left: -9999px; top: -9999px; }

/* Visually hidden but still announced by screen readers */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.verify-result:empty { display: none; }
.verify-result > .alert:first-child,
.verify-result > .stamp-row:first-child { margin-top: 1.6rem; }
.verify-result > .result-wrap { margin-bottom: .25rem; }

/* QR scan-trigger, docked inside the reference-ID field */
.qr-trigger {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--accent);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.qr-trigger:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.qr-trigger svg { width: 18px; height: 18px; }
.qr-trigger[hidden] { display: none; }

/* ---- Turnstile: own centered row, decoupled from the submit control --------- */
.turnstile-row {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0 .5rem;
}
.turnstile-row .cf-turnstile { line-height: 0; }

/* Mobile only: visually shrink the widget (still Cloudflare's normal,
   horizontal layout — untouched on PC) via a CSS scale rather than
   switching to the "compact" size, which would change its shape entirely.
   The negative margin below folds the transform's leftover whitespace back
   in so it doesn't leave a gap where the full-size box used to be. */
@media (max-width: 560px) {
  .turnstile-row {
    transform: scale(.82);
    transform-origin: center;
    margin: 1.1rem 0 -0.4rem;
  }
}

/* ---- Submit: icon-only cube, not a text button, not a search bar ------------
   A distinct square block (width === height) with a faceted/beveled edge so
   it reads as a cube rather than a plain flat square, sitting beside the
   Reference ID input rather than fused into one continuous bar shape. */
.submit-cube {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(155deg, rgba(255,255,255,.16), transparent 40%),
    var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.25),
    inset 0 -2px 4px rgba(0,0,0,.18);
  transition: filter .15s ease, transform .1s ease, box-shadow .15s ease;
}
.submit-cube .btn-icon { width: 19px; height: 19px; flex: none; position: relative; z-index: 1; }
.submit-cube:hover { filter: brightness(1.08); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), inset 0 -2px 4px rgba(0,0,0,.18), 0 0 20px -5px var(--accent-glow); }
.submit-cube:active { transform: translateY(1px) scale(.97); }

/* Locked state: visually + functionally inert until Turnstile clears it */
.submit-cube:disabled {
  background: var(--surface-2);
  color: var(--ink-faint);
  border-color: var(--border-strong);
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
}
.submit-cube:disabled .btn-icon { opacity: .4; }

/* Armed: Turnstile has cleared the challenge — quiet confirmation pulse */
.submit-cube.is-armed { animation: armed-pulse .6s ease-out; }
@keyframes armed-pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  100% { box-shadow: 0 0 22px -4px var(--accent-glow); }
}

@media (max-width: 480px) {
  .submit-cube { width: 44px; height: 44px; }
  .submit-cube .btn-icon { width: 16px; height: 16px; }
}

/* ---- Result: futuristic data manifest ------------------------------------------ */
.result-wrap {
  margin-top: .25rem;
  position: relative;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--surface-2), var(--surface-inset)),
    repeating-linear-gradient(0deg, transparent 0 27px, var(--border) 27px 28px);
  background-blend-mode: normal, overlay;
  overflow: hidden;
  box-shadow: var(--shadow-glow);
}

/* thin animated data-rail along the top edge of the manifest */
.result-wrap::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-2), var(--accent), transparent);
  background-size: 200% 100%;
  z-index: 2;
}
@media (prefers-reduced-motion: no-preference) {
  .result-wrap::before { animation: rail-scan 3.2s linear infinite; }
}
@keyframes rail-scan {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.result-table {
  position: relative;
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.result-table, .result-table tbody { display: block; width: 100%; }

/* Each field: heading on its own line, the record directly beneath it. */
.result-table tr {
  display: block;
  position: relative;
  padding: .85rem 1.1rem .85rem 1.4rem;
  border-bottom: 1px solid var(--border);
  transition: background-color .15s ease;
}
.result-table tr:last-child { border-bottom: none; }
.result-table tr:hover { background: var(--surface-2); }

/* Left accent tick — lights up on hover, terminal-readout style */
.result-table tr::before {
  content: "";
  position: absolute;
  left: 0; top: .85rem; bottom: .85rem;
  width: 2px;
  background: var(--border-strong);
  transition: background-color .15s ease, box-shadow .15s ease;
}
.result-table tr:hover::before { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }

.result-table th, .result-table td {
  display: block;
  text-align: left;
  padding: 0;
  width: auto;
}
.result-table th {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: .3rem;
  opacity: .85;
}
.result-table th::before { content: "// "; opacity: .55; }
.result-table td {
  color: var(--ink);
  word-break: break-word;
  font-size: .98rem;
  line-height: 1.4;
}
.result-table td.mono { font-family: var(--font-mono); letter-spacing: .02em; }

/* Desktop: real <table> layout so every row shares ONE heading-column width,
   sized to fit the widest label (not each row computing its own width,
   which is what made the column edges zig-zag before). "width: 1%" together
   with white-space: nowrap on th is the standard shrink-to-fit trick for
   table-layout: auto — the browser still won't let the column go narrower
   than its widest single-line heading, so labels never wrap, but the column
   also never stretches past what the text actually needs.
   Mobile stays exactly as above — header row, then its data row, repeating. */
@media (min-width: 720px) {
  .result-table { display: table; }
  .result-table tbody { display: table-row-group; }

  .result-table tr { display: table-row; }
  .result-table tr::before { display: none; } /* replaced by th's border-left below */

  .result-table th, .result-table td {
    display: table-cell;
    vertical-align: baseline;
    padding: .85rem 0 .85rem 0;
    border-bottom: 1px solid var(--border);
  }
  .result-table tr:last-child th,
  .result-table tr:last-child td { border-bottom: none; }

  .result-table th {
    margin-bottom: 0;
    width: 1%;
    white-space: nowrap;
    padding-left: 1.4rem;
    padding-right: 1.6rem;
    border-left: 2px solid var(--border-strong); /* the accent tick, moved onto the cell so it stays aligned with the shared border-bottom */
    transition: border-color .15s ease, box-shadow .15s ease;
  }
  .result-table td { padding-right: 1.1rem; }
  .result-table tr:hover th { border-left-color: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .3rem .8rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.status-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.status-pill.is-good { background: var(--success-bg); color: var(--success-ink); border-color: var(--success-border); }
.status-pill.is-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-border); }

/* ---- Document links: single-line icon strip ------------------------------------ */
.doc-icons {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}
.doc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease, color .15s ease, transform .1s ease;
}
.doc-icon svg { width: 19px; height: 19px; }
.doc-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: translateY(-1px);
}
.doc-icon:active { transform: translateY(0); }
.doc-icon.is-doc { color: var(--accent); border-color: var(--success-border); }

/* ---- Status stamp: animated rubber-seal, centered hero of the result box -------
   A row matching at all is what "verified" means on this portal — the seal
   always reads VERIFIED in the success color. The record's own case-progress
   state (In process, Resolved, ...) is a separate concern and is shown by
   the status pill inside the table below, not by this seal. */
.stamp-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .6rem;
  width: -webkit-max-content;
  width: -moz-max-content;
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1.25rem;
  padding: 1.5rem 2.2rem;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}

/* soft radial flash behind the seal on arrival */
.stamp-row::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .stamp-row::before { animation: seal-flash .7s ease-out .05s both; }
}
@keyframes seal-flash {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: .9; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

.status-stamp {
  flex: none;
  width: 84px;
  height: 84px;
  overflow: visible;
  color: var(--success-ink);
  filter: drop-shadow(0 0 10px var(--accent-glow));
}

/* toothed/coined outer edge + solid inner ring */
.stamp-edge {
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-dasharray: 2.6 3;
  stroke-linecap: round;
  opacity: .85;
  transform-origin: 50% 50%;
}
.stamp-ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  transform-origin: 50% 50%;
}

/* curved status word, top arc and bottom arc */
.stamp-arc-text {
  fill: currentColor;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 8.4px;
  letter-spacing: .5px;
}

/* small flanking stars, either side of the seal */
.stamp-star { fill: currentColor; opacity: .9; }

/* center banner: two rules sandwiching the bold status word */
.stamp-band-line { stroke: currentColor; stroke-width: 2; }
.stamp-band-text {
  fill: currentColor;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 10.5px;
}

@media (prefers-reduced-motion: no-preference) {
  .status-stamp {
    animation: stamp-impact .5s cubic-bezier(.2, .9, .25, 1.15) both;
  }
  .stamp-edge {
    animation: ring-spin 22s linear infinite, ring-fade .3s ease .1s both;
  }
  .stamp-ring {
    stroke-dasharray: 260;
    stroke-dashoffset: 260;
    animation: ring-draw .6s ease-out .1s both;
  }
  .stamp-arc-text { animation: ring-fade .3s ease .3s both; }
  .stamp-star {
    transform: scale(0);
    transform-box: fill-box;
    transform-origin: center;
    animation: star-pop .3s ease-out .45s both;
  }
  .stamp-star:last-of-type { animation-delay: .52s; }
  .stamp-band-line {
    stroke-dasharray: 62;
    stroke-dashoffset: 62;
    animation: band-draw .3s ease-out .35s both;
  }
  .stamp-band-text { animation: ring-fade .25s ease .55s both; }
}
/* Reduced motion: everything present in its final, fully-drawn state */
@media (prefers-reduced-motion: reduce) {
  .stamp-ring, .stamp-band-line { stroke-dasharray: none; }
}

@keyframes stamp-impact {
  0%   { opacity: 0; transform: scale(1.6) rotate(-14deg); }
  60%  { opacity: 1; transform: scale(.94) rotate(3deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
@keyframes ring-draw { to { stroke-dashoffset: 0; } }
@keyframes ring-spin { to { transform: rotate(360deg); } }
@keyframes ring-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes band-draw { to { stroke-dashoffset: 0; } }
@keyframes star-pop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ---- QR scan modal --------------------------------------------------------------- */
.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(3, 5, 10, .78);
  backdrop-filter: blur(6px);
}
.qr-modal[hidden] { display: none; }

.qr-modal-panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2), var(--shadow-glow);
  padding: 1.25rem;
}

.qr-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .9rem;
}
.qr-modal-head h2 {
  font-family: var(--font-mono);
  font-size: .85rem;
  letter-spacing: .03em;
  color: var(--ink-muted);
  margin: 0;
}

.qr-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.qr-close:hover { border-color: var(--accent); }
.qr-close svg { width: 16px; height: 16px; }

.qr-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}
.qr-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.qr-frame {
  position: absolute;
  inset: 10%;
  pointer-events: none;
}
.qr-frame::before, .qr-frame::after,
.qr-frame span::before, .qr-frame span::after {
  content: "";
  position: absolute;
  width: 26px; height: 26px;
  border-color: var(--accent);
  border-style: solid;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}
.qr-frame::before { top: 0; left: 0; border-width: 3px 0 0 3px; }
.qr-frame::after   { top: 0; right: 0; border-width: 3px 3px 0 0; }
.qr-frame span::before { bottom: 0; left: 0; border-width: 0 0 3px 3px; }
.qr-frame span::after  { bottom: 0; right: 0; border-width: 0 3px 3px 0; }

.qr-status {
  margin-top: .9rem;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--ink-muted);
  text-align: center;
  min-height: 1.2em;
}
.qr-status.is-error { color: var(--error-ink); }
.qr-status.is-good { color: var(--success-ink); }

.qr-cancel {
  width: 100%;
  margin-top: .9rem;
  padding: .65rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: .88rem;
  cursor: pointer;
}
.qr-cancel:hover { border-color: var(--accent); }

/* ---- Footer -------------------------------------------------------------------- */
.foot-note {
  text-align: center;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--ink-faint);
  margin-top: 1.75rem;
  line-height: 1.7;
  letter-spacing: .01em;
}
.foot-note .lock {
  display: inline-flex;
  vertical-align: -3px;
  width: 13px;
  height: 13px;
  margin-right: .3rem;
}

/* ---- Responsive ------------------------------------------------------------------ */
@media (max-width: 560px) {
  .result-table tr { padding: .8rem 1rem .8rem 1.2rem; }
  .doc-icon { width: 44px; height: 44px; } /* keep touch targets comfortable on phones */
}

@media (max-width: 400px) {
  .field input[type="text"] { letter-spacing: .01em; font-size: .86rem; }
}
