/* The partner portal (docs/partners.md). Tokens, keys, plates, fields and
   LEDs come from the site's stylesheet (../css/style.css), loaded before
   this one. The frame is the app layout in DESIGN.md: a rail on the wall
   and one content plate. */

.p-body { display: block; background: var(--wall); font-size: 1rem; line-height: 1.5; }
.p-noscript { max-width: 460px; margin: 20vh auto; padding: 0 20px; text-align: center; }
.p-body h1, .p-body h2 { text-shadow: var(--engrave); }
.p-body select.input { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.p-body .btn[disabled] { opacity: 0.5; cursor: default; }
.p-body .btn[disabled]:active { transform: none; }

.p-textkey { padding: 0; border: 0; background: none; color: var(--ink); font-size: inherit; font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; cursor: pointer; }
.p-textkey:hover { text-decoration-thickness: 2px; }

.p-state { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 0.875rem; font-weight: 600; white-space: nowrap; }
.p-error { margin-top: 12px; color: var(--danger); font-size: 0.9375rem; font-weight: 550; }
.p-error[hidden] { display: none; }

/* ── The entrance: one plate on the wall ─────────────────────────────── */

.p-entry { min-height: 100vh; min-height: 100dvh; display: grid; justify-items: center; align-content: start; padding: max(32px, 46vh - 190px) 16px 96px; }
.p-entry-plate { width: min(460px, 100%); padding: 22px 32px 0; overflow: hidden; }
.p-entry-status { margin-bottom: 14px; }
.p-entry-plate h1 { font-size: clamp(1.5rem, 1.05rem + 2vw, 2.125rem); font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; }
.p-entry-note { margin-top: 6px; color: var(--ink-2); overflow-wrap: anywhere; }
.p-entry-row { display: flex; gap: 8px; margin-top: 20px; }
.p-entry-row .input { flex: 1; min-width: 0; }
.p-entry-row .btn { padding: 0 18px; }
.p-code { font-size: 1.5rem; letter-spacing: 0.3em; text-align: center; padding-left: calc(14px + 0.3em); }
.p-entry-label { display: block; margin: 20px 0 6px; font-size: 0.875rem; font-weight: 600; }
.p-entry-where { min-height: 84px !important; }
.p-entry-hint { margin-top: 6px; color: var(--ink-2); font-size: 0.875rem; }
.p-entry-terms { margin-top: 16px; font-size: 0.9375rem; }
.p-entry-wide { width: 100%; margin-top: 20px; }
.p-entry-plate .groove { margin: 24px -32px 0; }
.p-entry-service { padding: 14px 0; font-size: 0.875rem; }
.p-entry-service a, .p-entry-service .p-textkey { font-weight: 550; }
.p-maker { position: fixed; left: 24px; bottom: 20px; display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 0.9375rem; font-weight: 700; font-stretch: calc(var(--wide) * 1%); text-decoration: none; }
.p-maker .mark { width: 22px; height: 22px; color: inherit; }

/* ── The frame ───────────────────────────────────────────────────────── */

.p-shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 8px; max-width: 1280px; margin: 0 auto; padding: 20px 20px 48px 12px; align-items: start; }
.p-rail { position: sticky; top: 20px; display: flex; flex-direction: column; min-height: calc(100vh - 68px); padding: 6px 12px 0; }
.p-brand { margin: 4px 0 26px 12px; font-size: 1.0625rem; line-height: 1.15; }
.p-brand small { display: block; color: var(--ink-2); font-size: 0.8125rem; font-weight: 600; font-stretch: 100%; }
.p-rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.p-rail nav a { display: flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: var(--radius); color: var(--ink-2); font-weight: 550; text-decoration: none; }
.p-rail nav a:hover { color: var(--ink); background: var(--plate-lo); }
.p-rail nav a[aria-current] { color: var(--ink); background: var(--plate-fill); box-shadow: var(--plate-shadow); }
.p-rail-foot { margin-top: auto; padding: 24px 12px 0; display: grid; gap: 6px; justify-items: start; font-size: 0.875rem; }
.p-rail-foot .scheme { margin: 0 0 10px; }
.p-who { max-width: 100%; overflow: hidden; color: var(--ink-2); text-overflow: ellipsis; white-space: nowrap; }

