
:root {
  color-scheme: dark light;
  --bg: #0d1020;
  --bg-grad: radial-gradient(1200px 500px at 15% -10%, #1d2150 0%, rgba(13,16,32,0) 60%), radial-gradient(900px 500px at 100% 0%, #2a1a4d 0%, rgba(13,16,32,0) 55%);
  --surface: #161a30;
  --surface-2: #1d2240;
  --border: #2d3358;
  --text: #eceefb;
  --muted: #aab0d3;
  --accent: #8b8dff;
  --accent-strong: #4f46e5;
  --accent-strong-hover: #6159f0;
  --on-accent: #ffffff;
  --link: #a9b4ff;
  --ok-bg: #0f3a2a; --ok-fg: #7ff0b8; --ok-bd: #1d6b4c;
  --warn-bg: #3d2f0d; --warn-fg: #ffd37a; --warn-bd: #7a5c14;
  --bad-bg: #431a26; --bad-fg: #ff9fb3; --bad-bd: #84304a;
  --info-bg: #1a2a52; --info-fg: #a8c1ff; --info-bd: #324a8c;
  --neutral-bg: #272c4d; --neutral-fg: #c5cae8; --neutral-bd: #3c4375;
  --focus: #ffd166;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5fb;
    --bg-grad: radial-gradient(1200px 500px at 15% -10%, #dfe3ff 0%, rgba(244,245,251,0) 60%), radial-gradient(900px 500px at 100% 0%, #efe3ff 0%, rgba(244,245,251,0) 55%);
    --surface: #ffffff;
    --surface-2: #eef0fb;
    --border: #d3d7ee;
    --text: #151936;
    --muted: #464c75;
    --accent: #4338ca;
    --accent-strong: #4338ca;
    --accent-strong-hover: #3730a3;
    --link: #3a30c2;
    --ok-bg: #dcf7e8; --ok-fg: #0b5b37; --ok-bd: #8fd6b1;
    --warn-bg: #fff1cc; --warn-fg: #6b4a00; --warn-bd: #e6c36a;
    --bad-bg: #fde0e7; --bad-fg: #8a1534; --bad-bd: #eea2b5;
    --info-bg: #e2e9ff; --info-fg: #213a8f; --info-bd: #a9bbf2;
    --neutral-bg: #e6e8f6; --neutral-fg: #333a66; --neutral-bd: #c3c8e6;
    --focus: #b45309;
    --shadow: 0 8px 24px rgba(40,44,100,.12);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); background-image: var(--bg-grad); background-repeat: no-repeat; color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 3vw + 1rem, 2.4rem); }
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: .9em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .08rem .35rem; overflow-wrap: anywhere; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .8rem 1rem; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 1rem; }
pre code { background: none; border: 0; padding: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.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; }
.skip-link { position: absolute; left: 1rem; top: -4rem; background: var(--accent-strong); color: var(--on-accent); padding: .5rem 1rem; border-radius: 8px; z-index: 10; }
.skip-link:focus { top: .75rem; }

