/* Tensai client portal — what it adds to the staff portal's design system (app.css, loaded
 * first). Only tokens from app.css are used, so light and dark come from the same lines and
 * keep the contrast app.css is checked for. Pages use the full width of the window, with
 * gutters that grow with it; text keeps a readable measure. */

body.cp { --cp-gutter: clamp(16px, 2.5vw + 8px, 64px); background: var(--canvas); min-height: 100vh; display: flex; flex-direction: column; }

/* ── shell: a navy top bar (the staff portal's sidebar colour) ──────── */
.cp-top { position: sticky; top: 0; z-index: 40; background: var(--nav-bg); color: var(--nav-text-2); border-bottom: 1px solid var(--nav-line); }
.cp-top-in { padding: 0 var(--cp-gutter); min-height: 60px; display: flex; align-items: center; gap: 28px; }
.cp-brand { display: flex; align-items: center; gap: 11px; color: var(--nav-text); text-decoration: none; flex: 0 0 auto; }
.cp-brand:hover { text-decoration: none; }
.cp-brand-name { display: grid; gap: 5px; font: 600 1rem/1.15 var(--font); letter-spacing: .01em; }
.cp-brand-name small { font: 400 .76rem/1.2 var(--font); color: var(--nav-muted); letter-spacing: 0; max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-theme { list-style: none; cursor: pointer; width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center;
  background: transparent; color: var(--nav-text-2); border: 1px solid transparent; }
.cp-theme:hover { background: rgba(255, 255, 255, .1); color: var(--nav-text); }
.cp-auth-foot .cp-theme { display: inline-grid; vertical-align: middle; color: var(--muted); width: 32px; height: 32px; }
.cp-auth-foot .cp-theme:hover { background: var(--surface-3); color: var(--text); }
.cp-nav { display: flex; align-items: stretch; align-self: stretch; gap: 2px; flex: 1 1 auto; min-width: 0; }
.cp-link { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--nav-text-2); font-weight: 450; white-space: nowrap; text-decoration: none; }
.cp-link .i { width: 17px; height: 17px; opacity: .85; }
.cp-link:hover { color: var(--nav-text); background: rgba(255, 255, 255, .06); text-decoration: none; }
.cp-link.is-active { color: var(--nav-text); font-weight: 550; }
.cp-link.is-active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px; background: var(--nav-accent); }
.cp-link.is-active .i { opacity: 1; color: var(--nav-accent); }
.cp-right { display: flex; align-items: center; gap: 12px; margin-left: auto; flex: 0 0 auto; }
.cp-top .env { background: transparent; color: #f6c97a; border-color: rgba(246, 201, 122, .5); }
.cp-top .env::before { background: #f6c97a; }
.cp-top .env-staging { color: #a9c6ff; border-color: rgba(169, 198, 255, .5); }
.cp-top .env-staging::before { background: #a9c6ff; }
.cp-top .badge.tone-accent { background: rgba(255, 255, 255, .12); color: var(--nav-text); }
.cp-avatar { list-style: none; cursor: pointer; width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center;
  background: rgba(255, 255, 255, .1); color: var(--nav-text); font: 600 .82rem/1 var(--font); border: 1px solid rgba(255, 255, 255, .22); }
.cp-avatar:hover { background: rgba(255, 255, 255, .16); }
.cp-avatar::-webkit-details-marker { display: none; }
.cp-menu { width: 290px; color: var(--text); }
.cp-menu-who { display: grid; gap: 2px; padding: 8px 10px; }
.dd-item.tone-bad-text, .dd-item.tone-bad-text .i { color: var(--bad-text); }

.cp-main { width: 100%; padding: 32px var(--cp-gutter) 56px; flex: 1 0 auto; container: page / inline-size; }
.cp-notice { margin-bottom: 20px; }
.cp-foot { width: 100%; padding: 18px var(--cp-gutter) 28px; display: flex; flex-wrap: wrap; gap: 6px 20px;
  color: var(--muted); font-size: .84rem; border-top: 1px solid var(--line); }
.cp-foot > :first-child { margin-right: auto; }
.cp-foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* ── signed-out pages ───────────────────────────────────────────────── */
.cp .auth { flex: 1 0 auto; }
.cp .auth-main { align-content: center; gap: 18px; }
.cp-auth-logo { display: none; }
.cp-auth-foot { text-align: center; }
.cp-auth-foot a { color: var(--muted); }
.cp-forgot { margin: -6px 0 14px; }
.cp-eyebrow { display: flex; align-items: center; gap: 8px; color: var(--accent-text); font: 600 .74rem/1.2 var(--font); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.cp-eyebrow .i { width: 15px; height: 15px; }
.cp-state-icon { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; margin-bottom: 18px;
  color: var(--b-fg, var(--accent-on-soft)); border: 1px solid currentColor; }
.cp-state-icon .i { width: 22px; height: 22px; }
.cp-progress { list-style: none; display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 24px; padding: 0; border-top: 1px solid var(--line); }
.cp-progress li { display: flex; align-items: center; gap: 10px; padding: 12px 0 0; color: var(--muted); font-size: .86rem; font-weight: 500; position: relative; }
.cp-progress li span { width: 22px; height: 22px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font: 500 .76rem/1 var(--mono); }
.cp-progress li.is-current { color: var(--text); font-weight: 600; }
.cp-progress li.is-current::before { content: ""; position: absolute; left: 0; right: 8px; top: -2px; height: 3px; background: var(--accent); }
.cp-progress li.is-current span { background: var(--accent); color: var(--accent-ink); }
.cp-pw { gap: 0 14px; }
.cp-terms .check { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; color: var(--text-2); font-weight: 400; }
.cp-terms .check .cb { margin-top: 3px; flex: 0 0 auto; }

/* ── licences ───────────────────────────────────────────────────────── */
.cp-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px var(--card-pad); margin-bottom: var(--gap);
  border-left: 3px solid var(--accent); flex-wrap: wrap; }
.cp-hero-body { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1 1 420px; }
.cp-hero-body h2 { font-size: 1.05rem; margin: 0 0 2px; }
.cp-hero-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; border: 1px solid var(--accent-soft-2); color: var(--accent-text); flex: 0 0 auto; }
.cp-section-title { margin: 28px 0 12px; }
.cp-section-title:first-child { margin-top: 0; }
.cp-offers { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: var(--gap); }
.cp-offer { display: flex; flex-direction: column; padding: var(--card-pad); gap: 14px; }
.cp-offer.is-live { border-top: 3px solid var(--accent); }
.cp-offer-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cp-offer-title { min-width: 0; }
.cp-offer-title h2 { font-size: 1.02rem; margin: 0; }
.cp-offer-icon { width: 32px; height: 32px; border-radius: var(--r-md); display: grid; place-items: center; flex: 0 0 auto;
  color: var(--b-fg, var(--accent-on-soft)); border: 1px solid var(--line); }
.cp-offer-icon .i { width: 17px; height: 17px; }
.cp-offer-facts { margin: 0; }
.cp-offer-actions { margin-top: auto; }
/* How it works, for someone with nothing collected yet. */
.cp-how { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); border-top: 1px solid var(--line); }
.cp-how > div { padding: 20px var(--card-pad); border-left: 1px solid var(--line); }
.cp-how > div:first-child { border-left: 0; }
.cp-how .n { font: 500 .78rem/1 var(--mono); color: var(--accent-text); letter-spacing: .06em; }
.cp-how h3 { color: var(--text); font-size: .95rem; text-transform: none; letter-spacing: 0; margin: 8px 0 4px; }
.cp-how p { color: var(--muted); font-size: .9rem; margin: 0; max-width: 46ch; }
@container page (max-width: 760px) {
  .cp-how > div { border-left: 0; border-top: 1px solid var(--line); }
  .cp-how > div:first-child { border-top: 0; }
}

/* ── collecting a licence ───────────────────────────────────────────── */
.cp-back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: 14px; font-size: .9rem; }
.cp-back .i { width: 15px; height: 15px; }
.cp-collect { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; }
.cp-step { padding: var(--card-pad); display: flex; flex-direction: column; }
.cp-step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.cp-step-head h2 { font-size: 1.02rem; margin: 0; }
.cp-step-n { width: 26px; height: 26px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 500 .86rem/1 var(--mono); flex: 0 0 auto; }
.cp-step-end { margin-top: auto; padding-top: 12px; }
.cp-open { width: 100%; justify-content: center; margin: 4px 0 12px; }
.cp-qr { display: grid; justify-items: center; gap: 10px; margin: 4px 0 12px; }
.cp-qr img { width: clamp(180px, 14vw, 240px); height: auto; aspect-ratio: 1; }
.cp-qr-more > summary { cursor: pointer; color: var(--accent-text); font-size: .9rem; margin-bottom: 10px; }
.cp-pin { display: flex; gap: clamp(4px, 1.4vw, 8px); margin: 6px 0 14px; }
.cp-pin span { width: clamp(38px, 11vw, 48px); height: clamp(48px, 13vw, 60px); display: grid; place-items: center; border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--surface-2); font: 500 clamp(1.35rem, 5vw, 1.75rem)/1 var(--mono); color: var(--text); }
.cp-fineprint { display: flex; align-items: center; gap: 6px; margin-top: 16px; max-width: 100ch; }
.cp-done { display: flex; gap: 16px; align-items: flex-start; }
.cp-done .cp-state-icon { margin: 0; }
.cp-done h2 { font-size: 1.1rem; margin: 2px 0 4px; }

