/*
 * TP-02 counter tablet: approved visual direction (D-026, D-027).
 * Stripe's visual language with PERURI accents: a navy context panel beside a white
 * working panel, navy-tinted ink, hairline surfaces with soft depth, electric blue for
 * actions only, purple in shapes only. Colour never carries meaning by itself.
 * Inter loads from Google Fonts when online; the system font stack is the fallback.
 */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  /* PERURI accents (PDS 2026 key visual) */
  --p-navy: #202887;
  --p-blue: #3c3cf8;
  --p-blue-press: #2a2ad6;
  --p-purple: #e957ff;
  --p-lavender: #cfcfff;
  /* UI neutrals, biased to PERURI navy */
  --ink: #141a4f;
  --slate: #5b6185;
  --hair: #e3e5f0;
  --edge: #c9cce0;
  --canvas: #f6f7fc;
  --tint: #f1f1ff;
  --white: #ffffff;
  --stage: #dfe1ee;
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--stage); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Stage + panel ---------- */
#app { display: flex; height: 100%; }
#stage { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
#panel { width: 360px; flex: none; background: var(--canvas); border-left: 1px solid var(--hair); overflow-y: auto; font-size: 14px; }
#app.no-panel #panel { display: none; }
#show-panel { display: none; position: absolute; top: 6px; right: 6px; opacity: .25; font-size: 11px; padding: 2px 6px; border: 1px solid var(--edge); background: var(--white); border-radius: 4px; cursor: pointer; }
#show-panel:hover, #show-panel:focus { opacity: 1; }
#app.no-panel #show-panel { display: block; }

#device { width: 1280px; height: 800px; flex: none; transform-origin: center center; }
#app.with-panel #device { border-radius: 18px; box-shadow: 0 0 0 12px #141832, 0 0 0 13px #000, 0 30px 60px -20px rgba(20,26,79,.55); }

/* ---------- Tablet frame ---------- */
#tablet { position: relative; width: 1280px; height: 800px; background: var(--white); overflow: hidden; display: grid; grid-template-columns: 448px 1fr; font-size: 20px; line-height: 1.45; }
#tablet.full { display: block; }
.num { font-variant-numeric: tabular-nums; }

/* Left: navy context panel */
.side { position: relative; background: var(--p-navy); color: var(--white); padding: 40px 44px; display: flex; flex-direction: column; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 18px; font-weight: 500; color: #e6e7ff; position: relative; z-index: 1; }
.logo-box { width: 52px; height: 36px; border: 1.5px dashed rgba(207,207,255,.6); border-radius: 8px; display: grid; place-items: center; font-size: 11px; color: var(--p-lavender); flex: none; }
.steps { margin-top: 52px; position: relative; z-index: 1; }
.steps .lbl { font-size: 15px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--p-lavender); }
.bar { display: flex; gap: 6px; margin-top: 12px; width: 240px; }
.bar i { flex: 1; height: 5px; border-radius: 4px; background: rgba(207,207,255,.28); }
.bar i.done { background: rgba(255,255,255,.7); }
.bar i.on { background: var(--white); }
.side h1 { font-size: 40px; line-height: 1.1; letter-spacing: -0.035em; font-weight: 700; margin: 20px 0 0; color: var(--white); position: relative; z-index: 1; text-wrap: balance; }
.side .rule { margin-top: 22px; display: flex; gap: 12px; align-items: flex-start; font-size: 18px; line-height: 1.45; color: #e6e7ff; position: relative; z-index: 1; padding: 14px 16px; background: rgba(255,255,255,.07); border: 1px solid rgba(207,207,255,.22); border-radius: 12px; }
.side .rule .ico { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--p-lavender); color: var(--p-lavender); display: grid; place-items: center; font-size: 13px; font-weight: 700; margin-top: 2px; }
.powered { margin-top: auto; margin-bottom: 128px; font-size: 15px; color: rgba(230,231,255,.8); position: relative; z-index: 1; display: flex; gap: 8px; align-items: center; }
.powered b { color: var(--white); font-weight: 600; }
.hex { position: absolute; z-index: 0; pointer-events: none; }
/* Entrance motion runs only when the screen changes (#tablet.enter), not on every re-render */
@media (prefers-reduced-motion: no-preference) {
  #tablet.enter.from-idle .hex.h1 { animation: drift .9s .05s cubic-bezier(.2,.8,.2,1) both; }
  #tablet.enter.from-idle .hex.h2 { animation: drift .9s .15s cubic-bezier(.2,.8,.2,1) both; }
  #tablet.enter .main > *:not(.top) { animation: lift .4s cubic-bezier(.2,.8,.2,1) both; }
}
@keyframes lift { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes drift { from { transform: translate(24px, 24px) rotate(5deg); } to { transform: none; } }

/* Right: white working panel */
.main { position: relative; display: flex; flex-direction: column; padding: 28px 56px 40px; background: var(--white); overflow-y: auto; }
.main::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(to right, rgba(32,40,135,.04) 1px, transparent 1px); background-size: 208px 100%; background-position: 55px 0; pointer-events: none; }
.main > * { position: relative; }
.top { display: flex; justify-content: flex-end; align-items: center; min-height: 50px; margin-bottom: 24px; }
.lang-switch { display: inline-flex; border: 1px solid var(--hair); border-radius: 10px; overflow: hidden; background: var(--white); }
.lang-switch button { min-height: 50px; min-width: 120px; padding: 0 20px; border: 0; background: var(--white); font-size: 16px; font-weight: 500; color: var(--slate); cursor: pointer; }
.lang-switch button + button { border-left: 1px solid var(--hair); }
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: var(--white); font-weight: 600; }
.foot { margin-top: auto; padding-top: 20px; display: grid; grid-template-columns: 1fr 1.35fr; gap: 16px; }
.foot.one { grid-template-columns: 1fr; }
.foot.back { grid-template-columns: auto 1fr; }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }

