/* =============================================================================
   The client portal (portal.html, portal.js) in residential's portal layout (vmv-operations portal.html): a sign-in card
   centred on a soft page with the code boxes; then a top bar with the business and "Hi, <name>", the account bar, tabs
   (a bar at the bottom on phones, a row under the header from 760px), cards at 20px with one shadow, the next visit as
   one blue card. Kit tokens only (docs/design/DESIGN.md): words in Geist, numbers in Geist Mono, one blue, red only with a
   word. Client portal only (body[data-app="portal"]).
   ============================================================================= */
body[data-app="portal"] { margin: 0; min-height: 100vh; background: color-mix(in srgb, var(--t-blue) 5%, var(--canvas)); color: var(--ink);
  font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
:where(body[data-app="portal"] a) { color: var(--accent); }
body[data-app="portal"] button, body[data-app="portal"] a { touch-action: manipulation; }
body[data-app="portal"] [hidden] { display: none !important; }
body[data-app="portal"] :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pt-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.pt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pt-skip { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: var(--radius-md); background: var(--primary); color: var(--on-primary) !important; font-weight: 600; text-decoration: none; }
.pt-skip:focus { top: 8px; }

/* Light / Dark / Auto and the account bar: one segmented control. */
.pt-seg { display: inline-flex; gap: 4px; padding: 3px; border-radius: var(--radius-pill); background: var(--surface-2); max-width: 100%; }
.pt-seg button { min-height: 40px; padding: 0 14px; border: 0; border-radius: var(--radius-pill); background: none; color: var(--ink-muted);
  font: 600 14px/1 var(--font-sans); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(10, 10, 10, .1); }

.pt-msg { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 11px 13px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  font: 500 15px/1.45 var(--font-sans); }
.pt-msg svg { flex: none; margin-top: 2px; }
.pt-msg--bad { background: var(--danger-soft); color: var(--danger); }

/* ---------- Sign in ---------- */
.pl { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.pl-top { display: flex; justify-content: flex-end; padding: calc(env(safe-area-inset-top) + 12px) 16px 0; }
.pl-center { display: grid; align-content: center; justify-items: center; gap: 14px; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
.pl-card { width: 100%; max-width: 420px; display: grid; gap: 14px; padding: 28px 24px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-card);
  animation: pt-rise .5s var(--spring) both; }
.pl-head { display: grid; justify-items: center; gap: 6px; text-align: center; }
.pl-tile { width: 56px; height: 56px; border-radius: 16px; box-shadow: var(--shadow-card); margin-bottom: 6px; }
.pl-head .ui-caption { margin: 0; color: var(--accent); }
.pl-title { margin: 0; font: 600 28px/1.15 var(--font-sans); letter-spacing: -.03em; }
.pl-lead { margin: 0; color: var(--ink-muted); font: 400 15px/1.5 var(--font-sans); text-align: center; }
.pl-lead b { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.pl-form { display: grid; gap: 12px; }
.pl-idf { position: relative; }
.pl-idf .ui-input { width: 100%; min-height: 50px; padding-left: 44px; font-size: 17px; box-sizing: border-box; }
.pl-ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--accent); display: grid; pointer-events: none; }
.pl-go { width: 100%; min-height: 50px; }
.pl-help, .pl-foot { margin: 0; text-align: center; color: var(--ink-muted); font: 400 14px/1.45 var(--font-sans); }
.pl-otp { margin: 4px 0; }
.pl-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; }
.pl-link { min-height: 44px; padding: 0; border: 0; background: none; color: var(--accent); font: 600 15px/1 var(--font-sans); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.pl-link:disabled { color: var(--ink-faint); text-decoration: none; cursor: default; }

/* ---------- Signed in: top bar, account bar, tabs ---------- */
.pt-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1080px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; }
.pt-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pt-brand img { flex: none; border-radius: 9px; }
.pt-brand > span { display: grid; min-width: 0; }
.pt-brand b { font: 600 17px/1.2 var(--font-sans); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-brand small { font: 400 12px/1.3 var(--font-sans); color: var(--ink-muted); }
.pt-hi { flex: none; font: 500 15px/1 var(--font-sans); color: var(--ink-muted); }
.pt-acct { max-width: 1080px; margin: 0 auto 8px; padding: 0 16px; }
.pt-acct .pt-seg { display: flex; } .pt-acct .pt-seg button { flex: 1 1 0; min-width: 0; }

.pt-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
  padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  background: var(--material); -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6); border-top: 1px solid var(--hairline); }
.pt-tabbar a { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 52px; padding: 4px; border-radius: 14px; color: var(--ink-muted);
  font: 600 12px/1 var(--font-sans); text-decoration: none; transition: background-color .15s, color .15s; }
