/* Proof approval page. One stylesheet, no external fonts or CDNs (strict CSP).
   Brand colors arrive from the API and are set on :root by app.js. */

:root {
  --accent: #1d4f91;
  --accent-hover: #163e73;
  --accent-soft: #eaf0f8;
  --accent-ring: rgba(29, 79, 145, .28);
  --stripe: #8c939c;

  --bg: #f3f5f7;
  --surface: #ffffff;
  --ink: #16191d;
  --ink-2: #3d4651;
  --muted: #5d6875;
  --line: #dde2e8;
  --line-strong: #c3cad3;
  --stage: #e6e9ed;
  --stage-dot: #d2d7de;

  --wait-bg: #fff4dc; --wait-ink: #6e4600; --wait-dot: #d98e04;
  --ok-bg: #e5f3ea;   --ok-ink: #0d5531;   --ok-dot: #1c8a4f;
  --chg-bg: #edeefb;  --chg-ink: #36309a;  --chg-dot: #5b55d6;
  --exp-bg: #eef0f3;  --exp-ink: #3d4651;  --exp-dot: #8a94a1;
  --err-bg: #fdecec;  --err-ink: #9b1c1c;

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sheet-max-h: 62vh;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
body.has-dock { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
img { max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.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 {
  position: absolute; left: 12px; top: -48px; z-index: 50;
  background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: 8px;
  border: 2px solid var(--accent); text-decoration: none; font-weight: 600;
}
.skip:focus { top: 12px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--surface);
  border-top: 4px solid var(--stripe);
  border-bottom: 1px solid var(--line);
}
.topbar__in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__logo { display: block; height: 40px; width: auto; max-width: 200px; object-fit: contain; }
.brand__logo--badge { height: 48px; }
.brand__name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; line-height: 1.2; }
.brand__word { font-weight: 800; font-size: 20px; letter-spacing: -.02em; color: var(--accent); }
.topbar__what { color: var(--muted); font-size: 14px; display: none; }

/* ---------- page ---------- */
.page { padding-top: 22px; padding-bottom: 32px; }
.intro { margin-bottom: 18px; }
.intro__line { color: var(--ink-2); font-size: 15px; }
.intro__line b { font-weight: 600; color: var(--ink); }
.intro h1 {
  font-size: 24px; line-height: 1.2; letter-spacing: -.015em; font-weight: 700;
  margin-top: 4px; max-width: 34ch; text-wrap: balance;
}
.intro .pill { margin-top: 12px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; line-height: 1.3;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pill--pending { background: var(--wait-bg); color: var(--wait-ink); }
.pill--pending::before { background: var(--wait-dot); }
.pill--approved { background: var(--ok-bg); color: var(--ok-ink); }
.pill--approved::before { background: var(--ok-dot); }
.pill--changes { background: var(--chg-bg); color: var(--chg-ink); }
.pill--changes::before { background: var(--chg-dot); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }

/* ---------- proof stage: the proof sits on a light table with crop marks ---------- */
.proof { min-width: 0; }
.stage {
  position: relative; margin: 0;
  background-color: var(--stage);
  background-image: radial-gradient(var(--stage-dot) 1px, transparent 1.2px);
  background-size: 18px 18px;
  border-radius: 14px;
  padding: 30px 26px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.sheet {
  --ratio: 1.3333;
  position: relative;
  width: min(100%, calc(var(--sheet-max-h) * var(--ratio)));
  aspect-ratio: var(--ratio);
  background: #fff;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .10), 0 10px 28px -6px rgba(17, 24, 39, .18);
  cursor: zoom-in;
  border: 0; padding: 0; display: block;
}
.sheet img { display: block; width: 100%; height: 100%; object-fit: contain; }
.sheet.is-in { animation: settle .32s ease-out both; }
@keyframes settle { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

.crop { position: absolute; width: 0; height: 0; pointer-events: none; }
.crop::before, .crop::after { content: ""; position: absolute; background: #6b7480; }
.crop::before { width: 12px; height: 1px; }
.crop::after { width: 1px; height: 12px; }
.crop--tl { top: 0; left: 0; }
.crop--tl::before { left: -18px; top: 0; }  .crop--tl::after { top: -18px; left: 0; }
.crop--tr { top: 0; right: 0; }
.crop--tr::before { right: -18px; top: 0; } .crop--tr::after { top: -18px; right: 0; }
.crop--bl { bottom: 0; left: 0; }
.crop--bl::before { left: -18px; bottom: 0; } .crop--bl::after { bottom: -18px; left: 0; }
.crop--br { bottom: 0; right: 0; }
.crop--br::before { right: -18px; bottom: 0; } .crop--br::after { bottom: -18px; right: 0; }

.stage__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .94); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .08);
}
.stage__nav:hover { background: #fff; border-color: var(--ink-2); }
.stage__nav:disabled { opacity: .35; cursor: default; }
.stage__nav--prev { left: 8px; }
.stage__nav--next { right: 8px; }
@media (max-width: 639px) { .stage__nav { display: none; } } /* phones: swipe or use the page buttons */

.stage__empty { max-width: 34ch; text-align: center; color: var(--ink-2); padding: 40px 8px; }
.stage__empty h2 { font-size: 18px; margin-bottom: 6px; color: var(--ink); }
.docfile {
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  background: #fff; border-radius: 10px; padding: 32px 28px; max-width: 360px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .10), 0 10px 28px -6px rgba(17, 24, 39, .18);
}
.docfile p { color: var(--ink-2); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 12px; }
.toolbar__count { font-size: 15px; color: var(--ink-2); }
.toolbar__count b { color: var(--ink); font-weight: 600; }
.toolbar__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.thumbs { list-style: none; display: flex; gap: 10px; margin: 14px 0 0; padding: 2px 2px 6px; overflow-x: auto; }
.thumb {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); font-size: 13px;
}
.thumb__img {
  width: 76px; height: 60px; border-radius: 8px; background: #fff; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 4px;
}
.thumb__img img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.thumb[aria-current="true"] { color: var(--ink); font-weight: 600; }
.thumb[aria-current="true"] .thumb__img { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.thumb:hover .thumb__img { border-color: var(--line-strong); }

.hint { margin-top: 10px; font-size: 14px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px; border-radius: 10px;
  font-size: 16px; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background-color .15s, border-color .15s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover { background: #f6f7f9; border-color: var(--ink-2); }
.btn--small { min-height: 40px; padding: 8px 14px; font-size: 15px; border-radius: 8px; }
.btn--block { width: 100%; }
.btn[aria-disabled="true"] { opacity: .7; cursor: progress; }
.btn svg { flex: none; }
.linkbtn {
  background: none; border: 0; padding: 8px 2px; color: var(--ink-2); font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; font-size: 15px;
}
.linkbtn:hover { color: var(--ink); }

/* ---------- review panel ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.state { padding: 16px 20px; display: flex; gap: 12px; align-items: flex-start; }
.state__icon { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.state__title { font-size: 17px; font-weight: 700; line-height: 1.3; }
.state__sub { font-size: 15px; margin-top: 2px; }
.state--pending { background: var(--wait-bg); color: var(--wait-ink); }
.state--pending .state__icon { background: var(--wait-dot); color: #fff; }

.panel__sec { padding: 18px 20px; border-top: 1px solid var(--line); }
.panel__sec:first-child { border-top: 0; }
.panel h2 { font-size: 17px; line-height: 1.3; font-weight: 700; margin-bottom: 10px; }

.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }

.items { list-style: none; margin: 0; padding: 0; }
.items li { padding: 10px 0; border-top: 1px solid var(--line); }
.items li:first-child { border-top: 0; padding-top: 0; }
.items li:last-child { padding-bottom: 0; }
.items__label { font-weight: 600; }
.items__value { color: var(--ink-2); font-size: 15px; }
.summary { white-space: pre-line; color: var(--ink-2); font-size: 15px; overflow-wrap: anywhere; }

.choices { display: grid; gap: 10px; }
.choices__note { font-size: 15px; color: var(--ink-2); margin-bottom: 14px; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.form__head h2 { margin: 0; }
.form__intro { font-size: 15px; color: var(--ink-2); margin-top: -6px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 15px; }
.field__hint { font-size: 14px; color: var(--muted); }
.field input, .field textarea {
  width: 100%; min-height: 48px; padding: 11px 13px; font-size: 16px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 124px; resize: vertical; line-height: 1.45; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field [aria-invalid="true"] { border-color: var(--err-ink); }
.field__err { font-size: 14px; color: var(--err-ink); font-weight: 600; }
.field input.sign { font-size: 18px; font-weight: 600; letter-spacing: .01em; }

.check {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 14px;
  cursor: pointer; transition: border-color .15s, background-color .15s;
}
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.check span { font-weight: 600; line-height: 1.4; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check[data-invalid="true"] { border-color: var(--err-ink); }
.check input:focus-visible { outline: none; }
.check:focus-within { box-shadow: 0 0 0 3px var(--accent-ring); }

.form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.alert { background: var(--err-bg); color: var(--err-ink); border-radius: 10px; padding: 12px 14px; font-size: 15px; font-weight: 600; }

.fine { font-size: 13px; line-height: 1.5; color: var(--muted); }

/* ---------- confirmation ---------- */
.decided { padding-top: 22px; padding-bottom: 22px; }
.decided--approved { background: var(--ok-bg); }
.decided--changes { background: var(--chg-bg); }
.done__mark { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; margin-bottom: 14px; }
.done--approved .done__mark { background: var(--ok-dot); }
.done--changes .done__mark { background: var(--chg-dot); }
.done h2 { font-size: 22px; line-height: 1.25; margin-bottom: 4px; }
.done--approved h2 { color: var(--ok-ink); }
.done--changes h2 { color: var(--chg-ink); }
.done p { color: var(--ink-2); }
.done p + p { margin-top: 10px; }
.done .done__who { color: var(--ink); font-weight: 600; }
.done .note { margin-top: 14px; padding: 12px 14px; background: #fff; border-radius: 10px; white-space: pre-line; overflow-wrap: anywhere; }
.done .note p { color: var(--ink); margin: 0; }
.done .note .note__label { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.done--approved .done__mark path { stroke-dasharray: 30; stroke-dashoffset: 0; }
.done--approved.is-new .done__mark path { animation: draw .45s .1s ease-out both; }
@keyframes draw { from { stroke-dashoffset: 30; } to { stroke-dashoffset: 0; } }

/* ---------- message pages (expired, not found) ---------- */
.message { max-width: 560px; margin: 24px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; }
.message__icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--exp-bg); color: var(--exp-ink); margin-bottom: 14px; }
.message h1 { font-size: 22px; line-height: 1.25; margin-bottom: 8px; }
.message p { color: var(--ink-2); }
.message p + p, .message .facts { margin-top: 12px; }
.message .btn { margin-top: 18px; }

.foot { padding-top: 20px; padding-bottom: 36px; color: var(--muted); font-size: 14px; }
.foot p { border-top: 1px solid var(--line); padding-top: 18px; }

.noscript { background: var(--surface); padding: 16px; border-radius: 10px; }

/* ---------- loading skeleton ---------- */
.sk { display: block; background: #e3e7ec; border-radius: 8px; }
.sk--brand { width: 170px; height: 36px; }
.sk--line { width: 220px; height: 16px; margin-bottom: 10px; }
.sk--title { width: min(420px, 80%); height: 28px; margin-bottom: 20px; }
.sk--stage { height: 52vh; border-radius: 14px; }
.sk--panel { height: 300px; border-radius: 16px; }
@media (prefers-reduced-motion: no-preference) {
  .sk { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .55; } }
}

/* ---------- sticky action bar on phones ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(17, 24, 39, .06);
}
.dock .btn { min-height: 50px; padding: 10px 12px; font-size: 15px; }

/* ---------- full size viewer ---------- */
.viewer {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent; color: #fff; overflow: hidden;
}
.viewer::backdrop { background: #0e1014; }
.viewer[open] { display: flex; flex-direction: column; background: #0e1014; }
.viewer__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px calc(10px) 16px; padding-top: calc(10px + env(safe-area-inset-top));
}
.viewer__title { font-weight: 600; font-size: 15px; }
.viewer__tools { display: flex; gap: 8px; align-items: center; }
.vbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; min-width: 40px; padding: 8px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); color: #fff; border: 1px solid rgba(255, 255, 255, .22);
  font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.vbtn:hover { background: rgba(255, 255, 255, .2); }
.vbtn--icon { padding: 8px; }
.viewer :focus-visible { outline-color: #fff; }
.viewer__canvas {
  flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center;
  padding: 8px 16px 24px; overscroll-behavior: contain;
}
.viewer__canvas img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; cursor: zoom-in; user-select: none; }
.viewer__canvas.is-zoomed { display: block; padding: 0; }
.viewer__canvas.is-zoomed img { max-width: none; max-height: none; cursor: zoom-out; margin: 0 auto; }
.viewer__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.viewer__nav:hover { background: rgba(255, 255, 255, .24); }
.viewer__nav:disabled { opacity: .3; cursor: default; }
.viewer__nav--prev { left: 12px; }
.viewer__nav--next { right: 12px; }
.viewer__canvas.is-zoomed ~ .viewer__nav { display: none; }
@media (min-width: 640px) { .viewer--multi .viewer__canvas { padding-left: 80px; padding-right: 80px; } .viewer--multi .viewer__canvas.is-zoomed { padding: 0; } }

/* ---------- larger screens ---------- */
@media (min-width: 640px) {
  .wrap { padding: 0 24px; }
  .intro h1 { font-size: 28px; }
  .stage { padding: 40px 64px; }
  .stage__nav--prev { left: 14px; }
  .stage__nav--next { right: 14px; }
  .thumb__img { width: 92px; height: 70px; }
}

@media (min-width: 960px) {
  :root { --sheet-max-h: clamp(320px, calc(100vh - 330px), 680px); }
  .topbar__in { min-height: 76px; }
  .brand__logo { height: 44px; max-width: 240px; }
  .brand__logo--badge { height: 54px; }
  .brand__name { font-size: 19px; }
  .topbar__what { display: block; }
  .page { padding-top: 30px; }
  .intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
  .intro h1 { font-size: 30px; }
  .intro .pill { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr) 392px; gap: 28px; }
  .stage { min-height: calc(var(--sheet-max-h) + 80px); padding: 40px 72px; }
  .panel { position: sticky; top: 20px; }
  .dock { display: none; }
  body.has-dock { padding-bottom: 0; }
}

@media (min-width: 1200px) {
  .layout { grid-template-columns: minmax(0, 1fr) 420px; gap: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .topbar, .dock, .toolbar, .thumbs, .stage__nav, .decision, .foot { display: none !important; }
  .stage { background: none; padding: 0; }
}