/* ── the app ────────────────────────────────────────────────────────── */
.cp-download { justify-content: center; }
.cp-size { font-weight: 400; margin-left: 4px; font-family: var(--mono); font-size: .86em; }
.cp-notes { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.cp-app-qr { margin: 0 auto 12px; }
.cp-app-qr img { width: 200px; height: 200px; }
/* TR500 Simulator: the activation code beside its QR code */
.sim-code-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.sim-code-qr { margin: 0; }
.sim-code-qr img { width: 168px; height: 168px; }
.sim-code { font-size: 1.9rem; font-weight: 600; letter-spacing: .12em; margin: 2px 0 0; color: var(--text); }
.cp-grants { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cp-grants li { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.cp-grants .i { color: var(--ok-text); }
.cp-places { display: grid; gap: 8px; }
.cp-places-figure { font: 600 1.8rem/1 var(--font); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cp-places-figure small { font: 400 .9rem var(--font); color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.cp-account { max-width: 1280px; }

/* ── staff preview ──────────────────────────────────────────────────── */
.cp-preview { background: var(--warn-soft); border-bottom: 1px solid var(--warn-line); color: var(--text); }
.cp-preview-in { padding: 9px var(--cp-gutter); display: flex; align-items: center; gap: 14px; }
.cp-preview-icon { color: var(--warn-text); display: grid; }
.cp-preview-icon .i { width: 19px; height: 19px; }
.cp-preview-text { flex: 1; font-size: .88rem; line-height: 1.45; color: var(--text-2); }
.cp-preview-text strong { color: var(--text); }
.cp-redacted { display: flex; align-items: center; gap: 10px; padding: 16px; margin-bottom: 12px; border-radius: var(--r-md);
  border: 1px dashed var(--line-strong); background: var(--surface-2); color: var(--muted); font-size: .9rem; }
.cp-redacted .i { flex: 0 0 auto; }
.cp-pin-hidden span { color: var(--faint); }

/* ── narrower windows ───────────────────────────────────────────────── */
@container page (max-width: 1080px) {
  .cp-collect { grid-template-columns: 1fr; }
}
/* The sections' short names where the full ones would not fit; the bar never runs off the page
   (it scrolls sideways instead, with no scroll bar showing). */
.cp-short { display: none; }
.cp-nav { overflow-x: auto; scrollbar-width: none; }
.cp-nav::-webkit-scrollbar { display: none; }
@media (max-width: 1120px) {
  .cp-full { display: none; }
  .cp-short { display: inline; }
}
/* Between the tab bar and room for everything, the top bar's sections are words only. */
@media (min-width: 901px) and (max-width: 1120px) {
  .cp-link .i { display: none; }
}
@media (max-width: 1000px) {
  .cp-brand-name small { max-width: 16ch; }
  .cp-link { padding: 0 9px; }
}
/* Phones and tablets: the sections become a tab bar at the foot of the screen. */
@media (max-width: 900px) {
  .cp-top-in { min-height: 54px; gap: 12px; }
  .cp-nav { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; gap: 0;
    padding: 0 4px env(safe-area-inset-bottom); background: var(--nav-bg); border-top: 1px solid var(--nav-line); }
  .cp-link { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 3px; height: 58px; padding: 0 2px;
    font-size: .7rem; font-weight: 500; text-align: center; }
  .cp-link span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cp-link .i { width: 20px; height: 20px; }
  .cp-link.is-active::after { top: 0; bottom: auto; left: 22%; right: 22%; }
  body.cp:has(.cp-nav) { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .cp-top .env { display: none; }
  .cp-main { padding-top: 22px; padding-bottom: 36px; }
  .cp-preview-in { flex-wrap: wrap; gap: 6px 12px; padding-top: 8px; padding-bottom: 8px; }
  .cp-preview-text { flex-basis: calc(100% - 40px); font-size: .82rem; }
  .cp-preview-more { display: none; }
  .cp-preview-in .btn { margin-left: 31px; }
}
@media (max-width: 560px) {
  .cp-pw { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .cp-brand-name small { display: none; }
}

/* API documentation: the readers' references (rendered Markdown) and C# samples */
.doc-readers { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: var(--gap, 20px); align-items: start; }
.doc-links { display: grid; gap: 8px; }
.doc-link { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); color: var(--text); text-decoration: none; }
.doc-link:hover { border-color: var(--accent); background: var(--surface-2); }
.doc-link > svg { flex: none; margin-top: 2px; color: var(--accent-text); }
.doc-link strong { display: block; font-weight: 600; }
.doc-link span span { display: block; color: var(--muted); font-size: .88rem; margin-top: 2px; }
.doc-crumb { font-size: .85rem; color: var(--muted); margin: 0 0 4px; }
.doc-crumb a { color: var(--muted); }
.doc-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.doc-side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.doc-nav { display: flex; flex-direction: column; gap: 1px; }
.doc-nav .label { margin: 0 10px 6px; }
.doc-nav .doc-nav-sep { margin-top: 18px; }
.doc-nav-link, .doc-toc-link { display: block; padding: 6px 10px; border-radius: var(--r-sm); color: var(--text-2); text-decoration: none; font-size: .9rem; }
.doc-toc-link { padding: 4px 10px; font-size: .84rem; color: var(--muted); }
.doc-nav-link:hover, .doc-toc-link:hover { background: var(--surface-2); color: var(--text); }
.doc-nav-link.is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.doc-body { padding: 8px 32px 28px; min-width: 0; line-height: 1.6; }
.doc-body h2 { font-size: 1.3rem; margin: 30px 0 12px; padding-top: 22px; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.doc-body h2:first-child { margin-top: 18px; padding-top: 0; border-top: 0; }
.doc-body h3 { font-size: 1.05rem; margin: 24px 0 8px; scroll-margin-top: 16px; }
.doc-body p, .doc-body ul, .doc-body ol { margin: 0 0 12px; max-width: 82ch; }
.doc-body li { margin: 3px 0; }
.doc-body code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: .86em; overflow-wrap: anywhere; }
.doc-body h2 code { font-size: .9em; }
.doc-code { position: relative; margin: 0 0 16px; }
.doc-code pre { margin: 0; padding: 14px 16px; background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; line-height: 1.5; }
.doc-code pre code { background: none; border: 0; padding: 0; font-size: .84rem; overflow-wrap: normal; }
.doc-copy { position: absolute; top: 8px; right: 8px; }
.doc-table { margin: 0 0 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.doc-table table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.doc-table th, .doc-table td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.doc-table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.doc-table tr:last-child td { border-bottom: 0; }
@media (max-width: 960px) {
  .doc-layout { grid-template-columns: 1fr; }
  .doc-toc { display: none; }
  .doc-side { position: static; max-height: none; }
  .doc-body { padding: 4px 18px 22px; }
  .doc-readers { grid-template-columns: 1fr; }
}

/* The NDA page: the agreement scrolls inside the card, so the signature form stays in reach. */
.cp-nda-text { max-height: min(52vh, 560px); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 14px 0 18px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); color: var(--text);
  font-size: .9rem; line-height: 1.55; }
.cp-nda-text:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cp-nda-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .84rem; }

/* A deed: the PDF in a frame tall enough to read a page, the signature form below it. Phones
   do not show PDFs in frames, so they get the link to open it instead. */
.auth-card.cp-deed { max-width: min(1040px, 100%); }
@media (min-width: 901px) { .auth:has(.cp-deed) { grid-template-columns: minmax(300px, .5fr) minmax(0, 1.5fr); } }
.cp-nda-intro { margin: 0 0 12px; color: var(--text); }
.cp-nda-open { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.cp-deed-frame { display: block; width: 100%; height: min(78vh, 980px); margin: 12px 0 8px; border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--surface-2); }
.cp-deed-small { margin: 0 0 18px; }
.cp-deed-fields { grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 720px) {
  .cp-deed-frame { display: none; }
  .cp-nda-open { margin-left: 0; }
  .cp-deed-fields { grid-template-columns: 1fr; }
}

/* ── licence requests ──────────────────────────────────────────────────────── */
.cp-quota { font-variant-numeric: tabular-nums; }
.cp-requests { margin-bottom: var(--gap); }
.cp-req-list { list-style: none; margin: 0; padding: 0; }
.cp-req { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px var(--card-pad); border-top: 1px solid var(--line); }
.cp-req:first-child { border-top: 0; }
.cp-req-main { display: grid; gap: 3px; min-width: 0; }
.cp-req-name { font-weight: 600; }
.cp-req-reason { margin: 6px 0 0; padding: 8px 12px; border-left: 3px solid var(--bad-text); background: var(--surface-2); font-size: .9rem; max-width: 70ch; }
.cp-req-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.cp-req-side form { margin: 0; }
.cp-req-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--gap); align-items: start; }
.cp-quota-big { margin: 0 0 10px; font-size: .95rem; color: var(--muted); }
.cp-quota-big strong { font: 600 1.6rem/1 var(--mono); color: var(--text); margin-right: 4px; font-variant-numeric: tabular-nums; }
.cp-steps { list-style: none; margin: 0; padding: 0; }
.cp-steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 14px var(--card-pad); border-top: 1px solid var(--line); }
.cp-steps li:first-child { border-top: 0; }
.cp-steps .n { font: 500 .78rem/1.4rem var(--mono); color: var(--accent-text); letter-spacing: .06em; }
.cp-steps h3 { color: var(--text); font-size: .92rem; text-transform: none; letter-spacing: 0; margin: 0 0 3px; }
.cp-steps p { color: var(--muted); font-size: .86rem; margin: 0; }
@media (max-width: 960px) {
  .cp-req-layout { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .cp-req { flex-direction: column; }
  .cp-req-side { justify-content: flex-start; }
}

/* The preview's "view as" menu: the organisation, or one of its people. */
.cp-preview-as > summary { list-style: none; }
.cp-preview-as > summary::-webkit-details-marker { display: none; }
.cp-preview-as .dd-panel { min-width: 280px; right: 0; left: auto; }
@media (max-width: 720px) { .cp-preview-in { flex-wrap: wrap; } }
