:root {
  --bg: #0c0d0e;
  --bg-elevated: #17181a;
  --bg-inset: #090a0a;
  --bg-raised: var(--bg-elevated);
  --paper: #ece6d8;
  --paper-dim: #a39c8d;
  --ink: #ece6d8;
  --ink-soft: #a39c8d;
  --ink-faint: #6e6858;
  --gold: #c9a44c;
  --gold-bright: #e3c374;
  --oxblood: #b4483a;
  --oxblood-bright: #d1614f;
  --line: #2b2b28;
  --line-bright: #423f38;
  --rule: var(--line);
  --rule-strong: var(--line-bright);
  --accent: var(--gold);
  --accent-soft: rgba(201, 164, 76, 0.14);
  --accent-ink: #1a1509;
  --good: #8fbf8f;
  --good-soft: rgba(143, 191, 143, 0.12);
  --warn: var(--gold-bright);
  --warn-soft: rgba(201, 164, 76, 0.12);
  --risk: var(--oxblood-bright);
  --risk-soft: rgba(180, 72, 58, 0.12);
  --serif: "Fraunces", "Iowan Old Style", serif;
  --sans: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); scrollbar-gutter: stable; }
body {
  background: var(--bg);
  color: var(--paper);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
}
.hidden { display: none !important; }
input, textarea, button { font-family: inherit; font-size: inherit; }
a { color: var(--gold); }

/* Subtle paper-grain overlay — matches the internal tool's "case file"
   texture, replacing the old light-theme corner watermark (which had
   no equivalent on a dark background). */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- auth views ---------- */
.view-auth {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.25rem;
  position: relative; z-index: 1;
  overflow: hidden;
}
.auth-glow {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 640px 480px at 50% 40%, rgba(201, 164, 76, 0.16), transparent 70%);
  animation: glow-pulse 7s ease-in-out infinite alternate;
}
@keyframes glow-pulse {
  0% { opacity: 0.7; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.08); }
}
@keyframes fade-up {
  0% { opacity: 0; transform: translateY(20px); filter: blur(4px); }
  100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}
.animate-fade-up { opacity: 0; animation: fade-up 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@media (prefers-reduced-motion: reduce) {
  .auth-glow { animation: none; }
  .animate-fade-up { opacity: 1; animation: none; }
}
.auth-card {
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 2.75rem 2.5rem 2.5rem;
  max-width: 400px; width: 100%;
  box-shadow: 0 1px 2px rgba(29,33,41,0.04), 0 12px 32px -12px rgba(29,33,41,0.18);
  position: relative; z-index: 1;
}
.auth-card::before {
  content: ""; position: absolute; inset: 8px;
  border: 1px solid var(--rule); border-radius: 2px; pointer-events: none;
}
.auth-card-wide { max-width: 460px; }
.auth-mark { text-align: center; margin-bottom: 1.1rem; }
.auth-mark-glyph {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--accent); color: var(--accent);
  font-family: var(--serif); font-size: 1.4rem; font-weight: 600;
}
.auth-kicker {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); text-align: center; margin-bottom: 0.6rem;
}
.auth-title {
  font-family: var(--serif); font-weight: 600; font-size: 1.9rem; text-align: center;
  margin: 0 0 0.4rem; color: var(--ink); text-wrap: balance;
}
.auth-sub {
  text-align: center; color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 1.75rem; text-wrap: pretty;
}

.auth-form { display: flex; flex-direction: column; gap: 1.1rem; }
.auth-form label, .request-form label {
  display: flex; flex-direction: column; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em; color: var(--ink-soft);
}
.hint { font-weight: 400; color: var(--ink-faint); text-transform: none; letter-spacing: 0; }
input[type="text"], input[type="email"], input[type="password"], textarea {
  font-family: var(--sans); font-size: 0.95rem; color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 4px;
  padding: 0.65rem 0.75rem; background: var(--bg-raised);
  transition: border-color 0.15s ease;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; font-family: var(--sans); }

.field-invalid { border-color: var(--risk) !important; }
.field-invalid:focus { box-shadow: 0 0 0 3px var(--risk-soft); }