/* Buttons (≥ 44 px; main actions 76 px for standing use at arm's length) */
.btn { min-height: 76px; padding: 0 32px; border-radius: var(--radius); border: 1px solid var(--edge); background: var(--white); color: var(--ink); font-size: 21px; font-weight: 600; letter-spacing: -0.01em; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 12px; box-shadow: 0 1px 2px rgba(20,26,79,.06); }
.btn.primary { background: var(--p-blue); border-color: var(--p-blue); color: var(--white); box-shadow: 0 1px 2px rgba(20,26,79,.2), 0 12px 24px -12px rgba(60,60,248,.7); }
.btn.primary:active { background: var(--p-blue-press); }
.btn.ghost { border-color: transparent; box-shadow: none; color: var(--slate); min-width: 160px; }
.btn:disabled { background: var(--canvas); color: #9a9fbd; border-color: var(--hair); box-shadow: none; cursor: not-allowed; }
.btn:focus-visible, .choice:focus-visible, .chip:focus-visible, .lang-switch button:focus-visible, .lang-card:focus-visible, .field input:focus-visible { outline: 3px solid var(--p-blue); outline-offset: 3px; }

/* Amount sheet (FR-14): label over value, pay before receive */
.sheet { background: var(--white); border: 1px solid var(--hair); border-radius: 14px; box-shadow: 0 1px 2px rgba(20,26,79,.06), 0 16px 32px -20px rgba(32,40,135,.28); position: relative; }
.row { padding: 24px 32px 22px; }
.row + .row { border-top: 1px solid var(--hair); }
.lab { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--slate); }
.lab .dot { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--tint); color: var(--p-blue); }
.amt { font-size: 72px; font-weight: 700; letter-spacing: -0.035em; line-height: 1.04; margin-top: 8px; font-variant-numeric: tabular-nums; }
.amt .ccy { font-weight: 600; color: var(--slate); font-size: .56em; letter-spacing: -0.01em; margin-right: 14px; vertical-align: .12em; }
.amt .ccy.tight { margin-right: 2px; }
.sheet.compact .row { padding: 16px 24px 14px; }
.sheet.compact .amt { font-size: 44px; margin-top: 4px; }
.sheet.compact .lab { font-size: 14px; }
.swap { position: absolute; right: 32px; top: calc(50% - 26px); width: 52px; height: 52px; border-radius: 50%; background: var(--white); border: 1px solid var(--hair); color: var(--p-blue); display: grid; place-items: center; box-shadow: 0 6px 14px -8px rgba(32,40,135,.4); }
.facts { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: var(--tint); border-top: 1px solid var(--hair); border-radius: 0 0 14px 14px; padding: 15px 32px; font-size: 18px; color: var(--slate); }
.facts b { color: var(--ink); font-weight: 600; }
.facts .lock { display: inline-flex; gap: 8px; align-items: center; color: var(--ink); font-weight: 600; }
.facts .lock svg { color: var(--p-blue); }
.sheet.compact .facts { padding: 12px 24px; font-size: 16px; }