.pt-tabbar a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
body.pt-tabs-on { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) {
  .pt-tabbar { position: static; display: flex; gap: 6px; max-width: 1080px; margin: 0 auto 8px; padding: 0 16px; background: none; border: 0;
    -webkit-backdrop-filter: none; backdrop-filter: none; }
  .pt-tabbar a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--radius-pill); font-size: 15px; }
  .pt-tabbar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
  .pt-acct .pt-seg { display: inline-flex; } .pt-acct .pt-seg button { flex: none; padding: 0 18px; }
  body.pt-tabs-on { padding-bottom: 0; }
}
@media (hover: hover) { .pt-tabbar a:not([aria-current="page"]):hover { color: var(--ink); } }

.pt-main { max-width: 1080px; margin: 0 auto; padding: 4px 16px 24px; display: grid; gap: 14px; }
.pt-main:focus { outline: none; }
.pt-main--one { max-width: 720px; }
.pt-col { display: grid; gap: 14px; align-content: start; min-width: 0; }
.pt-col > * { animation: pt-rise .45s var(--spring) both; }
.pt-col > *:nth-child(2) { animation-delay: 50ms; } .pt-col > *:nth-child(3) { animation-delay: 100ms; } .pt-col > *:nth-child(n+4) { animation-delay: 150ms; }
@media (min-width: 960px) { .pt-main:not(.pt-main--one) { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; } }
.pt-foot { padding: 8px 16px calc(28px + env(safe-area-inset-bottom)); text-align: center; color: var(--ink-muted); font: 400 13px/1.6 var(--font-sans); }
.pt-foot a { color: inherit; }

/* ---------- Cards and rows ---------- */
.pt-card { display: grid; gap: 10px; padding: 18px 20px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-card); min-width: 0; }
.pt-card--soft { background: var(--surface); box-shadow: none; padding: 14px 18px; }
.pt-h { display: flex; align-items: center; gap: 10px; margin: 0; font: 600 19px/24px var(--font-sans); letter-spacing: -.01em; }
.pt-h::before { content: ""; flex: none; width: 4px; height: 1.05em; border-radius: 2px; background: var(--t-blue); }
.pt-h3 { margin: 0; font: 600 17px/22px var(--font-sans); }
.pt-sub { color: var(--ink-muted); font: 400 14px/1.4 var(--font-sans); }
.pt-body { margin: 0; font: 400 15px/1.55 var(--font-sans); color: var(--ink-muted); }
.pt-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--ink-muted); font: 400 14px/1.5 var(--font-sans); }
.pt-note svg { flex: none; margin-top: 2px; color: var(--accent); }
.pt-empty { margin: 0; color: var(--ink-muted); font: 400 15px/1.5 var(--font-sans); }
.pt-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.pt-actions .ui-btn { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.pt-list { list-style: none; margin: 0; padding: 0; }
.pt-list > li { border-top: 1px solid var(--hairline); } .pt-list > li:first-child { border-top: 0; }

.pt-visit { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 12px 0; }
.pt-visit--quiet .pt-visit__t b { color: var(--ink-muted); }
.pt-d { width: 48px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; align-content: center; line-height: 1; }
.pt-d b { font: 500 20px/1 var(--font-mono); } .pt-d span { margin-top: 3px; font: 600 11px/1 var(--font-sans); text-transform: uppercase; letter-spacing: .06em; }
.pt-visit--quiet .pt-d { background: var(--surface-2); color: var(--ink-muted); }
.pt-visit__t { display: grid; gap: 2px; min-width: 0; } .pt-visit__t b { font: 600 16px/1.3 var(--font-sans); }
.pt-visit .ui-status { font-family: var(--font-sans); white-space: nowrap; }
@media (max-width: 420px) { .pt-visit { grid-template-columns: auto minmax(0, 1fr); } .pt-visit .ui-status { grid-column: 2; justify-self: start; } }

.pt-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; padding: 12px 0; }
.pt-row__t { display: grid; gap: 2px; min-width: 0; flex: 1 1 180px; } .pt-row__t b { font: 600 16px/1.3 var(--font-sans); overflow-wrap: anywhere; }
.pt-row__a { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pt-row__a .ui-pill { min-height: 40px; text-decoration: none; font-family: var(--font-sans); }
.pt-amt { font-size: 15px; }
.pt-price { text-align: right; } .pt-price b { display: block; font-size: 17px; } .pt-price small { color: var(--ink-muted); font: 400 12px/1.2 var(--font-sans); }

.pt-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-pill); font: 600 13px/18px var(--font-sans); white-space: nowrap;
  background: var(--surface-2); color: var(--ink-muted); }