.pw-field { position: relative; }
.pw-field input { padding-right: 2.5rem; width: 100%; }
.pw-toggle {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 0.3rem; cursor: pointer;
  color: var(--ink-faint); display: flex; align-items: center; justify-content: center;
  border-radius: 3px; transition: color 0.15s ease;
}
.pw-toggle:hover { color: var(--accent); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw-toggle svg { width: 18px; height: 18px; display: block; }

.btn-primary {
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 4px;
  padding: 0.75rem 1.25rem; font-weight: 600; font-size: 0.92rem; cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn-primary:hover { background: var(--gold-bright); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.link-btn {
  display: block; margin: 1.4rem auto 0; background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 0.84rem; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn-light { color: var(--ink-faint); }

.form-error {
  background: var(--risk-soft); color: var(--risk); border-left: 3px solid var(--risk);
  padding: 0.6rem 0.8rem; border-radius: 3px; font-size: 0.84rem;
}
.form-success {
  background: var(--good-soft); color: var(--good); border-left: 3px solid var(--good);
  padding: 0.6rem 0.8rem; border-radius: 3px; font-size: 0.84rem;
}

.terms-box {
  border: 1px solid var(--rule); border-radius: 4px; background: var(--bg);
}
.terms-label {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); padding: 0.6rem 0.9rem 0;
}
.terms-content {
  max-height: 180px; overflow-y: auto; padding: 0.5rem 0.9rem 0.9rem;
  font-size: 0.82rem; color: var(--ink-soft); white-space: pre-wrap; line-height: 1.55;
}
.checkbox-row {
  flex-direction: row !important; align-items: flex-start; gap: 0.55rem !important;
  font-weight: 500 !important; color: var(--ink) !important;
}
.checkbox-row input { margin-top: 0.2rem; }

/* ---------- dashboard ---------- */
.masthead {
  border-bottom: 1px solid var(--line);
  background: radial-gradient(ellipse 900px 300px at 15% -20%, rgba(201, 164, 76, 0.08), transparent);
  position: relative; z-index: 1;
}
.masthead-inner {
  max-width: 1100px; margin: 0 auto; padding: 28px 32px 24px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.wordmark-kicker {
  display: block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 10px;
}
.wordmark h1 { font-family: var(--serif); font-size: 34px; font-weight: 500; letter-spacing: -0.01em; margin: 0; color: var(--paper); }
.wordmark-em { font-style: normal; font-weight: 600; color: var(--paper); }
.masthead-side { display: flex; align-items: center; gap: 20px; padding-bottom: 6px; }
.masthead-meta { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.masthead .link-btn {
  margin: 0; display: inline; font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  color: var(--paper-dim); text-decoration: none; border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 1px; transition: color 0.15s ease, border-color 0.15s ease;
}
.masthead .link-btn:hover { color: var(--gold-bright); border-color: var(--gold); }

.stage { max-width: 1100px; margin: 0 auto; padding: 2.75rem 32px 4rem; position: relative; z-index: 1; }

.panel { margin-bottom: 3rem; }
.panel-label {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 0.5rem;
}
.panel-title {
  font-family: var(--serif); font-weight: 600; font-size: 1.5rem; margin: 0 0 1.25rem; color: var(--ink);
}

.panel-guide {
  background: var(--accent-soft); border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 1.1rem 1.5rem;
}
.guide-callout { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; flex-wrap: wrap; margin: 0; color: var(--paper); font-size: 0.94rem; }
.guide-callout .btn-primary { white-space: nowrap; }

.panel-new {
  background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 6px;
  padding: 1.75rem 2rem 2rem;
}
.request-form { display: flex; flex-direction: column; gap: 1.1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.request-form input, .request-form textarea { max-width: none; }
.panel-new .btn-primary { align-self: flex-start; }

/* Registry — each request reads like a case-file entry: monospace
   reference number, a status "stamp" rather than a flat colored word. */
.registry-empty {
  color: var(--ink-faint); font-size: 0.9rem; border: 1px dashed var(--rule-strong);
  border-radius: 6px; padding: 2rem; text-align: center;
}
.registry-list { display: flex; flex-direction: column; gap: 0.9rem; }
.dossier {
  background: var(--bg-raised); border: 1px solid var(--rule); border-left: 3px solid var(--rule-strong);
  border-radius: 4px; padding: 1.1rem 1.35rem;
  display: grid; grid-template-columns: 1fr auto; gap: 0.75rem 1.5rem; align-items: center;
}
.dossier[data-status="completed"], .dossier[data-status="partial"] { border-left-color: var(--good); }
.dossier[data-status="failed"] { border-left-color: var(--risk); }
.dossier[data-status="in_progress"] { border-left-color: var(--warn); }

.dossier-main { min-width: 0; }
.dossier-ref {
  font-family: var(--mono); font-size: 0.7rem; color: var(--ink-faint); letter-spacing: 0.02em;
  margin-bottom: 0.3rem;
}
.dossier-name { font-weight: 700; font-size: 1rem; color: var(--ink); margin-bottom: 0.15rem; }
.dossier-meta { font-size: 0.82rem; color: var(--ink-soft); }
.dossier-meta .dot { margin: 0 0.4em; color: var(--rule-strong); }
.dossier-purpose { font-size: 0.8rem; color: var(--ink-faint); margin-top: 0.35rem; font-style: italic; }

.dossier-side { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.stamp {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 0.35em 0.7em; border-radius: 3px; border: 1.5px solid currentColor;
  white-space: nowrap;
}
.stamp-pending { color: var(--ink-faint); }
.stamp-in_progress { color: var(--warn); }
.stamp-completed, .stamp-partial { color: var(--good); }
.stamp-failed, .stamp-no_results { color: var(--risk); }

.btn-download {
  background: var(--good); color: #12220f; border: none; border-radius: 4px;
  padding: 0.5rem 0.85rem; font-size: 0.8rem; font-weight: 600; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn-download:hover { background: #a5d1a5; }

/* Case monitoring — an add-on, styled distinctly (gold, not green) so
   it doesn't read as part of the base completed/partial result. */
.dossier-monitor { margin-top: 0.6rem; }
.btn-monitor {
  background: transparent; color: var(--gold); border: 1.5px solid var(--gold); border-radius: 4px;
  padding: 0.4em 0.75em; font-size: 0.76rem; font-weight: 600; cursor: pointer;
}
.btn-monitor:hover { background: var(--gold); color: #1a1509; }
.monitor-active { display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap; }
.monitor-badge {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--gold); border: 1.5px solid var(--gold); border-radius: 3px;
  padding: 0.3em 0.6em; white-space: nowrap;
}
.monitor-meta { font-size: 0.78rem; color: var(--ink-faint); }
.btn-monitor-cancel {
  background: none; border: none; color: var(--ink-faint); font-size: 0.75rem; text-decoration: underline;
  cursor: pointer; padding: 0;
}
.monitor-changes {
  margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.78rem; color: var(--ink-soft);
}
.monitor-changes li { margin-bottom: 0.2rem; }

/* Security panel — 2FA enrollment */
.totp-status p { margin: 0 0 0.9rem; font-size: 0.9rem; color: var(--ink-soft); }
.totp-badge {
  display: inline-block; font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.04em; padding: 0.3em 0.7em; border-radius: 3px; margin-bottom: 0.6rem;
}
.totp-badge-on { color: var(--good); border: 1.5px solid var(--good); }

.totp-steps { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.totp-steps li { margin-bottom: 0.8rem; font-size: 0.9rem; color: var(--ink-soft); }
.totp-qr {
  margin: 0.7rem 0; padding: 0.9rem; background: #fff; border: 1px solid var(--rule);
  border-radius: 6px; width: fit-content;
}
.totp-qr svg { display: block; width: 180px; height: 180px; }
.totp-secret {
  font-family: var(--mono); font-size: 0.95rem; letter-spacing: 0.08em; color: var(--accent-ink);
  background: var(--accent-soft); border: 1px solid var(--rule); border-radius: 4px;
  padding: 0.6rem 0.9rem; margin-top: 0.5rem; word-break: break-all; user-select: all;
}

.site-footer {
  border-top: 1px solid var(--rule); padding: 1.75rem 1.5rem 2.5rem; position: relative; z-index: 1;
}
.site-footer p {
  max-width: 980px; margin: 0 auto; font-size: 0.78rem; color: var(--ink-faint); text-align: center;
}