/* header / nav */
.site-header { background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.bar { max-width: 1120px; margin: 0 auto; padding: .7rem 1.25rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand small { font-weight: 600; color: var(--muted); font-size: .72rem; display: block; letter-spacing: .08em; text-transform: uppercase; line-height: 1; margin-top: 2px; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: .5rem; }
.nav a { color: var(--muted); text-decoration: none; padding: .45rem .8rem; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.userbox form { margin: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface-2); }
.user-name { font-weight: 600; }
.subnav { border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.subnav .bar { padding-top: .35rem; padding-bottom: .35rem; }
.subnav .nav { margin-left: 0; }
.subnav .nav a { padding: .3rem .7rem; font-size: .9rem; }

main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .875rem; }
.site-footer .bar { justify-content: space-between; }
.site-footer a { color: var(--muted); }
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: .6rem 1.1rem; border-radius: 10px; border: 1px solid transparent; background: var(--accent-strong); color: var(--on-accent); line-height: 1.2; }
.btn:hover { background: var(--accent-strong-hover); }
.btn svg { width: 18px; height: 18px; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); padding: .4rem .8rem; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: #b4234a; color: #fff; }
.btn-danger:hover { background: #cf2d58; }
.btn-ok { background: #15803d; color: #fff; }
.btn-ok:hover { background: #17963f; }
.btn-sm { padding: .3rem .7rem; font-size: .875rem; border-radius: 8px; }
.btn-lg { padding: .85rem 1.5rem; font-size: 1.05rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* cards & layout helpers */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
/* grid-4 is only the admin dashboard's row of small stat counters; page content is a single column of cards. */
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin: 0; color: var(--muted); }
.page-head h1 { margin-bottom: .25rem; }
.stat { display: block; text-decoration: none; color: inherit; }
.stat .num { font-size: 2.1rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-weight: 600; font-size: .9rem; margin-top: .35rem; }
a.stat:hover { border-color: var(--accent); }
.hero { padding: 2.5rem 0 1.5rem; max-width: 46rem; }
.hero h1 { font-size: clamp(2.1rem, 4vw + 1rem, 3.3rem); }
.hero .lead { font-size: 1.2rem; color: var(--muted); }
.gradient-text { background: linear-gradient(90deg, #a9b4ff, #e0a8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (prefers-color-scheme: light) { .gradient-text { background: linear-gradient(90deg, #4338ca, #9333ea); -webkit-background-clip: text; background-clip: text; color: transparent; } }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.steps li { counter-increment: step; position: relative; padding-left: 3rem; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-strong); color: var(--on-accent); font-weight: 700; }
.steps li strong { display: block; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: .6rem; } }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td .inline-form { display: flex; gap: .4rem; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; letter-spacing: .02em; border: 1px solid; white-space: nowrap; }
.badge::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.badge-pending { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.badge-approved, .badge-active, .badge-verified { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.badge-denied, .badge-revoked, .badge-unverified { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-bd); }
.badge-info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); border-color: var(--neutral-bd); }

/* forms */
form { margin: 0; }
.field { margin-bottom: 1.1rem; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field .hint { color: var(--muted); font-size: .875rem; margin: .25rem 0 0; }
.req { color: var(--bad-fg); }
.check { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: 1.1rem; }
.check input { width: 1.1rem; height: 1.1rem; margin: .2rem 0 0; flex: none; accent-color: var(--accent); }
.check label { margin: 0; font-weight: 600; }
.check .hint { color: var(--muted); font-size: .875rem; margin: .25rem 0 0; font-weight: 400; }
input[type=text], input[type=email], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .6rem .75rem; }
input[type=file] { width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: .6rem; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; margin-right: .75rem; padding: .35rem .8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
textarea { min-height: 9rem; resize: vertical; }
textarea.mono { font-size: .85rem; }
input:hover, select:hover, textarea:hover { border-color: var(--accent); }
input[aria-invalid=true], textarea[aria-invalid=true], select[aria-invalid=true] { border-color: var(--bad-fg); }
.field-error { color: var(--bad-fg); font-weight: 600; font-size: .9rem; margin: .3rem 0 0; display: flex; gap: .35rem; align-items: flex-start; }
.field-error::before { content: "!"; flex: none; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--bad-fg); color: var(--bad-bg); display: grid; place-items: center; font-size: .75rem; font-weight: 800; margin-top: .15rem; }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 12rem; }
.filters .field.grow { flex: 1; }
.code-input { font-size: 1.8rem !important; letter-spacing: .5em; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; max-width: 16rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem 0; margin: 0 0 1.25rem; }
legend { font-weight: 700; padding: 0 .4rem; }

/* flash / alerts / empty */
.flash, .alert { display: flex; gap: .75rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 10px; border: 1px solid; margin-bottom: 1.25rem; }
.flash p, .alert p { margin: 0; }
.flash-success { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.flash-error, .alert-danger { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-bd); }
.flash-info, .alert-info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.alert-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.alert a, .flash a { color: inherit; font-weight: 700; }
.alert code { color: var(--text); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.empty .icon { width: 44px; height: 44px; margin: 0 auto .5rem; opacity: .7; }
.empty h3 { color: var(--text); margin-bottom: .25rem; }
.error-page { text-align: center; padding: 3rem 0; max-width: 40rem; margin: 0 auto; }
.error-page .code { font-size: clamp(4rem, 12vw, 7rem); font-weight: 800; line-height: 1; letter-spacing: -.04em; }
.error-page .code span { background: linear-gradient(90deg, #a9b4ff, #e0a8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (prefers-color-scheme: light) { .error-page .code span { background: linear-gradient(90deg, #4338ca, #9333ea); -webkit-background-clip: text; background-clip: text; color: transparent; } }
.error-page .actions { justify-content: center; }
.error-page .alert { text-align: left; }
.turnstile-box { min-height: 70px; margin-bottom: 1rem; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { padding: 0 0 1rem 1.1rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .45rem; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.sep { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.hash { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; overflow-wrap: anywhere; }
details > summary { cursor: pointer; font-weight: 600; }
@media (prefers-reduced-motion: no-preference) { .btn, a, input, select, textarea { transition: background-color .15s, border-color .15s, color .15s; } }
@media print { .site-header, .site-footer { display: none; } }
