/* =====================================================================
   SURNAME STORY — Partner Portal
   Dashboard-specific styling. Builds on styles.css tokens + legal.css
   (header / footer). Warm, premium, editorial; gold accents, soft cards.
   ===================================================================== */

.partner-body { background: var(--ivory); min-height: 100vh; display: flex; flex-direction: column; }
.partner-body .foot { margin-top: auto; }
#partnerApp { flex: 1 0 auto; }

/* warm page wash behind everything */
.partner-body {
  background:
    radial-gradient(120% 70% at 12% -5%, #FBF4E4 0%, transparent 55%),
    radial-gradient(120% 80% at 100% 0%, #F3E7CC 0%, transparent 45%),
    var(--ivory);
}

.pi-state { padding-block: clamp(34px, 5vw, 64px); }

/* shared small label (matches .field > label weight) */
.pi-label { font-size: 13px; font-weight: 600; color: var(--ink); letter-spacing: .01em; }

/* ---------------------------------------------------------------- spinner */
.pi-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--gold);
  display: inline-block; animation: pi-spin .8s linear infinite;
}
.pi-spinner--gold { width: 44px; height: 44px; border-width: 4px; border-top-color: var(--gold-deep); }
.pi-spinner--sm { width: 22px; height: 22px; border-width: 2.5px; border-top-color: var(--gold-deep); }
@keyframes pi-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- loading state */
.pi-loading-wrap {
  min-height: 48vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; text-align: center;
}
.pi-loading-text { color: var(--muted); font-size: 15px; }

/* ================================================================= */
/*  AUTH (logged out)                                                 */
/* ================================================================= */
.pi-auth-wrap {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(32px, 5vw, 72px);
  align-items: center; max-width: 1080px; margin-inline: auto;
}
.pi-auth-intro .h2 { margin-top: 14px; }
.pi-auth-intro .lede { margin-top: 16px; max-width: 46ch; }
.pi-bullets { list-style: none; margin: 26px 0 0; display: flex; flex-direction: column; gap: 13px; }
.pi-bullets li { display: flex; align-items: flex-start; gap: 11px; font-size: 15px; color: var(--ink); }
.pi-bullets svg { width: 19px; height: 19px; color: var(--gold-deep); flex: none; margin-top: 2px; }
.pi-guide-link { margin-top: 28px; }
.pi-guide-link .link-arrow { font-size: 14.5px; }

/* auth card */
.pi-auth-card { padding: clamp(22px, 3vw, 34px); border-radius: var(--r-lg); box-shadow: var(--shadow-md); }

/* tabs */
.pi-tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--ivory); border: 1px solid var(--line); border-radius: 999px; padding: 5px; margin-bottom: 24px; }
.pi-tab {
  position: relative; z-index: 2; padding: 11px 14px; border-radius: 999px;
  font-weight: 600; font-size: 14.5px; color: var(--muted); text-align: center;
  transition: color .25s var(--ease);
}
.pi-tab.is-active { color: var(--ink); }
.pi-tab-ind {
  position: absolute; z-index: 1; top: 5px; bottom: 5px; left: 5px;
  width: calc(50% - 5px); border-radius: 999px; background: #fff;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  transition: transform .3s var(--ease);
}
.pi-tabs[data-active="signup"] .pi-tab-ind { transform: translateX(100%); }

/* forms */
.pi-form { display: flex; flex-direction: column; gap: 16px; }
.pi-form[hidden] { display: none; }
.pi-fineprint { font-size: 12.5px; color: var(--muted-2); text-align: center; line-height: 1.5; }
.pi-fineprint a { color: var(--gold-deep); text-decoration: underline; text-underline-offset: 2px; }

/* error message */
.pi-error {
  font-size: 13.5px; font-weight: 500; color: #9a3b2e;
  background: #fbeae6; border: 1px solid #f0cfc7; border-radius: var(--r-md);
  padding: 10px 13px; display: flex; gap: 8px; align-items: center; margin: -2px 0 0;
}
.pi-error[hidden] { display: none; }
.pi-error::before { content: "!"; flex: none; width: 18px; height: 18px; border-radius: 50%;
  background: #c2543f; color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; }

/* ================================================================= */
/*  DASHBOARD                                                         */
/* ================================================================= */
.pi-dash-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 18px; margin-bottom: 26px;
}
.pi-greeting { margin-top: 10px; line-height: 1.04; }
.pi-greeting #bizName { color: var(--gold-deep); }

