/* CEMS – External Document Verification System · modern minimal interface (v1.7)
   One bold element – the verdict stamp; everything else stays quiet. */
@font-face {
  font-family: "CEMS Blackletter";
  src: url("fonts/UnifrakturMaguntia-Book.ttf") format("truetype");
  font-display: swap;
}
:root {
  --paper: #f4f6f9;
  --surface: #ffffff;
  --ink: #15233b;
  --muted: #5d6b80;
  --line: #dde3eb;
  --line-strong: #c5cfdb;
  --accent: #1d47c8;
  --accent-soft: #e8eefc;
  --accent-ink: #ffffff;
  --ok: #0e7a4f;     --ok-bg: #e6f4ec;
  --bad: #b42318;    --bad-bg: #fcebe9;
  --warn: #9a5800;   --warn-bg: #fff3e0;
  --neutral: #475467; --neutral-bg: #eef1f5;
  --r-lg: 22px;
  --r-sm: 12px;
  --shadow: 0 1px 2px rgba(21, 35, 59, .04), 0 12px 32px -8px rgba(21, 35, 59, .10);
  --shadow-s: 0 1px 2px rgba(21, 35, 59, .06), 0 2px 6px rgba(21, 35, 59, .04);
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --shadow: none; --shadow-s: none;
    --paper: #0f141c; --surface: #161d28; --ink: #e8edf4; --muted: #9aa7b8; --line: #263142; --line-strong: #34425a;
    --accent: #7c9bff; --accent-soft: #1b2645; --accent-ink: #0f141c;
    --ok: #5fd39b; --ok-bg: #11291e; --bad: #ff8b80; --bad-bg: #331614; --warn: #f2b85a; --warn-bg: #33250d; --neutral: #b6c1cf; --neutral-bg: #1f2733;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans);
  min-height: 100vh; display: flex; flex-direction: column; font-feature-settings: "tnum" 1;
}
.wrap { width: 100%; max-width: 920px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-bottom: 48px; }
a { color: var(--accent); text-underline-offset: 2px; }
.mono, .mono-in { font-family: var(--mono); letter-spacing: .01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 650; }
.break { overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.no-js .js-only { display: none !important; }
.print-only { display: none; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------------------ header */
.top { background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; backdrop-filter: saturate(1.4) blur(10px); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; text-decoration: none; }
.logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; flex: none; }
.logo-mark { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.logo-mark .ic { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.inst { font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.sub { font-size: 13px; color: var(--muted); }
.lang { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; flex: none; }
.lang a { color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; }
.lang a.on { background: var(--ink); color: var(--surface); }
.lang a:not(.on):hover { color: var(--ink); }

/* ------------------------------------------------------------ hero */
.hero { padding: 44px 0 26px; max-width: 680px; }
.hero.compact { padding: 26px 0 16px; }
.hero h1 { margin: 0 0 10px; font: 650 clamp(30px, 5vw, 44px)/1.1 var(--display); letter-spacing: -.02em; }
.hero.compact h1 { font-size: clamp(22px, 3.4vw, 28px); margin: 0; }
.lead { margin: 0 0 18px; color: var(--muted); font-size: 17px; max-width: 62ch; }
.trust { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 14px; color: var(--muted); }
.trust li { display: flex; align-items: center; gap: 7px; }
.trust .ic { width: 18px; height: 18px; color: var(--accent); }

/* ------------------------------------------------------------ method chooser */
.panel-card { background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.methods { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.method {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; text-align: left; cursor: pointer;
  display: flex; gap: 10px; align-items: flex-start; padding: 16px 16px 14px; border-right: 1px solid var(--line); position: relative;
}
.method:last-child { border-right: 0; }
.method .ic { margin-top: 2px; }
.m-text { display: flex; flex-direction: column; min-width: 0; }
.m-text b { color: var(--ink); font-weight: 600; font-size: 15px; line-height: 1.3; }
.m-text small { font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.method:hover { background: var(--paper); }
.method.on { color: var(--accent); background: var(--surface); }
.method.on b { color: var(--accent); }
.method.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--accent); }
.no-js .method { cursor: default; }

.panel { padding: 22px 22px 24px; }
.js .panel[data-inactive] { display: none; }
.no-js .panel + .panel { border-top: 1px solid var(--line); }
.grid-fields { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 14px; }
.grid-fields.three { grid-template-columns: 190px minmax(0, 1fr) 210px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lbl { font-size: 14px; font-weight: 600; }
input, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 11px 12px; min-height: 46px;
}
input.mono-in { font-family: var(--mono); font-size: 15px; }
input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); font-family: var(--sans); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:user-invalid { border-color: var(--bad); }
.help { margin: 10px 0 16px; color: var(--muted); font-size: 13.5px; display: flex; gap: 7px; align-items: flex-start; }
.help .ic { width: 16px; height: 16px; margin-top: 2px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 15px/1 var(--sans); min-height: 46px; padding: 0 20px;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(29, 71, 200, .25), 0 8px 18px -6px rgba(29, 71, 200, .45); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn .ic { width: 18px; height: 18px; }
.btn.is-loading { pointer-events: none; opacity: .85; }
.btn.is-loading::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
button.link { appearance: none; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
button.link .ic { width: 15px; height: 15px; }

/* QR scanning */
.scan-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: start; }
.no-js .scan-grid { grid-template-columns: 1fr; }
.viewer { position: relative; aspect-ratio: 1; border-radius: var(--r-lg); background: var(--paper); border: 1px dashed var(--line-strong); overflow: hidden; display: grid; place-items: center; }
.viewer video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.scan.live .viewer video { display: block; }
.scan.live .viewer-hint { display: none; }
.viewer-hint .ic { width: 64px; height: 64px; color: var(--line-strong); stroke-width: 1.2; }
.frame { position: absolute; inset: 18%; border: 2px solid rgba(255, 255, 255, .9); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25); display: none; }
.scan.live .frame { display: block; }
.scan-side .help:first-child { margin-top: 0; }
.scan-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.scan-msg { min-height: 1.4em; margin: 10px 0; font-size: 14px; }
.scan-msg.bad { color: var(--bad); }
.paste { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.paste .lbl { display: block; margin-bottom: 6px; }

/* ------------------------------------------------------------ result */
.result { margin-top: 22px; background: var(--surface); border: 1px solid transparent; box-shadow: var(--shadow); border-radius: var(--r-lg); overflow: hidden; scroll-margin-top: 12px; }
.result:focus { outline: none; }
.verdict { display: flex; gap: 26px; align-items: center; padding: 26px 26px 24px; border-bottom: 1px solid var(--line); background: var(--tone-bg); }
.tone-ok { --tone: var(--ok); --tone-bg: var(--ok-bg); }
.tone-bad { --tone: var(--bad); --tone-bg: var(--bad-bg); }
.tone-warn { --tone: var(--warn); --tone-bg: var(--warn-bg); }
.tone-neutral { --tone: var(--neutral); --tone-bg: var(--neutral-bg); }

/* the stamp: the page's one strong graphic element */
.stamp {
  flex: none; width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center; color: var(--tone);
  border: 3px solid currentColor; box-shadow: inset 0 0 0 5px var(--tone-bg), inset 0 0 0 6.5px currentColor; transform: rotate(-8deg);
  animation: stamp .42s cubic-bezier(.2, 1.4, .4, 1) both;
}
.stamp span {
  max-width: 100px; text-align: center; font: 800 15px/1.1 var(--display); letter-spacing: .06em; text-transform: uppercase; overflow-wrap: anywhere;
}
.lang-uk .stamp span { font-size: 13px; letter-spacing: .03em; }
@keyframes stamp { from { opacity: 0; transform: rotate(-8deg) scale(1.35); } to { opacity: 1; transform: rotate(-8deg) scale(1); } }
@media (prefers-reduced-motion: reduce) { .stamp { animation: none; } .btn.is-loading::before { animation-duration: 2s; } }
.verdict-text { min-width: 0; }
.state { margin: 0 0 6px; font: 650 26px/1.2 var(--display); color: var(--tone); letter-spacing: -.01em; }
.verdict-text p { margin: 0 0 8px; max-width: 60ch; }
.verdict-text .meta { font-size: 14px; color: var(--muted); margin: 0; }
.verdict-text .meta b { color: var(--ink); font-weight: 600; }

.result-body { padding: 24px 26px 8px; }
.doc-heading { margin: 0 0 18px; font: 650 21px/1.3 var(--display); letter-spacing: -.01em; }
.details.with-media { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 26px; align-items: start; }
.media { display: flex; flex-direction: column; gap: 16px; }
figure { margin: 0; }
figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.photo img { width: 132px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); display: block; }
.zoomable { appearance: none; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); cursor: zoom-in; display: block; width: 100%; overflow: hidden; }
.zoomable img { display: block; width: 100%; height: auto; }
.kvs { margin: 0; }
.kv { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kvs.mini { margin-bottom: 14px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; color: var(--tone); background: var(--tone-bg); border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent); }
.note { color: var(--muted); font-size: 13.5px; margin: 16px 0; }
.qr-box { display: flex; gap: 16px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 18px; box-shadow: var(--shadow-s); }
.qr-box .qr { width: 104px; flex: none; }
.qr-box svg { display: block; width: 100%; height: auto; }
.qr-box .help { margin: 4px 0; }

.table-wrap { overflow-x: auto; }
table.docs { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.docs th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line-strong); }
.docs td { padding: 11px 10px 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; }

.next { margin: 0 26px 6px; padding: 18px 20px; border-radius: var(--r-sm); background: var(--paper); border: 1px solid var(--line); }
.verdict + .next { margin-top: 22px; }
.next h3 { margin: 0 0 8px; font-size: 16px; }
.next ul { margin: 0; padding-left: 20px; }
.next li { margin: 4px 0; }
.next .contact { margin: 12px 0 0; }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 18px 26px 24px; }

/* lightbox (document image) */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(9, 14, 22, .86); display: grid; place-items: center; padding: 20px; }
.lightbox img { max-width: min(1100px, 100%); max-height: calc(100vh - 80px); width: auto; height: auto; border-radius: 6px; background: #fff; }
.lightbox .btn { position: absolute; top: 14px; right: 14px; }

/* ------------------------------------------------------------ footer */
.foot { border-top: 1px solid var(--line); background: var(--surface); padding: 18px 0; font-size: 14px; }
.foot p { margin: 4px 0; }

/* ------------------------------------------------------------ small screens */
@media (max-width: 820px) {
  .methods { grid-template-columns: repeat(2, 1fr); }
  .method:nth-child(2) { border-right: 0; }
  .method:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .grid-fields, .grid-fields.three { grid-template-columns: 1fr; }
  .scan-grid { grid-template-columns: 1fr; }
  .viewer { max-width: 300px; }
  .details.with-media { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .top-in { min-height: 60px; }
  .sub { display: none; }
  .lang a { padding: 5px 9px; }
  .method { padding: 13px 12px 12px; gap: 8px; }
  .m-text small { display: none; }
  .panel { padding: 18px 16px 20px; }
  .btn.primary { width: 100%; }
  .row { flex-direction: column; }
  .verdict { flex-direction: column; align-items: flex-start; gap: 16px; padding: 22px 18px; }
  .stamp { width: 104px; height: 104px; }
  .stamp span { font-size: 13px; max-width: 84px; }
  .result-body { padding: 20px 18px 6px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .next { margin: 0 18px 6px; }
  .result-actions { padding: 16px 18px 20px; }
  .docs thead { display: none; }
  .docs tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .docs td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 3px 0; }
  .docs td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
}

/* ------------------------------------------------------------ print: one-page A4 verification report */
@page { size: A4 portrait; margin: 16mm 15mm; }
@media print {
  :root { --paper: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #bbb; --line-strong: #888; }
  body { background: #fff; font-size: 10.5pt; display: block; }
  .no-print, .js-only, .result-actions, .next { display: none !important; }
  .print-only { display: block; }
  .wrap { max-width: none; padding: 0; }
  .result { border: 0; margin: 0; border-radius: 0; box-shadow: none; break-inside: avoid; }
  .report-head { text-align: center; padding-bottom: 8mm; border-bottom: 1px solid #000; margin-bottom: 6mm; }
  .report-inst { font-weight: 700; font-size: 12pt; }
  .report-title { font-size: 20pt; margin-top: 2mm; }
  .lang-en .report-title { font-family: "CEMS Blackletter", Georgia, serif; font-size: 26pt; }
  .verdict { background: none; padding: 0 0 5mm; border-bottom: 1px solid #bbb; }
  .stamp { animation: none; width: 30mm; height: 30mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .state { color: #000; }
  .result-body { padding: 5mm 0 0; }
  .details.with-media { grid-template-columns: 50mm 1fr; gap: 6mm; }
  .zoomable { border: 0; }
  .kv { padding: 1.6mm 0; grid-template-columns: 55mm 1fr; }
  .qr-box { break-inside: avoid; }
  .qr-box .qr { width: 28mm; }
  .report-foot { margin-top: 6mm; padding-top: 3mm; border-top: 1px solid #000; font-size: 8.5pt; color: #333; }
  a { color: #000; text-decoration: none; }
}