/* Notices */
.notice { display: flex; gap: 12px; align-items: center; background: var(--tint); border: 1px solid #d9daff; border-radius: 12px; padding: 14px 18px; margin: 0 0 18px; font-size: 18px; font-weight: 600; color: var(--ink); }
.notice .ico { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--p-blue); color: var(--white); display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.error { font-weight: 600; font-size: 17px; margin-top: 8px; display: flex; gap: 8px; align-items: flex-start; color: var(--ink); }
.error::before { content: "!"; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--white); display: grid; place-items: center; font-size: 13px; font-weight: 800; margin-top: 1px; }

/* Choice cards (S-14, S-17) */
.choices { display: grid; gap: 16px; }
.choice { min-height: 132px; border: 1px solid var(--hair); border-radius: 14px; background: var(--white); font-size: 26px; font-weight: 600; letter-spacing: -0.015em; padding: 24px 28px; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 22px; box-shadow: 0 1px 2px rgba(20,26,79,.06), 0 14px 28px -22px rgba(32,40,135,.35); }
.choice .ico { width: 60px; height: 60px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--tint); color: var(--p-blue); }
.choice .chev { margin-left: auto; color: var(--slate); }
.choice[aria-pressed="true"] { border: 2px solid var(--p-blue); background: var(--tint); }
.choice:disabled { opacity: .45; cursor: not-allowed; }

/* Single-choice chips (S-15, S-16) */
.q { margin: 0 0 16px; }
.q-label { font-size: 15px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--slate); margin: 0 0 10px; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.chip { min-height: 58px; border: 1px solid var(--edge); border-radius: 10px; background: var(--white); font-size: 17px; font-weight: 500; padding: 6px 14px; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 10px; line-height: 1.25; }
.chip::before { content: ""; flex: none; width: 20px; height: 20px; border: 1.5px solid var(--edge); border-radius: 50%; background: var(--white); }
.chip[aria-checked="true"] { border: 2px solid var(--p-blue); background: var(--tint); font-weight: 600; padding: 5px 13px; }
.chip[aria-checked="true"]::before { border: 6px solid var(--p-blue); }

.field { margin: 0 0 16px; }
.field label { display: block; font-size: 15px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--slate); margin-bottom: 8px; }
.field input { width: 100%; min-height: 62px; font-size: 22px; padding: 0 18px; border: 1px solid var(--edge); border-radius: 10px; background: var(--white); box-shadow: 0 1px 2px rgba(20,26,79,.05); }
.field input[aria-invalid="true"] { border: 2px solid var(--ink); }
.other-input { margin: 10px 0 0; }