.p-screen { min-height: calc(100vh - 68px); padding: 36px 40px 56px; outline: none; transition: opacity 160ms var(--ease-out); }
.p-screen[aria-busy='true'] { opacity: 0.55; }
.p-screen > * { max-width: 860px; }

.p-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 28px; }
.p-head h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 2.875rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; overflow-wrap: anywhere; }
.p-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--ink-2); font-size: 0.9375rem; font-weight: 550; text-decoration: none; }
.p-back::before { content: ''; width: 7px; height: 7px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.p-back:hover { color: var(--ink); text-decoration: underline; }

.p-block { margin-top: 44px; }
.p-block h2 { font-size: 1.3125rem; font-weight: 650; }
.p-block > h2, .p-block-head { margin-bottom: 16px; }
.p-block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; }
.p-block-head a { font-size: 0.9375rem; font-weight: 550; }
.p-hint { color: var(--ink-2); font-size: 0.9375rem; max-width: 68ch; }
.p-block > .p-hint { margin: -8px 0 16px; }
.p-empty { padding: 28px 24px; border-radius: var(--radius); background: var(--recess); box-shadow: var(--recess-shadow); color: var(--ink-2); max-width: 68ch; }
.p-notice { margin-bottom: 24px; padding: 14px 18px; border-radius: var(--radius); background: var(--recess); box-shadow: var(--recess-shadow); font-size: 0.9375rem; }
.p-foot-link { margin-top: 14px; font-size: 0.9375rem; }
.p-tools { margin-bottom: 14px; }

.p-seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius); background: var(--recess); box-shadow: var(--recess-shadow); }
.p-seg a { padding: 5px 12px; border-radius: 6px; color: var(--ink-2); font-size: 0.875rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.p-seg a:hover { color: var(--ink); }
.p-seg a[aria-current] { background: var(--plate-fill); color: var(--ink); box-shadow: 0 0 0 1px var(--edge), 0 1px 2px rgb(0 0 0 / 0.15); }

/* ── The till: held, ready, paid out ─────────────────────────────────── */

.p-till { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border-radius: var(--radius); background: var(--recess); box-shadow: var(--recess-shadow); }
.p-till > div { padding: 20px 24px 22px; }
.p-till > div + div { background: linear-gradient(90deg, var(--groove-dark) 0 1px, var(--groove-light) 1px 2px) left / 2px 100% no-repeat; }
.p-till dt { margin-bottom: 10px; }
.p-till dd { margin: 0; font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2rem); font-weight: 650; font-stretch: calc(var(--wide) * 1%); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; line-height: 1.1; }
.p-till p { margin-top: 8px; color: var(--ink-2); font-size: 0.875rem; line-height: 1.4; }

/* ── From a click to a sale ──────────────────────────────────────────── */

.p-funnel { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 0; }
.p-funnel li { display: grid; gap: 2px; padding: 4px 20px 4px 0; }
.p-funnel li + li { padding-left: 22px; background: linear-gradient(90deg, var(--groove-dark) 0 1px, var(--groove-light) 1px 2px) left / 2px 100% no-repeat; }
.p-funnel-name { font-size: 0.875rem; font-weight: 600; }
.p-funnel b { font-size: 1.75rem; font-weight: 650; font-stretch: calc(var(--wide) * 1%); font-variant-numeric: tabular-nums; line-height: 1.15; }
.p-funnel-note { color: var(--ink-2); font-size: 0.8125rem; }

.p-charts { margin-top: 28px; display: grid; gap: 14px; }
.p-chart { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: end; }
.p-chart-name { color: var(--ink-2); font-size: 0.875rem; font-weight: 600; line-height: 1.2; }
.p-chart-name b { display: block; color: var(--ink); font-size: 1.0625rem; font-variant-numeric: tabular-nums; }
.p-bars { display: flex; align-items: flex-end; gap: 2px; height: 56px; padding: 0 0 1px; border-bottom: 1px solid var(--groove-dark); box-shadow: 0 1px 0 var(--groove-light); }
.p-bars i { flex: 1; min-width: 1px; max-width: 28px; height: max(var(--h), 1px); border-radius: 2px 2px 0 0; background: var(--ink-2); transition: background-color 120ms var(--ease-out); }
.p-bars i[style*=':0%'] { background: var(--edge); }
.p-bars i:hover { background: var(--ink); }
.p-chart-axis { display: flex; justify-content: space-between; margin-left: 128px; color: var(--ink-3); font-size: 0.8125rem; }
.p-chart-foot { margin-top: 18px; color: var(--ink-2); font-size: 0.9375rem; }
.p-chart-foot b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ── The ledger: rows that open into a receipt ───────────────────────── */