/* head right-side cluster: stall button + plan chip */
.pi-dash-head-cta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Fair / Stall mode button */
.pi-stall-btn {
  display: inline-flex; align-items: center; gap: 9px; flex: none;
  padding: 11px 18px; border-radius: 999px;
  font-weight: 700; font-size: 14px; color: var(--ink);
  background: #fff; border: 1px solid var(--gold-light);
  box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease), background .2s var(--ease);
}
.pi-stall-btn:hover { border-color: var(--gold); background: var(--gold-wash); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.pi-stall-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.pi-stall-btn svg { width: 19px; height: 19px; color: var(--gold-deep); flex: none; }

/* plan status chip */
.pi-plan-chip {
  display: inline-flex; align-items: center; gap: 10px; flex: none;
  padding: 11px 18px; border-radius: 999px;
  background: linear-gradient(180deg, #FBF1D8, var(--gold-wash));
  border: 1px solid var(--gold-light);
  box-shadow: var(--shadow-sm);
}
.pi-plan-chip svg { width: 20px; height: 20px; color: var(--gold-deep); flex: none; }
.pi-plan-chip-text { font-size: 14px; font-weight: 700; letter-spacing: .01em; color: var(--ink); white-space: nowrap; }
/* unlimited → richer gold */
.pi-plan-chip.is-unlimited { background: linear-gradient(180deg, #F4DFA6, #EBCB7E); border-color: var(--gold); }
.pi-plan-chip.is-unlimited .pi-plan-chip-text { color: #4a3a12; }
/* trial → neutral, informative */
.pi-plan-chip.is-trial { background: #fff; border-color: var(--gold-soft); }
.pi-plan-chip.is-trial .pi-plan-chip-text { color: var(--gold-deep); }
/* zero remaining → muted/alert */
.pi-plan-chip.is-zero { background: #fbeae6; border-color: #f0cfc7; }
.pi-plan-chip.is-zero svg { color: #b5503c; }
.pi-plan-chip.is-zero .pi-plan-chip-text { color: #9a3b2e; }

/* trial watermark banner */
.pi-trial-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(180deg, #FFF7E6, #FBEFD2);
  border: 1px solid var(--gold-light); border-left: 4px solid var(--gold);
  border-radius: var(--r-md); padding: 15px 18px; margin-bottom: 22px;
}
.pi-trial-banner[hidden] { display: none; }
.pi-trial-banner > svg { width: 24px; height: 24px; color: var(--gold-deep); flex: none; }
.pi-trial-banner-body { flex: 1; min-width: 220px; }
.pi-trial-banner-title { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--ink); line-height: 1.15; }
.pi-trial-banner-text { font-size: 13.5px; color: #7a5e25; margin-top: 3px; line-height: 1.45; }
.pi-trial-banner-cta { flex: none; }

/* gentle out-of-quota notice */
.pi-notice {
  display: flex; align-items: center; gap: 11px;
  background: #fff6e3; border: 1px solid var(--gold-light); border-radius: var(--r-md);
  padding: 13px 16px; font-size: 14.5px; color: #7a5e25; margin-bottom: 24px;
}
.pi-notice[hidden] { display: none; }
.pi-notice svg { width: 20px; height: 20px; color: var(--gold-deep); flex: none; }

/* ---------------------------------------------------------------- stats bar
   A row of clean colored stat cards — the merchant's "command center" header. */
.pi-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px;
}
.pi-stat {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 16px 15px; border-radius: var(--r-md);
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
/* a soft accent rail per card */
.pi-stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--gold-soft);
}
.pi-stat-ic {
  position: absolute; top: 13px; right: 13px;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: var(--gold-wash); color: var(--gold-deep);
}
.pi-stat-ic svg { width: 19px; height: 19px; }
.pi-stat-val {
  font-family: var(--serif); font-weight: 600; font-size: clamp(26px, 3.2vw, 34px);
  line-height: 1.05; color: var(--ink); letter-spacing: -.01em;
  padding-right: 40px; word-break: break-word;
}
.pi-stat-lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }

/* per-card accent colors */
.pi-stat--month::before    { background: var(--gold); }
.pi-stat--remaining::before{ background: #6fa07a; }
.pi-stat--remaining .pi-stat-ic { background: #e9f1ea; color: #3f7a52; }
.pi-stat--total::before    { background: var(--gold-soft); }
.pi-stat--plan::before     { background: var(--ink); }
.pi-stat--plan .pi-stat-ic { background: #efe9dc; color: var(--ink); }
.pi-stat--plan .pi-stat-val { font-size: clamp(20px, 2.4vw, 26px); }

/* unlimited / zero emphasis */
.pi-stat-val.is-inf { color: #3f7a52; }
.pi-stat.is-zero::before { background: #c2543f; }
.pi-stat.is-zero .pi-stat-val { color: #9a3b2e; }
.pi-stat.is-zero .pi-stat-ic { background: #fbeae6; color: #b5503c; }

/* grid: generate + buy */
.pi-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 22px; align-items: start; }
.pi-card { padding: clamp(20px, 2.6vw, 30px); border-radius: var(--r-lg); }
.pi-card-head { margin-bottom: 18px; }
.pi-card-sub { font-size: 14px; color: var(--muted); margin-top: 6px; }

/* generate form */
.pi-gen-form { display: flex; flex-direction: column; gap: 17px; }
.pi-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* segmented control (cognome/nome) */
.pi-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; background: var(--ivory);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px; }
.pi-seg-opt { position: relative; }
.pi-seg-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pi-seg-opt span {
  display: block; text-align: center; padding: 10px 12px; border-radius: 999px;
  font-weight: 600; font-size: 14px; color: var(--muted); transition: .2s var(--ease);
}
.pi-seg-opt:hover span { color: var(--ink); }
.pi-seg-opt input:checked + span { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.pi-seg-opt input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

/* theme quick-pick chips */
.pi-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pi-chip {
  font-size: 12.5px; font-weight: 600; color: var(--gold-deep);
  background: var(--gold-wash); border: 1px solid var(--gold-light);
  border-radius: 999px; padding: 6px 13px;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.pi-chip:hover { background: #F2E4C2; border-color: var(--gold-soft); transform: translateY(-1px); }
.pi-chip:active { transform: translateY(0); }
.pi-chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.pi-gen-btn svg { width: 18px; height: 18px; }
.pi-gen-hint { font-size: 12.5px; color: var(--muted-2); text-align: center; line-height: 1.5; }

/* generating progress */
.pi-gen-progress {
  margin-top: 20px; padding: 30px 22px; border-radius: var(--r-lg);
  background:
    radial-gradient(100% 80% at 50% 0%, #FFF6E6 0%, #FBEFD7 100%);
  border: 1px solid var(--gold-light);
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
}
.pi-gen-progress[hidden] { display: none; }
.pi-progress-msg { font-family: var(--serif); font-size: 22px; color: var(--ink); min-height: 1.2em;
  animation: pi-fade .5s var(--ease); }
.pi-progress-note { font-size: 13px; color: var(--muted); max-width: 34ch; }
@keyframes pi-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* inline result */
.pi-result { margin-top: 22px; display: grid; grid-template-columns: minmax(0,1fr) 240px; gap: 22px;
  align-items: start; animation: pi-fade .5s var(--ease); }
.pi-result[hidden] { display: none; }
.pi-result-img {
  background: var(--parchment); border-radius: 4px; overflow: hidden;
  box-shadow: var(--shadow-cert); line-height: 0;
}
.pi-result-img img { width: 100%; height: auto; display: block; }
.pi-result-side { display: flex; flex-direction: column; gap: 12px; }
.pi-result-name { font-family: var(--serif); font-size: 26px; color: var(--ink); line-height: 1.1; margin-top: 2px; }
.pi-result-credit { font-size: 13.5px; color: var(--muted); }
.pi-result-credit strong { color: var(--gold-deep); font-weight: 700; }

/* trial watermark note under a result */
.pi-watermark-note {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; line-height: 1.45; font-weight: 600; color: #8a5a12;
  background: #fff6e3; border: 1px solid var(--gold-light); border-radius: var(--r-md);
  padding: 9px 11px;
}
.pi-watermark-note[hidden] { display: none; }
.pi-watermark-note svg { width: 16px; height: 16px; color: var(--gold-deep); flex: none; margin-top: 1px; }

/* show-on-screen / print buttons in the result + modal */
.pi-show-btn, .pi-print-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.pi-show-btn svg, .pi-print-btn svg { width: 17px; height: 17px; flex: none; }
.pi-show-btn.is-busy { pointer-events: none; opacity: .65; }

/* free redo button + hint */
.pi-redo-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.pi-redo-btn svg { width: 17px; height: 17px; transition: transform .5s var(--ease); }
.pi-redo-btn:hover:not(:disabled) svg { transform: rotate(-180deg); }
.pi-redo-btn.is-busy { pointer-events: none; opacity: .65; }
.pi-redo-btn.is-busy svg { animation: pi-spin .8s linear infinite; transform-origin: center; }
.pi-redo-btn:disabled { opacity: .5; cursor: not-allowed; }
.pi-redo-hint { font-size: 12px; color: var(--muted-2); text-align: center; line-height: 1.45; margin-top: -2px; }
.pi-redo-hint.is-done { color: var(--gold-deep); font-weight: 600; }

/* ---------------------------------------------------------------- plans */
.pi-plans { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.pi-plans-loading { font-size: 14px; color: var(--muted-2); padding: 8px 0; }

.pi-plan {
  position: relative; display: flex; flex-direction: column;
  padding: 20px 18px 18px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: #fff; transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.pi-plan:hover { border-color: var(--gold-soft); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.pi-plan.is-best {
  border-color: var(--gold); background: linear-gradient(180deg, #FFFDF7, var(--gold-wash));
  box-shadow: 0 0 0 1px var(--gold) inset, var(--shadow-sm);
}
.pi-plan.is-current { border-color: var(--gold-soft); }

.pi-plan-badge {
  position: absolute; top: -10px; right: 16px;
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  background: linear-gradient(180deg, #C19A53, var(--gold)); color: #2a2110;
  padding: 3px 10px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.pi-plan-badge--current { left: 16px; right: auto; background: var(--ink); color: #F6EFE0; }

.pi-plan-name { font-family: var(--serif); font-size: 21px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.pi-plan-price { font-family: var(--serif); font-size: 34px; font-weight: 600; color: var(--gold-deep); line-height: 1; margin: 6px 0 14px; }
.pi-plan-permo { font-family: var(--sans, inherit); font-size: 14px; font-weight: 600; color: var(--muted-2); margin-left: 2px; }

.pi-plan-features { list-style: none; margin: 0 0 16px; display: flex; flex-direction: column; gap: 9px; }
.pi-plan-features li { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--ink); line-height: 1.4; }
.pi-plan-features svg { width: 16px; height: 16px; color: var(--gold-deep); flex: none; margin-top: 2px; }

.pi-plan-cta { margin-top: auto; }
.pi-plan-cta:disabled { opacity: .55; cursor: default; }

.pi-plans-note { font-size: 12.5px; color: var(--muted-2); text-align: center; margin-top: 4px; line-height: 1.5; }

/* ---------------------------------------------------------------- certificates panel / history */
.pi-recent { margin-top: 30px; }
.pi-recent-head { margin-bottom: 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pi-recent-count {
  flex: none; font-size: 12.5px; font-weight: 700; color: var(--gold-deep);
  background: var(--gold-wash); border: 1px solid var(--gold-light);
  border-radius: 999px; padding: 5px 13px; white-space: nowrap;
}
.pi-recent-count[hidden] { display: none; }
.pi-history { display: grid; grid-template-columns: repeat(auto-fill, minmax(186px, 1fr)); gap: 18px; }
.pi-history-empty {
  font-size: 14px; color: var(--muted); background: #fff; border: 1px dashed var(--line);
  border-radius: var(--r-md); padding: 22px; text-align: center;
}
.pi-history-empty[hidden] { display: none; }

.pi-hist-card {
  position: relative;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
  display: flex; flex-direction: column;
}
.pi-hist-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--gold-soft); }

/* clickable thumbnail (button) → opens preview */
.pi-hist-thumb {
  position: relative; display: block; width: 100%;
  aspect-ratio: 1 / 1.414; background: var(--parchment); line-height: 0; overflow: hidden;
  border: 0; padding: 0; cursor: zoom-in;
}
.pi-hist-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; transition: transform .35s var(--ease); }
.pi-hist-thumb:hover img { transform: scale(1.03); }
.pi-hist-thumb:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

/* per-row busy overlay (during redo) */
.pi-hist-busy {
  position: absolute; inset: 0; display: none; place-items: center;
  background: rgba(246,238,221,.72); backdrop-filter: blur(1px);
}
.pi-hist-card.is-redoing .pi-hist-busy { display: grid; }
.pi-hist-card.is-redoing .pi-hist-thumb { cursor: progress; }

.pi-hist-body { padding: 12px 13px 13px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.pi-hist-name { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.05; color: var(--ink); }
.pi-hist-meta { font-size: 11.5px; color: var(--muted-2); display: flex; flex-wrap: wrap; gap: 4px 8px; }
.pi-hist-meta .pi-dot { color: var(--gold-soft); }

/* actions group: Download · Print · Show · Redo */
.pi-hist-actions { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding-top: 4px; }
.pi-hist-act {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 8px;
  background: #fff; cursor: pointer; min-width: 0;
  transition: border-color .2s var(--ease), background .2s var(--ease), color .2s var(--ease);
}
.pi-hist-act:hover { border-color: var(--gold-soft); background: var(--ivory); }
.pi-hist-act:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.pi-hist-act svg { width: 14px; height: 14px; flex: none; }
.pi-hist-act span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-hist-act.is-busy { pointer-events: none; opacity: .6; }
.pi-hist-act--redo { color: var(--gold-deep); }
.pi-hist-act--redo:hover { background: var(--gold-wash); border-color: var(--gold-soft); }
.pi-hist-act--redo svg { transition: transform .5s var(--ease); }
.pi-hist-act--redo:hover:not(:disabled) svg { transform: rotate(-180deg); }
.pi-hist-act--redo:disabled { opacity: .5; cursor: not-allowed; }
.pi-hist-card.is-redoing .pi-hist-act--redo svg { animation: pi-spin .8s linear infinite; transform-origin: center; }

/* ---------------------------------------------------------------- preview modal */
.pi-modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 22px; }
.pi-modal[hidden] { display: none; }
.pi-modal-backdrop { position: absolute; inset: 0; background: rgba(27,24,19,.62); backdrop-filter: blur(2px); animation: pi-fade .25s var(--ease); }
.pi-modal-card {
  position: relative; z-index: 1; width: min(560px, 100%); max-height: calc(100vh - 44px);
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pi-pop .28s var(--ease);
}
@keyframes pi-pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.pi-modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.9); border: 1px solid var(--line); color: var(--ink);
  box-shadow: var(--shadow-sm); cursor: pointer; transition: background .2s var(--ease), transform .2s var(--ease);
}
.pi-modal-close:hover { background: #fff; transform: rotate(90deg); }
.pi-modal-close:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.pi-modal-close svg { width: 18px; height: 18px; }
.pi-modal-img { background: var(--parchment); line-height: 0; overflow: auto; display: grid; place-items: center; flex: 1; min-height: 0; }
.pi-modal-img img { max-width: 100%; max-height: 64vh; height: auto; display: block; }
.pi-modal-foot { padding: 16px 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; flex: none; }
.pi-modal-name { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.pi-modal-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.pi-modal-actions .btn { flex: 1 1 140px; }
body.pi-modal-open { overflow: hidden; }

/* ---------------------------------------------------------------- print surface
   Hidden on screen; on print we hide the whole app and show only this image
   filling an A4 page so a single certificate prints clean. */
.pi-print-area { display: none; }
@media print {
  body.partner-body > *:not(#partnerApp) { display: none !important; }
  #partnerApp > *:not(.pi-print-area) { display: none !important; }
  .pi-print-area {
    display: block !important; position: static;
    width: 100%; margin: 0; padding: 0; background: #fff;
  }
  .pi-print-area img { display: block; width: 100%; height: auto; max-height: 100vh; object-fit: contain; }
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #fff !important; }
}

/* ---------------------------------------------------------------- toast */
.pi-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  background: var(--ink); color: #F6EFE0; font-size: 14px; font-weight: 500;
  padding: 13px 20px; border-radius: 999px; box-shadow: var(--shadow-lg);
  z-index: 200; opacity: 0; transition: opacity .3s var(--ease), transform .3s var(--ease);
  max-width: calc(100vw - 32px); text-align: center;
}
.pi-toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.pi-toast[hidden] { display: none; }
.pi-toast.is-err { background: #8a2f23; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 960px) {
  .pi-grid { grid-template-columns: 1fr; }
  .pi-auth-wrap { grid-template-columns: 1fr; gap: 36px; }
  .pi-auth-intro { text-align: left; }
  /* plans card now spans full width → lay cards out side by side */
  .pi-plans { flex-direction: row; flex-wrap: wrap; }
  .pi-plan { flex: 1 1 220px; }
  /* stat cards wrap to two-up */
  .pi-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .pi-result { grid-template-columns: 1fr; }
  .pi-result-side { flex-direction: column; }
  .pi-two { grid-template-columns: 1fr; }
  .pi-dash-head { align-items: flex-start; }
  .pi-dash-head-cta { width: 100%; }
  .pi-stall-btn { flex: 1 1 auto; justify-content: center; }
  .pi-plan-chip { padding: 10px 15px; }
  .pi-plan-chip-text { font-size: 13px; }
  .pi-trial-banner { flex-direction: column; align-items: flex-start; }
  .pi-trial-banner-cta { width: 100%; text-align: center; }
  .pi-plans { flex-direction: column; }
  .pi-stat { padding: 14px 14px 13px; }
  .pi-stat-ic { width: 30px; height: 30px; top: 12px; right: 12px; }
  .pi-stat-ic svg { width: 16px; height: 16px; }
  .pi-history { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 13px; }
  .pi-modal { padding: 12px; }
  .pi-modal-actions .btn { flex: 1 1 100%; }
}
@media (max-width: 460px) {
  .pi-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pi-history { grid-template-columns: 1fr; }
  .pi-hist-actions { grid-template-columns: 1fr 1fr; }
}

/* respect reduced motion (styles.css already nukes transitions globally) */
@media (prefers-reduced-motion: reduce) {
  .pi-spinner { animation: pi-spin 1.4s linear infinite; }
}

/* ===================== FAIR CONSOLE (live stall board) ===================== */
.pi-console-head { align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.pi-console-head-side { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.pi-today-pill { font-size: 13px; font-weight: 700; color: var(--gold-deep);
  background: var(--gold-wash); border: 1px solid var(--gold-light);
  border-radius: 999px; padding: 6px 13px; white-space: nowrap; }
.pi-today-pill:empty { display: none; }
.pi-touch-toggle { display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--muted); background: #fff;
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px;
  transition: border-color .2s var(--ease), color .2s var(--ease), background .2s var(--ease); }
.pi-touch-toggle svg { width: 16px; height: 16px; }
.pi-touch-toggle[aria-pressed="true"] { color: var(--gold-deep); border-color: var(--gold); background: var(--gold-wash); }

.pi-console-running { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.pi-crun { display: inline-flex; align-items: center; gap: 16px; background: #fff;
  border: 2px solid var(--gold-light); border-radius: 16px; padding: 16px 26px 16px 20px;
  box-shadow: var(--shadow-md); }
.pi-crun .pi-spinner { width: 34px; height: 34px; border-width: 4px; }
.pi-crun-name { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600;
  color: var(--ink); font-size: clamp(30px, 5vw, 46px); line-height: 1.05; letter-spacing: .01em; }
.pi-crun-timer { font-variant-numeric: tabular-nums; font-size: 22px; color: var(--gold-deep); font-weight: 700; }
.pi-crun--pending .pi-crun-timer { color: var(--muted); }
body.console-touch .pi-crun-name { font-size: clamp(38px, 7vw, 58px); }
body.console-touch .pi-crun .pi-spinner { width: 42px; height: 42px; }

.pi-console-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 15px; }
.pi-console-empty { color: var(--muted); font-size: 14.5px; text-align: center; padding: 26px 10px; }

.pi-cjob { display: flex; flex-direction: column; border: 1px solid var(--line);
  border-radius: var(--r-md); overflow: hidden; background: #fff; box-shadow: var(--shadow-sm); }
.pi-cjob.is-error { border-color: #f0cfc7; background: #fdf5f3; }
.pi-cjob.is-showcase { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-wash); }
.pi-cjob-thumb { position: relative; border: 0; padding: 0; cursor: pointer; background: var(--ivory);
  aspect-ratio: 3 / 4; width: 100%; overflow: hidden; }
.pi-cjob-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pi-cjob-badges { position: absolute; top: 7px; left: 7px; right: 7px; display: flex; flex-wrap: wrap; gap: 5px; }
.pi-cbadge { font-size: 11px; font-weight: 800; letter-spacing: .3px; border-radius: 999px;
  padding: 2px 8px; line-height: 1.5; backdrop-filter: blur(2px); }
.pi-cbadge--screen { background: rgba(201,162,39,.92); color: #1a1408; }
.pi-cbadge--sold { background: rgba(33,120,60,.92); color: #fff; }
.pi-cbadge--sent { background: rgba(40,70,120,.9); color: #fff; }
.pi-cjob-body { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.pi-cjob-name { font-weight: 800; color: var(--ink); font-size: 15px; line-height: 1.2; }
.pi-cjob-meta { font-size: 12px; color: var(--muted-2); }
.pi-cjob-err { font-size: 12.5px; color: #c42424; font-weight: 600; }
.pi-cjob-acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: auto; }
.pi-cact { display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer;
  padding: 8px 4px; color: var(--ink); font-size: 11.5px; font-weight: 700;
  transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease); }
.pi-cact svg { width: 17px; height: 17px; }
.pi-cact span { display: none; }
.pi-cact:hover { border-color: var(--gold); background: var(--gold-wash); color: var(--gold-deep); }
.pi-cact--sold.is-on { border-color: #2a8b46; background: #e9f7ee; color: #1f7a3a; }
.pi-cact--wide { grid-column: 1 / -1; padding: 10px; }
.pi-cact--wide span { display: inline; }
.pi-cact--retry { grid-column: 1 / -1; border-color: #e7b7ab; color: #c42424; }
.pi-cact--retry span { display: inline; }
.pi-cact--retry:hover { background: #fdeee9; border-color: #c42424; color: #c42424; }

/* Big-buttons / touch mode for behind-the-counter tablets */
body.console-touch .pi-console-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
body.console-touch .pi-cact { padding: 13px 4px; font-size: 13px; }
body.console-touch .pi-cact svg { width: 21px; height: 21px; }
body.console-touch .pi-cjob-acts { grid-template-columns: repeat(3, 1fr); gap: 8px; }
body.console-touch .pi-cact span { display: inline; }

/* modal: badges, sold, deliver block */
.pi-modal-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.pi-modal-badges:empty { display: none; }
.pi-sold-btn.is-sold { border-color: #2a8b46; color: #1f7a3a; background: #e9f7ee; }
.pi-modal-deliver { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.pi-deliver-title { font-size: 13px; font-weight: 700; color: var(--gold-deep); margin: 0 0 8px; }
.pi-deliver-qr { text-align: center; margin-bottom: 10px; }
.pi-deliver-qr img { background: #fff; border-radius: 8px; padding: 6px; }
.pi-deliver-row { display: flex; gap: 8px; margin-top: 8px; }
.pi-deliver-row .input { flex: 1; min-width: 0; }
.pi-deliver-upsell { margin-top: 8px; }

/* history search tools */
.pi-recent-tools { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.pi-recent-search { max-width: 220px; padding: 9px 13px; font-size: 14px; }
@media (max-width: 560px) { .pi-recent-search { max-width: 150px; } }

/* left column holds Generate + the live board stacked; Plans sits tall on the right */
.pi-col-main { display: flex; flex-direction: column; min-width: 0; }
.pi-col-main .pi-card { margin-top: 0; }
.pi-col-main #consoleCard { margin-top: 22px; }
/* paid partners: plans card hidden → the main column spans the full width */
.pi-grid.is-solo { grid-template-columns: 1fr; }

/* discreet "change plan" button (shown only to paid partners, reveals the plans) */
.pi-manage-plan { font-size: 13px; font-weight: 700; color: var(--muted);
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 15px; cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease), background .2s var(--ease); }
.pi-manage-plan:hover { border-color: var(--gold); color: var(--gold-deep); background: var(--gold-wash); }