/* Camera placeholders: no real camera in the prototype */
.camera { position: relative; flex: 1; min-height: 0; background: #0d1033; color: #eef0ff; border-radius: 14px; display: grid; place-items: center; overflow: hidden; }
.camera .hint { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(13,16,51,.78); padding: 14px 20px; font-size: 19px; text-align: center; }
.camera .tag { position: absolute; top: 12px; left: 14px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--p-lavender); }
.face-oval { width: 240px; height: 310px; border: 4px dashed var(--p-lavender); border-radius: 50%; }
.face-oval.live { animation: breathe 1.6s ease-in-out infinite; }
.doc-frame { width: 440px; height: 278px; border: 4px dashed var(--p-lavender); border-radius: 12px; }
.doc-photo { width: 440px; height: 278px; background: #e8e9f5; border-radius: 8px; display: grid; place-items: center; color: var(--slate); font-size: 17px; }
.doc-photo.blurry { filter: blur(3px); }
@keyframes breathe { 50% { transform: scale(1.03); } }

.spinner { width: 64px; height: 64px; border: 6px solid var(--tint); border-top-color: var(--p-blue); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 26px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .face-oval.live { animation: none; } .spinner { border-right-color: var(--p-blue); } }

.big-ico { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 26px; background: var(--tint); color: var(--p-blue); }
.big-ico.solid { background: var(--p-blue); color: var(--white); box-shadow: 0 16px 30px -14px rgba(60,60,248,.8); }
.state-msg { font-size: 34px; font-weight: 700; letter-spacing: -0.025em; max-width: 640px; margin: 0 auto 12px; line-height: 1.2; text-wrap: balance; }
.state-sub { font-size: 21px; color: var(--slate); max-width: 620px; margin: 0 auto; }

/* Face check intro */
.dont { display: flex; gap: 22px; justify-content: center; margin: 8px 0 30px; }
.dont div { width: 120px; text-align: center; font-size: 16px; color: var(--slate); }
.dont span { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 8px; border-radius: 50%; background: var(--tint); color: var(--p-blue); position: relative; }
.dont span::after { content: ""; position: absolute; width: 86px; height: 3px; background: var(--ink); transform: rotate(-45deg); border-radius: 2px; }

/* Signature */
.consent { font-size: 18px; margin: 18px 0 10px; color: var(--ink); }
.sig-wrap { position: relative; border: 1px solid var(--edge); border-radius: 12px; height: 200px; background: var(--white); touch-action: none; box-shadow: inset 0 1px 2px rgba(20,26,79,.05); }
.sig-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.sig-wrap .baseline { position: absolute; left: 28px; right: 28px; bottom: 52px; border-bottom: 1.5px dashed var(--edge); pointer-events: none; }
.sig-wrap .ph { position: absolute; left: 28px; bottom: 20px; color: var(--slate); font-size: 16px; pointer-events: none; }

/* Full-bleed screens: idle (S-10) */
.idle { position: absolute; inset: 0; background: var(--p-navy); color: var(--white); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow: hidden; }
.idle > *:not(.hex) { position: relative; z-index: 1; }
.idle .logo-box { width: 150px; height: 100px; font-size: 16px; border-radius: 14px; margin-bottom: 22px; }
.idle .name { font-size: 30px; font-weight: 600; color: #e6e7ff; margin-bottom: 44px; letter-spacing: -0.01em; }
.idle p { margin: 6px 0; font-size: 38px; font-weight: 700; letter-spacing: -0.03em; }
.idle p + p { font-size: 26px; font-weight: 500; color: var(--p-lavender); letter-spacing: -0.01em; }

/* Language choice (S-11) */
.lang-cards { display: grid; gap: 18px; }
.lang-card { min-height: 150px; border: 1px solid var(--hair); border-radius: 16px; background: var(--white); cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 0 36px; font-size: 36px; font-weight: 700; letter-spacing: -0.03em; box-shadow: 0 1px 2px rgba(20,26,79,.06), 0 16px 32px -22px rgba(32,40,135,.35); }
.lang-card small { display: block; font-size: 17px; font-weight: 500; color: var(--slate); letter-spacing: 0; margin-top: 4px; text-align: left; }
.lang-card .go { width: 56px; height: 56px; border-radius: 50%; background: var(--p-blue); color: var(--white); display: grid; place-items: center; flex: none; }

/* Overlays (S-21, S-26) */
.overlay { position: absolute; inset: 0; background: rgba(20,26,79,.55); display: grid; place-items: center; z-index: 10; backdrop-filter: blur(2px); }
.overlay .card { background: var(--white); border-radius: 18px; padding: 44px 52px; min-width: 560px; max-width: 760px; text-align: center; box-shadow: 0 30px 60px -20px rgba(20,26,79,.6); }
.overlay .card .state-msg { margin-bottom: 26px; }

.frozen-badge { position: absolute; right: 10px; bottom: 10px; font-size: 12px; background: var(--ink); color: var(--white); padding: 3px 9px; border-radius: 6px; z-index: 20; opacity: .75; pointer-events: none; }

/* ---------- Facilitator panel ---------- */
.p-head { position: sticky; top: 0; z-index: 3; background: var(--ink); color: var(--white); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.p-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.p-head small { display: block; font-size: 11.5px; font-weight: 400; color: var(--p-lavender); }
.p-head button { background: transparent; color: var(--white); border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.p-body { padding: 14px 14px 28px; display: grid; gap: 12px; }
.p-card { background: var(--white); border: 1px solid var(--hair); border-radius: 12px; padding: 14px; display: grid; gap: 10px; box-shadow: 0 1px 2px rgba(20,26,79,.04); }
.p-k { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--slate); }
.p-card select, .p-card input[type=number] { width: 100%; min-height: 36px; padding: 4px 8px; border: 1px solid var(--edge); border-radius: 8px; background: var(--white); font-size: 14px; }
.p-note { font-size: 13px; color: var(--slate); line-height: 1.45; }
.p-status { font-size: 16px; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; }
.p-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--slate); }
.p-meta .timer { font-family: var(--mono); font-size: 13px; color: var(--ink); font-weight: 600; }
.p-actions { display: grid; gap: 8px; }
.p-actions .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pbtn { min-height: 40px; padding: 6px 12px; border: 1px solid var(--edge); border-radius: 8px; background: var(--white); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; text-align: center; }
.pbtn.pri { background: var(--p-blue); border-color: var(--p-blue); color: var(--white); }
.pbtn.link { border: 0; background: transparent; color: var(--slate); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; min-height: 32px; justify-self: start; padding: 4px 2px; }
.pbtn:focus-visible { outline: 3px solid var(--p-blue); outline-offset: 2px; }
.pbtn:disabled { opacity: .4; cursor: not-allowed; }
details.p-more { background: var(--white); border: 1px solid var(--hair); border-radius: 12px; }
details.p-more > summary { list-style: none; cursor: pointer; padding: 12px 14px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
details.p-more > summary::-webkit-details-marker { display: none; }
details.p-more > summary::after { content: "+"; font-size: 16px; color: var(--slate); }
details.p-more[open] > summary::after { content: "–"; }
details.p-more > div { padding: 0 14px 14px; display: grid; gap: 10px; }
.p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.p-grid label, .p-field label { display: block; font-size: 12px; color: var(--slate); margin-bottom: 3px; }
.p-check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.p-sub { font-size: 12px; font-weight: 600; color: var(--slate); margin-top: 4px; }
.p-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.p-chips .pbtn { min-height: 34px; font-size: 13px; font-weight: 500; padding: 4px 10px; }

/* Money banner mirror: shape + icon + text, colour-independent (FR-25) */
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.banner .b-ico { flex: none; width: 26px; height: 26px; display: grid; place-items: center; font-size: 14px; }
.banner small { display: block; font-weight: 500; color: var(--slate); }
.banner.unsafe { border: 2px dashed var(--ink); background: var(--white); }
.banner.unsafe .b-ico { border: 2px solid var(--ink); border-radius: 4px; transform: rotate(45deg); }
.banner.unsafe .b-ico span { transform: rotate(-45deg); }
.banner.safe { border: 2px solid var(--p-blue); background: var(--tint); }
.banner.safe .b-ico { background: var(--p-blue); color: var(--white); border-radius: 50%; }
.banner.none { border: 1px solid var(--hair); color: var(--slate); font-weight: 500; }

.log { font-family: var(--mono); font-size: 11px; max-height: 220px; overflow-y: auto; background: var(--canvas); border: 1px solid var(--hair); border-radius: 8px; padding: 6px 8px; }
.log div { padding: 2px 0; border-bottom: 1px dotted var(--hair); }
.p-times { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 12.5px; }
.p-times span:nth-child(even) { font-family: var(--mono); text-align: right; }
.p-times .tot { font-weight: 700; border-top: 1px solid var(--hair); padding-top: 4px; margin-top: 2px; }