.p-sales { border-radius: var(--radius); background: var(--recess); box-shadow: var(--recess-shadow); overflow: hidden; }
.p-sale + .p-sale { background: linear-gradient(var(--groove-dark) 0 1px, var(--groove-light) 1px 2px) top / 100% 2px no-repeat; }
.p-sale summary { display: grid; grid-template-columns: 108px minmax(0, 1fr) auto 104px 14px; gap: 16px; align-items: center; min-height: 60px; padding: 10px 18px 10px 20px; cursor: pointer; list-style: none; }
.p-sale summary::-webkit-details-marker { display: none; }
.p-sale summary::after { content: ''; width: 7px; height: 7px; border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2); transform: translateY(-2px) rotate(45deg); transition: transform 160ms var(--ease-out); }
.p-sale[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.p-sale summary:hover { background: color-mix(in srgb, var(--plate-lo) 55%, transparent); }
.p-sale summary:focus-visible { outline-offset: -3px; border-radius: 6px; }
.p-sale-day { color: var(--ink-2); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.p-sale-what { display: grid; min-width: 0; line-height: 1.3; }
.p-sale-what b { font-weight: 650; font-stretch: calc(var(--wide) * 1%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-sale-what span { overflow: hidden; color: var(--ink-2); font-size: 0.8125rem; text-overflow: ellipsis; white-space: nowrap; }
.p-sale-amount { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.p-sale-amount.is-minus { color: var(--ink-2); }

.p-receipt { margin: 0 20px 20px 144px; padding: 4px 20px 16px; max-width: 520px; border-radius: var(--radius); background: var(--plate-fill); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.8), 0 0 0 1px var(--edge), 0 1px 2px rgb(0 0 0 / 0.08); }
.p-receipt dl { margin: 0; }
.p-receipt dl > div, .p-receipt-total { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; padding: 10px 0; }
.p-receipt dl > div + div { background: linear-gradient(var(--groove-dark) 0 1px, var(--groove-light) 1px 2px) top / 100% 2px no-repeat; }
.p-receipt dt { font-size: 0.9375rem; }
.p-receipt dt small { display: block; color: var(--ink-2); font-size: 0.8125rem; line-height: 1.35; }
.p-receipt dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.p-receipt-total { margin-top: 2px; padding-top: 14px; border-top: 2px solid var(--ink); font-weight: 650; }
.p-receipt-total b { font-size: 1.1875rem; font-stretch: calc(var(--wide) * 1%); font-variant-numeric: tabular-nums; }
.p-receipt-note { margin-top: 6px; color: var(--ink-2); font-size: 0.875rem; }
.p-receipt dl:empty + .p-receipt-note, .p-receipt > .p-receipt-note:first-child { padding-top: 12px; }

.p-pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 18px; color: var(--ink-2); font-size: 0.875rem; }
.p-pager > :last-child { justify-self: end; }
.p-pager > :first-child { justify-self: start; }

/* ── Tables ──────────────────────────────────────────────────────────── */

.p-table { overflow-x: auto; border-radius: var(--radius); background: var(--recess); box-shadow: var(--recess-shadow); }
.p-table table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.p-table th, .p-table td { padding: 14px 16px; text-align: left; vertical-align: top; font-weight: 400; }
.p-table thead th { padding: 11px 16px; color: var(--ink-2); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.p-table tbody tr { background: linear-gradient(var(--groove-dark) 0 1px, var(--groove-light) 1px 2px) top / 100% 2px no-repeat; }
.p-table th:first-child, .p-table td:first-child { padding-left: 20px; }
.p-table th:last-child, .p-table td:last-child { padding-right: 20px; }
.p-table .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.p-table tbody th a { font-weight: 650; font-stretch: calc(var(--wide) * 1%); }
.p-table b { font-weight: 650; }
.p-cell-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; color: var(--ink-2); font-size: 0.8125rem; }
.p-cell-note .p-state { font-size: 0.8125rem; }

/* ── A campaign ──────────────────────────────────────────────────────── */

.p-link { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 0; padding: 8px 8px 8px 18px; border-radius: var(--radius); background: var(--recess); box-shadow: var(--recess-shadow); }
.p-link-text { min-width: 0; padding: 6px 0; font-family: var(--font-mono); font-size: 0.9375rem; overflow-wrap: anywhere; user-select: all; }
.p-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; margin-top: 14px; color: var(--ink-2); font-size: 0.9375rem; }
.p-facts > * + *::before { content: '·'; margin: 0 10px; color: var(--ink-3); }
.p-facts + .p-notice { margin: 18px 0 0; }

/* ── Forms ───────────────────────────────────────────────────────────── */

.p-form { display: grid; gap: 28px; max-width: 620px; }
.p-field { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.p-field > label:not(.p-choice), .p-field > legend, .p-pair > label { padding: 0; font-size: 0.9375rem; font-weight: 600; }
.p-field > legend { margin-bottom: 8px; }
.p-field > label + .input + label { margin-top: 10px; }
[data-landing] { display: grid; gap: 28px; }
[data-landing][hidden] { display: none; }
.p-optional { margin-left: 4px; color: var(--ink-3); font-size: 0.8125rem; font-weight: 400; }
.p-short { min-height: 84px !important; }
.p-static { padding: 11px 0 0; font-weight: 550; overflow-wrap: anywhere; }
.p-slug { display: flex; align-items: center; border-radius: var(--radius); background: var(--recess); box-shadow: var(--recess-shadow); }
.p-slug:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.p-slug span { flex: none; max-width: 55%; padding-left: 14px; overflow: hidden; color: var(--ink-2); font-family: var(--font-mono); font-size: 0.9375rem; text-overflow: ellipsis; white-space: nowrap; }
.p-slug .input { padding-left: 1px; background: none; box-shadow: none; font-family: var(--font-mono); font-size: 0.9375rem; }
.p-slug .input:focus { outline: none; box-shadow: none; }

.p-choice { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 12px; padding: 12px 14px; border-radius: var(--radius); cursor: pointer; }
.p-choice + .p-choice { margin-top: 2px; }
.p-choice:hover { background: color-mix(in srgb, var(--plate-lo) 70%, transparent); }
.p-choice:has(input:checked) { background: var(--recess); box-shadow: var(--recess-shadow); }
.p-choice input { appearance: none; display: grid; place-content: center; width: 18px; height: 18px; margin: 2px 0 0; border-radius: 50%; background: var(--recess); box-shadow: var(--recess-shadow); cursor: pointer; }
.p-choice input::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--key); transform: scale(0); transition: transform 140ms var(--ease-out); }
.p-choice input:checked::after { transform: scale(1); }
.p-choice span { color: var(--ink-2); font-size: 0.9375rem; line-height: 1.45; }
.p-choice b { display: block; color: var(--ink); font-weight: 650; }
.p-choice em { display: block; margin-top: 2px; font-style: normal; font-size: 0.8125rem; }
.p-choice a { display: inline-block; margin-top: 4px; font-size: 0.875rem; font-weight: 600; }
.p-methods { display: flex; flex-wrap: wrap; gap: 4px; }
.p-methods .p-choice { margin: 0; padding-right: 20px; }

.p-pair { display: grid; grid-template-columns: auto 120px auto 132px; gap: 10px 14px; align-items: center; justify-content: start; }
.p-unit { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 0.9375rem; }
.p-example { padding: 12px 16px; border-radius: var(--radius); background: var(--recess); box-shadow: var(--recess-shadow); font-size: 0.9375rem; font-variant-numeric: tabular-nums; max-width: 68ch; }
.p-example:empty { display: none; }
.p-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.p-saved[hidden] { display: none; }
.p-form > .p-error { margin: -12px 0; }

.p-ask { margin-top: 24px; }
.p-ask form { display: grid; gap: 10px; justify-items: start; }
.p-ask-note { color: var(--ink-2); font-size: 0.9375rem; max-width: 68ch; }

/* ── First run, and prose ────────────────────────────────────────────── */

.p-start { display: grid; gap: 22px; justify-items: start; max-width: 620px; }
.p-lede { color: var(--ink-2); font-size: 1.1875rem; line-height: 1.5; }
.p-quiet-link { font-size: 0.9375rem; font-weight: 550; }

.p-prose { max-width: 66ch; font-size: 1.0625rem; line-height: 1.6; }
.p-prose h2 { margin: 40px 0 10px; font-size: 1.3125rem; font-weight: 650; }
.p-prose h2:first-child { margin-top: 0; }
.p-prose p + p, .p-prose ul + p { margin-top: 12px; }
.p-prose ul { padding-left: 22px; display: grid; gap: 8px; }
.p-prose b { font-weight: 650; }

/* ── Narrow screens: the rail becomes a strip above the plate ────────── */

@media (max-width: 900px) {
  .p-shell { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 12px 12px 32px; }
  .p-rail { position: static; min-height: 0; padding: 0; }
  .p-brand { margin: 6px 0 12px 6px; }
  .p-rail nav { margin: 0 -12px; padding: 4px 12px 10px; overflow-x: auto; scrollbar-width: none; }
  .p-rail nav::-webkit-scrollbar { display: none; }
  .p-rail ul { display: flex; gap: 4px; width: max-content; }
  .p-rail nav a { white-space: nowrap; }
  .p-rail-foot { position: absolute; top: 14px; right: 14px; margin: 0; padding: 0; display: flex; align-items: center; gap: 12px; }
  .p-rail-foot .scheme { margin: 0; }
  .p-who { display: none; }
  .p-screen { min-height: 0; padding: 26px 20px 40px; }
  .p-receipt { margin: 0 14px 16px; }
}

@media (max-width: 640px) {
  .p-till { grid-template-columns: 1fr; }
  .p-till > div + div { background: linear-gradient(var(--groove-dark) 0 1px, var(--groove-light) 1px 2px) top / 100% 2px no-repeat; }
  .p-funnel { grid-template-columns: 1fr 1fr; gap: 18px 0; }
  .p-funnel li:nth-child(odd) { padding-left: 0; background: none; }
  .p-chart { grid-template-columns: 1fr; gap: 6px; }
  .p-chart-name b { display: inline; margin-left: 4px; }
  .p-chart-axis { margin-left: 0; }
  .p-sale summary { grid-template-columns: minmax(0, 1fr) auto 14px; gap: 2px 12px; padding: 12px 14px 12px 16px; }
  .p-sale-day { grid-column: 1; grid-row: 1; font-size: 0.8125rem; }
  .p-sale-what { grid-column: 1; grid-row: 2; }
  .p-sale-state { grid-column: 1; grid-row: 3; margin-top: 4px; }
  .p-sale-amount { grid-column: 2; grid-row: 1 / span 3; }
  .p-sale summary::after { grid-column: 3; grid-row: 1 / span 3; }
  .p-receipt { padding: 2px 16px 14px; }
  .p-sale-what b { white-space: normal; }
  .p-slug { flex-direction: column; align-items: stretch; }
  .p-slug span { max-width: none; padding: 10px 14px 0; }
  .p-slug .input { padding-left: 14px; }
  .p-pair { grid-template-columns: 1fr; }
  .p-pair > label { margin-top: 4px; }
  .p-unit .input { max-width: 132px; }
  .p-entry-plate { padding: 20px 24px 0; }
  .p-entry-plate .groove { margin: 22px -24px 0; }
  .p-entry-row { flex-direction: column; }
  .p-entry-row .btn { min-height: 46px; }
  .p-maker { position: static; margin-top: 40px; }
  .p-table th, .p-table td { padding: 12px 10px; }
  .p-table th:first-child, .p-table td:first-child { padding-left: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .p-screen, .p-sale summary::after, .p-choice input::after, .p-bars i { transition: none; }
}