.pt-chip[data-kind="ok"] { background: var(--accent-soft); color: var(--accent); }
.pt-chip[data-kind="due"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.pt-chip[data-kind="bad"] { background: var(--danger-soft); color: var(--danger); }

/* The next visit: one blue card (the kit's branded call to action colour), white text. */
.pt-next { position: relative; display: grid; gap: 4px; padding: 22px; border-radius: 24px; background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-card); overflow: hidden; }
.pt-next__eye { margin: 0; font: 500 14px/1.2 var(--font-sans); opacity: .85; }
.pt-next__cd { position: absolute; right: 18px; top: 18px; padding: 5px 11px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--on-accent) 18%, transparent); font: 600 13px/1 var(--font-sans); }
.pt-next__big { margin: 8px 0 2px; font: 600 clamp(24px, 6vw, 30px)/1.15 var(--font-sans); letter-spacing: -.03em; }
.pt-next__line { margin: 0; font: 400 16px/1.45 var(--font-sans); opacity: .95; }
.pt-next__soft { opacity: .8; }
.pt-next__row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pt-next .ui-btn { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.pt-on { background: var(--on-accent); color: var(--accent); } .pt-on:active { background: var(--on-accent); }
.pt-ghost { background: color-mix(in srgb, var(--on-accent) 16%, transparent); color: var(--on-accent); }
.pt-faces { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0 2px; }
.pt-face { display: inline-flex; align-items: center; gap: 8px; font: 600 15px/1 var(--font-sans); }
.pt-face i { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font: 600 15px/1 var(--font-sans); font-style: normal;
  background: color-mix(in srgb, var(--on-accent) 22%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--on-accent) 70%, transparent); }

/* Card on file: a plain card shape (no number, only the brand and last 4). */
.pt-cc { display: grid; grid-template-columns: 1fr auto; gap: 18px 8px; max-width: 340px; aspect-ratio: 1.62; padding: 18px 20px; border-radius: 16px; box-sizing: border-box;
  background: var(--primary); color: var(--on-primary); align-content: space-between; }
.pt-cc__brand { font: 600 17px/1 var(--font-sans); } .pt-cc__num { grid-column: 1 / -1; font-size: 20px; letter-spacing: .12em; }
.pt-cc__exp { grid-column: 1 / -1; font: 400 13px/1 var(--font-sans); opacity: .8; }
.pt-nocard { display: grid; place-items: center; max-width: 340px; aspect-ratio: 2.4; padding: 12px; border: 1.5px dashed var(--hairline-strong); border-radius: 16px;
  color: var(--ink-muted); font: 500 15px/1.4 var(--font-sans); text-align: center; box-sizing: border-box; }

/* Help */
.pt-faq { border-top: 1px solid var(--hairline); } .pt-faq:first-of-type { border-top: 0; }
.pt-faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 0; font: 600 16px/1.35 var(--font-sans); cursor: pointer; list-style: none; }
.pt-faq summary::-webkit-details-marker { display: none; }
.pt-faq summary::after { content: ""; flex: none; width: 9px; height: 9px; border-right: 2px solid var(--ink-muted); border-bottom: 2px solid var(--ink-muted);
  transform: rotate(45deg) translateY(-3px); transition: transform .2s var(--spring); }
.pt-faq[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.pt-faq p { margin: 0 0 14px; color: var(--ink-muted); font: 400 15px/1.55 var(--font-sans); }

/* A quote: a sheet on phones, a dialog on computers. */
dialog.pt-sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 600px; max-height: 92dvh; border-radius: 24px 24px 0 0; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sheet); overflow: hidden; }
dialog.pt-sheet[open] { display: flex; flex-direction: column; animation: pt-up .4s var(--spring) both; }
dialog.pt-sheet::backdrop { background: rgba(10, 10, 10, .4); }
@media (min-width: 700px) { dialog.pt-sheet { margin: auto; border-radius: 24px; } }
.pt-sheet__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 18px 18px 6px; }
.pt-sheet__head .pt-sub { margin: 4px 0 0 14px; }
.pt-x { flex: none; width: 44px; height: 44px; }
.pt-sheet__body { display: grid; gap: 14px; padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); overflow: auto; overscroll-behavior: contain; }
.pt-quote { margin: 0; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; font: 400 14px/1.6 var(--font-mono); }
.pt-acc { display: grid; gap: 12px; }
.pt-acc .ui-input { min-height: 48px; box-sizing: border-box; width: 100%; }
.pt-agree { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; font: 500 15px/1.45 var(--font-sans); cursor: pointer; }
.pt-agree input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }
.pt-done { display: grid; justify-items: center; gap: 10px; padding: 16px 0 6px; text-align: center; }
.pt-done__ok { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: var(--on-accent); animation: pt-pop .5s var(--spring-bounce) both; }

.pt-toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; max-width: 90%; padding: 11px 18px;
  border-radius: var(--radius-pill); background: var(--primary); color: var(--on-primary); font: 600 15px/1.3 var(--font-sans); }
body.pt-tabs-on .pt-toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
.pt-toast--bad { background: var(--danger); color: #fff; }
@media (min-width: 760px) { body.pt-tabs-on .pt-toast { bottom: calc(18px + env(safe-area-inset-bottom)); } }

@keyframes pt-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pt-up { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes pt-pop { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pl-card, .pt-col > *, dialog.pt-sheet[open], .pt-done__ok { animation: none; } }
@media (prefers-reduced-transparency: reduce) { .pt-tabbar { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } }
