/* Rootcastle platform: one stylesheet for site, portal and admin. Brand tokens match rootcastle.com (REQ-PF-002).
   CSP forbids inline styles, so every visual rule lives here. */
:root {
  --ink: #0b0d10;
  --ink-2: #3a4049;
  --ink-3: #6b7380;
  --paper: #ffffff;
  --paper-2: #f5f6f8;
  --line: #dfe2e7;
  --blue: #0e3d8a;
  --blue-2: #0a2d66;
  --green: #228b55;
  --red: #b42318;
  --amber: #9a6700;
  --radius: 6px;
  --shell: 1180px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--ink); background: var(--paper-2); min-height: 100vh; display: flex; flex-direction: column; }
body > main { flex: 1; }
a { color: var(--blue); text-underline-offset: 2px; }
a:hover { color: var(--blue-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1.mono { font-size: 1.45rem; }
img, svg { max-width: 100%; height: auto; }
.shell { max-width: var(--shell); margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--paper); padding: 6px 10px; z-index: 10; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Header */
.top { background: #000; color: #fff; }
.top .shell { display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.brand span { color: #8fb3ef; font-weight: 500; margin-left: 6px; }
.nav { display: flex; gap: 4px 16px; flex-wrap: wrap; flex: 1; }
.nav a { color: #d6dbe3; text-decoration: none; font-size: .93rem; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--green); }
.top form { margin: 0; }
.top .who { color: #aab2bf; font-size: .85rem; }
.linkbtn { background: none; border: 0; color: #d6dbe3; cursor: pointer; font: inherit; font-size: .9rem; padding: 0; text-decoration: underline; }

main { padding: 28px 0 56px; }
.foot { border-top: 1px solid var(--line); background: var(--paper); color: var(--ink-3); font-size: .85rem; padding: 20px 0; }
.foot .shell { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* Surfaces */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 20px; }
.grid > .panel { margin-bottom: 0; }
.grid { margin-bottom: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.pagehead h1 { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.stat { display: block; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 2rem; line-height: 1.1; color: var(--blue); }

/* Tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--paper); }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; background: var(--paper-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--ink-3); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
dl.facts + p, dl.facts + .prose { margin-top: 14px; }

/* Status chips */
.chip { display: inline-block; font-size: .78rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2); white-space: nowrap; }
.chip-new, .chip-sent, .chip-received { border-color: #b9c9e8; background: #eef3fb; color: var(--blue); }
.chip-won, .chip-valid, .chip-accepted, .chip-published, .chip-completed, .chip-attended { border-color: #b6dcc7; background: #edf7f1; color: var(--green); }
.chip-lost, .chip-revoked, .chip-declined, .chip-spam, .chip-cancelled, .chip-not_found { border-color: #f1c4bf; background: #fdf1f0; color: var(--red); }
.chip-expired, .chip-draft, .chip-archived { border-color: #ecd9a8; background: #fdf8ec; color: var(--amber); }

/* Forms */
form.stack > * + * { margin-top: 14px; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.hint { display: block; font-weight: 400; color: var(--ink-3); font-size: .82rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--paper); border: 1px solid #c4c9d1; border-radius: var(--radius); padding: 8px 10px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 2px solid rgba(14, 61, 138, .18); outline-offset: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > input, .inline > select { width: auto; flex: 1 1 160px; }
.btn { display: inline-block; font: inherit; font-weight: 600; font-size: .92rem; border-radius: var(--radius); padding: 8px 14px; border: 1px solid var(--blue); background: var(--blue); color: #fff; cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover { background: var(--blue-2); color: #fff; }
.btn-ghost { background: var(--paper); color: var(--blue); }
.btn-ghost:hover { background: #eef3fb; color: var(--blue-2); }
.btn-green { background: var(--green); border-color: var(--green); }
.btn-green:hover { background: #1b7046; }
.btn-danger { background: var(--paper); color: var(--red); border-color: #e3a29b; }
.btn-danger:hover { background: #fdf1f0; color: var(--red); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* Messages */
.flash { border: 1px solid #b6dcc7; background: #edf7f1; color: #14532d; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 20px; }
.errors { border: 1px solid #f1c4bf; background: #fdf1f0; color: #7a1a12; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 20px; }
.errors ul { margin: 0; padding-left: 18px; }
.notice { border: 1px solid #ecd9a8; background: #fdf8ec; color: #5c3d00; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 20px; }
.secret { font-family: var(--mono); background: var(--paper-2); border: 1px dashed #9aa3b0; padding: 10px 12px; border-radius: var(--radius); overflow-wrap: anywhere; user-select: all; }
.codes { columns: 2; font-family: var(--mono); padding-left: 20px; }

/* Auth screens */
.authbox { max-width: 440px; margin: 40px auto; }
.qr { background: #fff; padding: 12px; border: 1px solid var(--line); display: inline-block; border-radius: var(--radius); }
.qr svg { display: block; width: 200px; height: 200px; }

/* Catalogue */
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 1.02rem; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--blue); }
.card .meta { font-size: .82rem; color: var(--ink-3); }
.card .price { margin-top: auto; font-weight: 700; }
.thumb { aspect-ratio: 4 / 3; background: var(--paper-2); border-radius: 4px; overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--ink-3); font-size: .85rem; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters a { text-decoration: none; border: 1px solid var(--line); background: var(--paper); padding: 4px 10px; border-radius: 999px; font-size: .88rem; color: var(--ink-2); }
.filters a[aria-current="true"] { border-color: var(--blue); color: var(--blue); background: #eef3fb; }
.specs th { width: 40%; text-transform: none; letter-spacing: 0; font-size: .9rem; }
.prose { max-width: 72ch; }
.prose p:last-child { margin-bottom: 0; }
.hero { background: #000; color: #fff; padding: 40px 0; margin: -28px 0 28px; }
.hero p { color: #c9d1dc; max-width: 64ch; }
.hero a.btn-ghost { background: transparent; color: #fff; border-color: #6c7a90; }

/* Verification */
.verify { max-width: 640px; margin: 0 auto; }
.verdict { font-size: 1.4rem; font-weight: 700; margin: 0 0 12px; }
.verdict-valid { color: var(--green); }
.verdict-revoked, .verdict-not_found { color: var(--red); }
.verdict-expired { color: var(--amber); }

/* Assessment */
.question { border-top: 1px solid var(--line); padding: 16px 0; }
.question:first-of-type { border-top: 0; }
.question p { white-space: pre-line; }
.result-pass { color: var(--green); }
.result-fail { color: var(--red); }

/* Printable documents (quote, certificate) */
.doc { background: #fff; max-width: 820px; margin: 24px auto; padding: 40px; border: 1px solid var(--line); }
.doc header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; border-bottom: 3px solid #000; padding-bottom: 16px; margin-bottom: 24px; }
.doc .mark { font-weight: 800; letter-spacing: .06em; font-size: 1.15rem; }
.doc .mark small { display: block; font-weight: 500; letter-spacing: 0; color: var(--ink-3); font-size: .8rem; }
.cert { text-align: center; }
.cert h1 { font-size: 2rem; margin: 18px 0 6px; }
.cert .holder { font-size: 1.7rem; font-weight: 700; margin: 18px 0; border-bottom: 1px solid var(--line); display: inline-block; padding: 0 24px 6px; }
.cert .scope { color: var(--ink-2); max-width: 60ch; margin: 16px auto; font-size: .92rem; }
.cert footer { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 32px; text-align: left; font-size: .85rem; }
.cert .qr svg { width: 120px; height: 120px; }
.noprint { text-align: center; margin: 16px; }
@media print {
  body { background: #fff; }
  .noprint, .top, .foot { display: none !important; }
  .doc { border: 0; margin: 0; max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
}
