/*
  Portland Fir — Components
  BEM-ish: block pf-block, element pf-block__el, modifier pf-block--mod.
  Each component below is documented with the markup contract it expects.
  Reuse these before adding new classes (see web/static/README.md).
*/

/* =========================================================
   App bar
   Markup: <header class="pf-app-bar">
             <a class="pf-icon-btn pf-app-bar__back" href="..." aria-label="Back">‹</a>  (sub-screens only)
             <a class="pf-app-bar__brand" href="/quotes"><img class="pf-app-bar__mark"></a>
             <h1 class="pf-app-bar__title">Fairview Garden Centre</h1>
             <span class="pf-app-bar__badge">Harrogate 2027</span>
             <nav class="pf-nav">…pf-nav__link (+ pf-nav__count)…</nav>
             <button class="pf-app-bar__rep" data-menu-toggle>
               <span class="pf-app-bar__avatar">AC</span></button>
           </header>
   The rep button opens the account menu (.pf-menu, below).
   ========================================================= */

.pf-app-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-app-bar);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 64px;
  padding: var(--space-2) var(--space-5);
  padding-top: calc(var(--space-2) + var(--safe-top));
  padding-left: calc(var(--space-5) + var(--safe-left));
  padding-right: calc(var(--space-5) + var(--safe-right));
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  flex: none;
}

.pf-app-bar__back {
  margin-inline-start: calc(-1 * var(--space-3));
  margin-inline-end: calc(-1 * var(--space-2));
  color: var(--color-primary);
  text-decoration: none;
}

.pf-app-bar__brand {
  display: flex;
  align-items: center;
  flex: none;
  border-radius: var(--radius-sm);
}

.pf-app-bar__mark {
  width: 32px;
  height: 32px;
  flex: none;
}

.pf-app-bar__title {
  flex: 0 1 auto;
  min-width: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-app-bar__badge {
  margin-inline-start: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-accent-tint);
  color: var(--color-gold-text);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pf-app-bar__rep {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  margin-inline-end: calc(-1 * var(--space-1));
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  flex: none;
}
.pf-app-bar__rep:hover .pf-app-bar__avatar,
.pf-app-bar__rep[aria-expanded="true"] .pf-app-bar__avatar {
  box-shadow: 0 0 0 3px var(--color-accent-tint), 0 0 0 4px var(--color-accent);
}

.pf-app-bar__avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-tint);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  transition: box-shadow var(--duration-fast) var(--easing-standard);
}

.pf-app-bar__avatar--lg {
  width: 48px;
  height: 48px;
  font-size: var(--font-size-md);
  flex: none;
}

.pf-app-bar__rep-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .pf-app-bar__rep-name { display: none; }
}

/* Primary nav: New quote / My quotes (+ today's count) */
.pf-nav {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: none;
}

.pf-nav__link {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  color: var(--color-ink-muted);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--duration-fast) var(--easing-standard), color var(--duration-fast) var(--easing-standard);
}
.pf-nav__link:hover { background: var(--color-surface-2); color: var(--color-ink); }
.pf-nav__link.is-active { background: var(--color-primary-tint); color: var(--color-primary); }

.pf-nav__count {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: var(--color-ink-on-primary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: var(--font-variant-numeric);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Narrow (iPad portrait 768): the show badge moves into the account
   menu and nav labels stay, icons carry less weight. */
@media (max-width: 820px) {
  .pf-app-bar { gap: var(--space-3); padding-inline: var(--space-4); }
  .pf-app-bar__badge { display: none; }
  .pf-nav__link { padding: 0 var(--space-3); }
}

/* Tablets in portrait and phones: the nav shows icons (and the count badges);
   the words stay for screen readers. The whole bar must fit the screen. */
@media (max-width: 900px) {
  .pf-app-bar { gap: var(--space-2); }
  .pf-nav { gap: 0; }
  .pf-nav__link { min-width: var(--tap-min); justify-content: center; padding: 0 var(--space-2); position: relative; }
  .pf-nav__link > span:not(.pf-nav__count) {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .pf-nav__count { min-width: 20px; height: 20px; padding: 0 5px; }
}
@media (max-width: 640px) {
  .pf-app-bar { padding-inline: var(--space-3); }
  .pf-app-bar__brand { display: none; }
}

/* =========================================================
   Bottom action bar (sticky footer of the app shell)
   Markup: <div class="pf-action-bar"><button class="pf-btn pf-btn--ghost">...
   ========================================================= */

.pf-action-bar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-action-bar);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  padding-bottom: calc(var(--space-4) + var(--safe-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
}

.pf-action-bar__spacer { flex: 1 1 auto; }

/* =========================================================
   Buttons
   Markup: <button class="pf-btn pf-btn--primary pf-btn--lg">Label</button>
   Variants: pf-btn--primary | --secondary | --ghost | --danger
   Sizes: default 48px, pf-btn--lg 56px (primary actions)
   Loading: add .pf-btn--loading (keeps width, shows spinner, disables clicks)
   Disabled: native [disabled]
   ========================================================= */

.pf-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  text-decoration: none; /* .pf-btn is also applied to <a> (e.g. nav CTAs) */
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--easing-standard),
    border-color var(--duration-fast) var(--easing-standard),
    color var(--duration-fast) var(--easing-standard),
    transform var(--duration-fast) var(--easing-standard);
  user-select: none;
  white-space: nowrap;
}

.pf-btn:active { transform: translateY(1px); }

.pf-btn--lg {
  min-height: var(--tap-primary);
  padding: 0 var(--space-6);
  font-size: var(--font-size-lg);
}

.pf-btn--full { width: 100%; }

/* Compact button for dense rows (table actions, card links): tighter
   padding and type, same 48px hit target. */
.pf-btn--sm {
  min-height: var(--tap-min);
  padding: 0 var(--space-4);
  font-size: var(--font-size-sm);
}

.pf-btn--primary {
  background: var(--color-primary);
  color: var(--color-ink-on-primary);
}
.pf-btn--primary:hover { background: var(--color-primary-hover); }
.pf-btn--primary:active { background: var(--color-primary-pressed); }

.pf-btn--secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-ink);
}
.pf-btn--secondary:hover { background: var(--color-surface-2); }

.pf-btn--ghost {
  background: transparent;
  color: var(--color-primary);
}
.pf-btn--ghost:hover { background: var(--color-primary-tint); }

.pf-btn--danger {
  background: var(--color-danger-700);
  /* ink-on-primary is white in light mode and near-black in dark mode,
     where danger-700 is a light coral: keeps AA contrast in both. */
  color: var(--color-ink-on-primary);
}
.pf-btn--danger:hover { filter: brightness(1.08); }

.pf-btn:disabled,
.pf-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.pf-btn--loading {
  color: transparent !important;
  pointer-events: none;
}

.pf-btn--loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  color: inherit;
  animation: pf-spin 700ms linear infinite;
}

.pf-btn--secondary.pf-btn--loading::after,
.pf-btn--ghost.pf-btn--loading::after {
  border-color: var(--color-border);
  border-top-color: var(--color-primary);
}

@keyframes pf-spin {
  to { transform: rotate(360deg); }
}

/* Icon button — square, min 48px */
.pf-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--easing-standard);
}
.pf-icon-btn:hover { background: var(--color-surface-2); }
.pf-icon-btn--bordered { border-color: var(--color-border); background: var(--color-surface); }

/* =========================================================
   Text inputs
   Markup:
   <div class="pf-field">
     <label class="pf-field__label" for="x">Name</label>
     <input class="pf-input" id="x">
     <p class="pf-field__help">Helper text</p>
     <!-- or on error: -->
     <p class="pf-field__error">Required</p>
   </div>
   Add .pf-field--error to the wrapper and aria-invalid to the input.
   ========================================================= */

.pf-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.pf-field__label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-ink);
}

.pf-input,
.pf-select,
.pf-textarea {
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  transition: border-color var(--duration-fast) var(--easing-standard),
    box-shadow var(--duration-fast) var(--easing-standard);
}

.pf-textarea { min-height: calc(var(--tap-min) * 2); resize: vertical; }

.pf-input:focus-visible,
.pf-select:focus-visible,
.pf-textarea:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-tint);
  outline: none;
}

.pf-input::placeholder { color: var(--color-ink-muted); }

.pf-field__help {
  font-size: var(--font-size-xs);
  color: var(--color-ink-muted);
}

.pf-field__error {
  font-size: var(--font-size-xs);
  color: var(--color-danger-700);
  font-weight: var(--font-weight-medium);
}

.pf-field--error .pf-input,
.pf-field--error .pf-select {
  border-color: var(--color-danger-700);
}

/* =========================================================
   Search field
   Markup:
   <div class="pf-search">
     <svg class="pf-search__icon" ...></svg>
     <input class="pf-search__input" placeholder="Search customers">
     <button class="pf-search__clear" aria-label="Clear" hidden>×</button>
   </div>
   ========================================================= */

.pf-search {
  position: relative;
  display: flex;
  align-items: center;
}

.pf-search__icon {
  position: absolute;
  left: var(--space-3);
  width: 20px;
  height: 20px;
  color: var(--color-ink-muted);
  pointer-events: none;
}

.pf-search__input {
  width: 100%;
  min-height: var(--tap-primary);
  padding-left: var(--space-8);
  padding-right: var(--space-8);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: var(--font-size-md);
}

.pf-search__input:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-tint);
  outline: none;
}

.pf-search__clear {
  position: absolute;
  right: var(--space-2);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  color: var(--color-ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  line-height: 1;
}

/* =========================================================
   Results list (customer search rows)
   Markup:
   <ul class="pf-results">
     <li class="pf-result-row">
       <div class="pf-result-row__main">
         <span class="pf-result-row__name">Fairview Garden Centre</span>
         <span class="pf-result-row__meta">C-10234 · Harrogate, UK</span>
       </div>
       <span class="pf-badge pf-badge--customer">Customer</span>
     </li>
   </ul>
   ========================================================= */

.pf-results {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}

.pf-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--tap-primary);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--easing-standard);
}
.pf-result-row:last-child,
.pf-results > li:last-child > .pf-result-row { border-bottom: none; }

/* Rows are usually <button>s (whole row tappable): reset button chrome. */
button.pf-result-row {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
}
.pf-results > li { display: block; }

.pf-result-row__main { flex: 1 1 auto; }
.pf-result-row__short { display: block; font-size: var(--font-size-sm); font-weight: 600; color: var(--color-primary); }

/* A search result that cannot be added (no price on this programme). */
.pf-result-row--unavailable { cursor: default; opacity: .75; }
.pf-result-row--unavailable .pf-result-row__name { color: var(--color-ink-muted); }
.pf-result-row__note { display: block; margin-top: var(--space-1); font-size: var(--font-size-sm); font-weight: 600; color: var(--color-ink-muted); }

.pf-result-row__chevron {
  flex: none;
  color: var(--color-ink-muted);
}

.pf-result-row__add {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-tint);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pf-result-row:hover,
.pf-result-row:focus-visible { background: var(--color-primary-tint); }

.pf-result-row__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pf-result-row__name {
  font-weight: var(--font-weight-semibold);
  color: var(--color-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pf-result-row__meta {
  font-size: var(--font-size-sm);
  color: var(--color-ink-muted);
}

/* Type badge: Lead / Customer */
.pf-badge {
  flex: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}
.pf-badge--customer { background: var(--color-primary-tint); color: var(--color-primary); }
.pf-badge--lead { background: var(--color-accent-tint); color: var(--color-gold-text); }
.pf-badge--warning { background: var(--color-warning-100); color: var(--color-warning-700); }
.pf-badge--neutral { background: var(--color-surface-2); color: var(--color-ink); }

/* =========================================================
   Segmented control (programme FOB / Delivered / Collection)
   Markup:
   <div class="pf-segmented" role="tablist">
     <button class="pf-segmented__btn is-active" role="tab" aria-selected="true">FOB</button>
     <button class="pf-segmented__btn" role="tab" aria-selected="false">Delivered</button>
     <button class="pf-segmented__btn" role="tab" aria-selected="false">Collection</button>
   </div>
   ========================================================= */

.pf-segmented {
  display: inline-flex;
  padding: 4px;
  background: var(--color-surface-2);
  border-radius: var(--radius-pill);
  gap: 2px;
}

.pf-segmented__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 var(--space-4);
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-ink-muted);
  font-weight: var(--font-weight-medium);
  text-decoration: none; /* .pf-segmented__btn is also applied to <a> (filter links) */
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--easing-standard), color var(--duration-fast) var(--easing-standard);
}

.pf-segmented__btn.is-active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  font-weight: var(--font-weight-semibold);
}

/* =========================================================
   Variant chips (LED / RGB / Standard)
   Markup:
   <div class="pf-variant-chips">
     <button class="pf-variant-chip is-selected" data-variant="LED">
       <span class="pf-variant-chip__dot pf-variant-chip__dot--led"></span>LED</button>
     <button class="pf-variant-chip" data-variant="RGB">
       <span class="pf-variant-chip__dot pf-variant-chip__dot--rgb"></span>RGB</button>
     <button class="pf-variant-chip" data-variant="STANDARD">
       <span class="pf-variant-chip__dot pf-variant-chip__dot--standard"></span>Standard</button>
   </div>
   ========================================================= */

.pf-variant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pf-variant-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--easing-standard), background-color var(--duration-fast) var(--easing-standard);
}

.pf-variant-chip.is-selected {
  border-color: var(--color-accent);
  background: var(--color-accent-tint);
  color: var(--color-ink);
}

.pf-variant-chip__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.pf-variant-chip__dot--led { background: #FFF6DF; }
.pf-variant-chip__dot--rgb {
  background: conic-gradient(from 90deg, #e8556c, #f0a63d, #f3e15c, #58c07a, #4aa3e0, #9464d6, #e8556c);
}
.pf-variant-chip__dot--standard { background: var(--color-ink-muted); }

/* =========================================================
   Quantity stepper (−/value/+ 48px controls)
   Markup:
   <div class="pf-qty-stepper">
     <button class="pf-qty-stepper__btn" data-step="-1" aria-label="Decrease">−</button>
     <span class="pf-qty-stepper__value">4</span>
     <button class="pf-qty-stepper__btn" data-step="1" aria-label="Increase">+</button>
   </div>
   ========================================================= */

.pf-qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface);
}

.pf-qty-stepper__btn {
  width: var(--tap-min);
  height: var(--tap-min);
  min-width: var(--tap-min);
  flex: none;
  border: none;
  background: var(--color-surface-2);
  color: var(--color-primary);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  line-height: 1;
}
.pf-qty-stepper__btn:hover { background: var(--color-primary-tint); }

.pf-qty-stepper__value {
  min-width: 44px;
  text-align: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-md);
}

/* =========================================================
   Line card (quote line)
   Markup:
   <article class="pf-line-card">
     <div class="pf-line-card__main">
       <p class="pf-line-card__name">Nordmann Fir 180–200cm</p>
       <p class="pf-line-card__code">NF-180 · <span class="pf-variant-chip ...">LED</span></p>
     </div>
     <div class="pf-line-card__price">£64.00</div>
     <div class="pf-line-card__qty pf-qty-stepper">...</div>
     <div class="pf-line-card__total">£256.00</div>
     <button class="pf-icon-btn pf-line-card__remove" aria-label="Remove">×</button>
   </article>
   ========================================================= */

.pf-line-card {
  display: grid;
  grid-template-columns: 64px 1fr auto auto auto auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.pf-line-card__main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pf-line-card__name { font-weight: var(--font-weight-semibold); }
.pf-line-card__code {
  font-size: var(--font-size-sm);
  color: var(--color-ink-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pf-line-card__price { color: var(--color-ink-muted); font-size: var(--font-size-sm); }
.pf-line-card__total { font-weight: var(--font-weight-semibold); min-width: 80px; text-align: right; }
.pf-line-card__remove { color: var(--color-danger-700); }

@media (max-width: 819px) {
  .pf-line-card {
    grid-template-columns: 64px 1fr auto;
    grid-template-areas:
      "thumb main remove"
      "price price price"
      "qty qty total";
  }
  .pf-line-card > .pf-thumb { grid-area: thumb; }
  .pf-line-card__main { grid-area: main; }
  .pf-line-card__remove { grid-area: remove; }
  .pf-line-card__price { grid-area: price; }
  .pf-line-card__qty { grid-area: qty; }
  .pf-line-card__total { grid-area: total; }
}

/* =========================================================
   Totals panel
   Markup:
   <div class="pf-totals">
     <div class="pf-totals__row"><span>Subtotal</span><span>£1,024.00</span></div>
     <div class="pf-totals__row"><span>VAT (20%)</span><span>£234.80</span></div>
     <div class="pf-totals__row pf-totals__row--total"><span>Total</span>
       <span class="pf-totals__value">£1,408.80</span></div>
   </div>
   ========================================================= */

.pf-totals {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pf-totals__row {
  display: flex;
  justify-content: space-between;
  color: var(--color-ink-muted);
  font-size: var(--font-size-sm);
}

.pf-totals__row--total {
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  color: var(--color-ink);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.pf-totals__value {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
}

/* =========================================================
   Scan bar
   Markup:
   <div class="pf-scan-bar">
     <span class="pf-scan-bar__dot" aria-hidden="true"></span>
     <span class="pf-scan-bar__status">Ready to scan</span>
     <input class="pf-scan-bar__input" data-scan autocomplete="off" inputmode="none">
     <button class="pf-icon-btn pf-scan-bar__camera" aria-label="Scan with camera">📷</button>
   </div>
   States: add .pf-scan-bar--busy while a scan is being processed,
   .pf-scan-bar--error on a failed lookup.
   ========================================================= */

.pf-scan-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-primary-tint);
  border: 1px solid var(--color-border);
}

.pf-scan-bar__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
  flex: none;
  animation: pf-pulse 1.6s var(--easing-standard) infinite;
}

@keyframes pf-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31, 77, 58, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(31, 77, 58, 0); }
}

.pf-scan-bar__status {
  font-weight: var(--font-weight-medium);
  color: var(--color-primary);
  flex: 1 1 auto;
}

.pf-scan-bar--error .pf-scan-bar__dot { background: var(--color-danger-700); animation: none; }
.pf-scan-bar--error .pf-scan-bar__status { color: var(--color-danger-700); }
.pf-scan-bar--busy .pf-scan-bar__dot { animation-duration: 0.7s; }

/* Visually-hidden but focusable input that actually receives scanner keystrokes */
.pf-scan-bar__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* =========================================================
   Status pills (Draft / Sent / Ordered / Failed)
   Markup: <span class="pf-status-pill pf-status-pill--draft">Draft</span>
   ========================================================= */

.pf-status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.pf-status-pill--draft { background: var(--color-surface-2); color: var(--color-ink-muted); }
.pf-status-pill--sent { background: var(--color-info-100); color: var(--color-info-700); }
.pf-status-pill--superseded { background: var(--color-surface-2); color: var(--color-ink-muted); box-shadow: inset 0 0 0 1px var(--color-border); }
.pf-status-pill--ordered { background: var(--color-success-100); color: var(--color-success-700); }
.pf-status-pill--failed { background: var(--color-danger-100); color: var(--color-danger-700); }

/* =========================================================
   Toast / banner
   Markup:
   <div class="pf-banner pf-banner--error" role="alert">
     <p class="pf-banner__message">Could not reach the server.</p>
     <button class="pf-btn pf-btn--secondary pf-banner__retry">Retry</button>
   </div>
   Toast container for transient toasts: <div class="pf-toast-stack" id="toasts">
   ========================================================= */

.pf-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}

.pf-banner__message { flex: 1 1 auto; font-weight: var(--font-weight-medium); }

.pf-banner--info { background: var(--color-info-100); color: var(--color-info-700); }
.pf-banner--success { background: var(--color-success-100); color: var(--color-success-700); }
.pf-banner--error { background: var(--color-danger-100); color: var(--color-danger-700); }

.pf-toast-stack {
  position: fixed;
  right: var(--space-5);
  bottom: calc(var(--space-5) + var(--safe-bottom));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(360px, calc(100vw - var(--space-6)));
}

.pf-toast-stack .pf-banner {
  box-shadow: var(--shadow-lg);
  animation: pf-toast-in var(--duration-base) var(--easing-standard);
}

@keyframes pf-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Modal / bottom sheet
   Markup:
   <div class="pf-modal-scrim">
     <div class="pf-modal" role="dialog" aria-modal="true">
       <div class="pf-modal__header"><h2>Title</h2>
         <button class="pf-icon-btn" aria-label="Close">×</button></div>
       <div class="pf-modal__body">...</div>
       <div class="pf-modal__footer">...</div>
     </div>
   </div>
   Portrait: sheet slides from bottom. Landscape (>=820px): centered dialog.
   ========================================================= */

.pf-modal-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-scrim);
  background: rgba(15, 21, 18, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.pf-modal {
  position: relative;
  z-index: var(--z-modal);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--color-surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: var(--shadow-lg);
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + var(--safe-bottom));
  animation: pf-sheet-in var(--duration-base) var(--easing-standard);
}

@keyframes pf-sheet-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.pf-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.pf-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

@media (min-width: 820px) and (orientation: landscape) {
  .pf-modal-scrim { align-items: center; }
  .pf-modal {
    width: min(560px, 90vw);
    max-height: 80vh;
    border-radius: var(--radius-md);
    animation: pf-dialog-in var(--duration-base) var(--easing-standard);
  }
  @keyframes pf-dialog-in {
    from { transform: scale(0.97); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }
}

/* =========================================================
   Signature pad
   Markup:
   <div class="pf-signature-pad">
     <canvas class="pf-signature-pad__canvas" data-signature-canvas></canvas>
     <div class="pf-signature-pad__baseline"></div>
     <span class="pf-signature-pad__hint">Sign here</span>
     <button class="pf-btn pf-btn--ghost pf-signature-pad__clear" data-signature-clear>Clear</button>
     <input type="hidden" name="signature" data-signature-output>
   </div>
   ========================================================= */

.pf-signature-pad {
  position: relative;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}

.pf-signature-pad__canvas {
  display: block;
  width: 100%;
  height: 220px;
  touch-action: none;
  /* The pad always draws ink in a fixed dark colour (see signature.js)
     regardless of theme, so the drawing surface itself is kept a fixed
     light colour here rather than following --color-surface (which goes
     dark in dark mode and would make the stroke invisible). */
  background: #FFFFFF;
}

.pf-signature-pad__baseline {
  position: absolute;
  left: var(--space-5);
  right: var(--space-5);
  bottom: 56px;
  border-bottom: 1px solid var(--color-border);
  pointer-events: none;
}

.pf-signature-pad__hint {
  position: absolute;
  left: var(--space-5);
  bottom: 60px;
  color: var(--color-ink-muted);
  font-size: var(--font-size-sm);
  pointer-events: none;
}

.pf-signature-pad__clear {
  position: absolute;
  right: var(--space-3);
  top: var(--space-3);
}

/* =========================================================
   Send progress stepper
   Markup:
   <ol class="pf-send-steps">
     <li class="pf-send-step is-done"><span class="pf-send-step__dot"></span>Quotation</li>
     <li class="pf-send-step is-active"><span class="pf-send-step__dot"></span>Signature</li>
     <li class="pf-send-step"><span class="pf-send-step__dot"></span>PDF</li>
     <li class="pf-send-step is-error"><span class="pf-send-step__dot"></span>Email</li>
   </ol>
   ========================================================= */

.pf-send-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.pf-send-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-ink-muted);
  font-weight: var(--font-weight-medium);
}

.pf-send-step__dot {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  position: relative;
}

.pf-send-step.is-active .pf-send-step__dot {
  border-color: var(--color-primary);
  animation: pf-pulse 1.2s var(--easing-standard) infinite;
}
.pf-send-step.is-active { color: var(--color-primary); }

.pf-send-step.is-done .pf-send-step__dot {
  border-color: var(--color-success-700);
  background: var(--color-success-700);
}
.pf-send-step.is-done .pf-send-step__dot::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 4px;
  border-left: 2px solid var(--color-ink-on-primary);
  border-bottom: 2px solid var(--color-ink-on-primary);
  transform: rotate(-45deg) translateY(-1px);
}
.pf-send-step.is-done { color: var(--color-ink); }

.pf-send-step.is-error .pf-send-step__dot {
  border-color: var(--color-danger-700);
  background: var(--color-danger-100);
}
.pf-send-step.is-error { color: var(--color-danger-700); }

/* =========================================================
   Empty states
   Markup:
   <div class="pf-empty">
     <div class="pf-empty__icon">...</div>
     <p class="pf-empty__title">No quotes yet today</p>
     <p class="pf-empty__body">Scan an item or search a customer to start.</p>
   </div>
   ========================================================= */

.pf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-9) var(--space-5);
  color: var(--color-ink-muted);
}

.pf-empty__icon {
  width: 48px;
  height: 48px;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-2);
}

.pf-empty__title { color: var(--color-ink); font-weight: var(--font-weight-semibold); font-size: var(--font-size-lg); }

/* =========================================================
   Skeleton loaders
   Markup: <div class="pf-skeleton pf-skeleton--text"></div>
   ========================================================= */

.pf-skeleton {
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-border) 37%, var(--color-surface-2) 63%);
  background-size: 400% 100%;
  animation: pf-skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

.pf-skeleton--text { height: 16px; width: 100%; }
.pf-skeleton--row { height: var(--tap-primary); width: 100%; border-radius: var(--radius-md); }

@keyframes pf-skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* =========================================================
   Table (admin)
   Markup: <table class="pf-table"><thead>...<tbody>...
   ========================================================= */

.pf-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.pf-table th,
.pf-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
}

.pf-table th {
  background: var(--color-surface-2);
  color: var(--color-ink-muted);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: var(--font-size-xs);
}

.pf-table tbody tr:last-child td { border-bottom: none; }
.pf-table tbody tr:hover { background: var(--color-primary-tint); }
.pf-table tbody tr[data-href] { cursor: pointer; }

/* =========================================================
   HTMX indicator states
   Add .htmx-indicator elements next to a trigger; htmx toggles opacity via
   its own [class~="htmx-request"] mechanism. We style both.
   ========================================================= */

.htmx-indicator {
  opacity: 0;
  transition: opacity var(--duration-fast) var(--easing-standard);
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.htmx-request .pf-btn:not(.htmx-indicator) {
  opacity: 0.85;
}

.pf-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: pf-spin 700ms linear infinite;
}

/* =========================================================
   Step indicator (quote flow: Customer · Items · Review · Send)
   Markup:
   <nav class="pf-stepbar" aria-label="Quote progress">
     <ol class="pf-steps">
       <li class="pf-steps__item is-done"><a class="pf-steps__link" href="…">
         <span class="pf-steps__dot">✓</span><span class="pf-steps__label">Customer</span></a></li>
       <li class="pf-steps__item is-current" aria-current="step"><span class="pf-steps__link">…</span></li>
       <li class="pf-steps__item is-upcoming">…</li>
     </ol>
   </nav>
   ========================================================= */

.pf-stepbar {
  flex: none;
  display: flex;
  justify-content: center;
  padding: var(--space-1) var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.pf-steps {
  display: flex;
  align-items: center;
  gap: 0;
}

.pf-steps__item {
  display: flex;
  align-items: center;
  color: var(--color-ink-muted);
}

/* connector line between steps */
.pf-steps__item + .pf-steps__item::before {
  content: "";
  width: 40px;
  height: 2px;
  margin-inline: var(--space-1);
  border-radius: 1px;
  background: var(--color-border);
}
.pf-steps__item.is-done + .pf-steps__item::before,
.pf-steps__item.is-done + .pf-steps__item.is-current::before { background: var(--color-primary); }

.pf-steps__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  color: inherit;
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}
a.pf-steps__link:hover { background: var(--color-primary-tint); }

.pf-steps__dot {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pf-steps__item.is-done { color: var(--color-ink); }
.pf-steps__item.is-done .pf-steps__dot {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-ink-on-primary);
}
.pf-steps__item.is-current { color: var(--color-primary); }
.pf-steps__item.is-current .pf-steps__label { font-weight: var(--font-weight-bold); }
.pf-steps__item.is-current .pf-steps__dot {
  border-color: var(--color-primary);
  box-shadow: inset 0 0 0 4px var(--color-surface), inset 0 0 0 11px var(--color-primary);
}

@media (max-width: 820px) {
  .pf-steps__item + .pf-steps__item::before { width: 20px; }
  .pf-steps__link { padding: 0 var(--space-2); }
}

/* Phones: only the current step keeps its word; the others are dots, so the
   four steps fit a 360 px screen. */
@media (max-width: 640px) {
  .pf-stepbar { padding-inline: var(--space-3); }
  .pf-steps { max-width: 100%; }
  .pf-steps__item + .pf-steps__item::before { width: 14px; margin-inline: 2px; }
  .pf-steps__link { padding: 0 var(--space-1); gap: var(--space-1); }
  .pf-steps__item:not(.is-current) .pf-steps__label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}

/* =========================================================
   Account menu (opened from the app bar avatar)
   Markup:
   <div class="pf-menu-scrim" hidden data-menu>
     <div class="pf-menu" role="dialog">
       <div class="pf-menu__head">avatar + pf-menu__name / pf-menu__meta</div>
       <div class="pf-menu__items"><button class="pf-menu__item">…</button></div>
     </div>
   </div>
   ========================================================= */

.pf-menu-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-scrim);
  background: rgba(15, 21, 18, 0.18);
}

.pf-menu {
  position: absolute;
  top: calc(64px + var(--safe-top) - 4px);
  right: calc(var(--space-4) + var(--safe-right));
  width: min(360px, calc(100vw - 32px));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pf-menu-in var(--duration-base) var(--easing-standard);
}

/* Focus is moved to the dialog itself on open (for screen readers); it
   isn't an interactive control, so no ring. */
.pf-menu:focus, .pf-menu:focus-visible { outline: none; }

@keyframes pf-menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.pf-menu__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}

.pf-menu__who { min-width: 0; }
.pf-menu__name { font-weight: var(--font-weight-semibold); font-size: var(--font-size-lg); }
.pf-menu__meta { font-size: var(--font-size-sm); color: var(--color-ink-muted); }

.pf-menu__items { display: flex; flex-direction: column; padding: var(--space-2); }
.pf-menu__items form { display: contents; }

.pf-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--tap-primary);
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-ink);
  font: inherit;
  font-weight: var(--font-weight-medium);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.pf-menu__item:hover { background: var(--color-surface-2); }
.pf-menu__item[disabled] { opacity: 0.7; cursor: progress; }
.pf-menu__icon { flex: none; color: var(--color-primary); }
.pf-menu__text { display: flex; flex-direction: column; flex: 1 1 auto; }
.pf-menu__hint { font-size: var(--font-size-xs); color: var(--color-ink-muted); font-weight: var(--font-weight-regular); }
.pf-menu__item--danger,
.pf-menu__item--danger .pf-menu__icon { color: var(--color-danger-700); }
.pf-menu__items form::before { content: none; }
.pf-menu__item--danger { margin-top: var(--space-1); border-top: 1px solid var(--color-border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

/* =========================================================
   Cards, page heads, section titles
   ========================================================= */

.pf-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
}
.pf-card--flush { padding: 0; overflow: hidden; }
.pf-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 56px;
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.pf-page { padding-block: var(--space-3) var(--space-8); }

.pf-page__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.pf-section-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
}

.pf-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding-inline: var(--space-1);
}

.pf-search--hero .pf-search__input {
  min-height: 64px;
  font-size: var(--font-size-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.pf-search--hero .pf-search__icon { left: var(--space-4); width: 22px; height: 22px; }
.pf-search--hero .pf-search__input { padding-left: calc(var(--space-8) + 4px); }

/* Search inputs are type=search: hide WebKit's own cancel button (the
   design has none) and keep our font. */
.pf-search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.pf-search__input { -webkit-appearance: none; appearance: none; color: var(--color-ink); }

.pf-customer-results:empty { display: none; }

.pf-empty--panel {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-9) var(--space-6);
}
.pf-empty--panel .pf-btn { margin-top: var(--space-3); }
.pf-empty--panel p:not(.pf-empty__title) { max-width: 420px; }

.pf-empty--inline {
  align-items: flex-start;
  text-align: left;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  gap: var(--space-1);
}
.pf-empty--inline .pf-empty__title { font-size: var(--font-size-md); }
.pf-empty--inline .pf-btn { margin-top: var(--space-2); }

/* =========================================================
   Quote builder layout
   Markup:
   <div class="pf-builder">
     <section class="pf-builder__main">scan bar, tools, results, lines-head,
       <div class="pf-builder__lines">…line cards…</div></section>
     <aside class="pf-summary" data-summary>…</aside>
   </div>
   Landscape: two panes; lines scroll inside the left pane, the summary
   is a sticky right column. Portrait: the summary becomes a sticky
   bottom sheet (collapsed: total + CTA; tap to expand).
   ========================================================= */

.pf-builder {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 380px);
  gap: var(--space-5);
}

.pf-builder__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-height: 0;
  min-width: 0;
}

.pf-builder__tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.pf-builder__search { flex: 1 1 260px; max-width: 460px; }

.pf-builder__results { position: relative; z-index: var(--z-dropdown); }
.pf-builder__results:empty { display: none; }

.pf-results--popover {
  position: absolute;
  top: calc(-1 * var(--space-3));
  right: 0;
  width: min(520px, 100%);
  max-height: min(420px, 55vh);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.pf-results-empty {
  position: absolute;
  top: calc(-1 * var(--space-3));
  right: 0;
  width: min(520px, 100%);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--color-ink-muted);
}

.pf-builder__lines-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-inline: var(--space-1);
  margin-bottom: calc(-1 * var(--space-2));
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
}
.pf-builder__lines-head > .text-sm { margin-inline-start: auto; white-space: nowrap; }

.pf-builder__lines {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* room so the last card's shadow/focus ring isn't clipped */
  padding: 2px 2px var(--space-5);
  margin: -2px;
}

/* A sent, signed or ordered quote has more than lines (banner, signing,
   history): the whole left pane scrolls and the lines keep their full
   height instead of being squeezed into a small scroll box. */
.pf-builder--readonly .pf-builder__main { overflow-y: auto; padding-bottom: var(--space-5); }
.pf-builder--readonly .pf-builder__main > * { flex-shrink: 0; }
.pf-builder--readonly .pf-builder__lines { flex: 0 0 auto; overflow: visible; padding-bottom: 2px; }

/* History is secondary: collapsed until asked for. */
.pf-history-panel { padding: 0; }
.pf-history-panel__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 56px;
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  list-style: none;
}
.pf-history-panel__summary::-webkit-details-marker { display: none; }
.pf-history-panel__summary::after {
  content: "";
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--color-ink-muted);
  border-bottom: 2px solid var(--color-ink-muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
  flex: none;
}
.pf-history-panel[open] > .pf-history-panel__summary::after { transform: rotate(-135deg); }
.pf-history-panel__summary > span { margin-inline-start: auto; }
.pf-history-panel .pf-history { padding: 0 var(--space-5) var(--space-4); }

.pf-builder__lines .pf-customer-results:empty { display: none; }

.pf-empty--panel { min-height: 100%; justify-content: center; }

.pf-scan-bar__form { display: contents; }
.pf-scan-bar .pf-icon-btn--bordered { background: var(--color-surface); }

/* Summary (right pane / portrait bottom sheet) */
.pf-summary {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.pf-summary__bar { display: none; }

.pf-summary__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.pf-saved {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-ink-muted);
}
.pf-saved svg { color: var(--color-success-700); }

.pf-customer-card { display: flex; flex-direction: column; gap: var(--space-1); position: relative; }
.pf-customer-card__head { display: flex; align-items: center; gap: var(--space-2); min-width: 0; flex-wrap: wrap; }
.pf-customer-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }
.pf-customer-card__name {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  min-width: 0;
}
.pf-customer-card__meta { font-size: var(--font-size-sm); color: var(--color-ink-muted); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.pf-customer-card__email {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  font-size: var(--font-size-sm);
  min-width: 0;
  overflow-wrap: anywhere;
}
.pf-customer-card__email svg { flex: none; color: var(--color-ink-muted); }
.pf-customer-card__change { flex: none; margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-3)) 0 0; }

.pf-totals__note { font-size: var(--font-size-xs); color: var(--color-success-700); text-align: right; }

@media (orientation: portrait), (max-width: 900px) {
  .pf-builder { grid-template-columns: minmax(0, 1fr); }
  /* leave room above the collapsed bottom sheet */
  .pf-builder__lines { padding-bottom: 120px; }
  .pf-builder--readonly .pf-builder__main { padding-bottom: 120px; }
  .pf-builder--readonly .pf-builder__lines { padding-bottom: 2px; }

  .pf-summary {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-action-bar);
    max-height: 80vh;
    padding: var(--space-3) calc(var(--space-5) + var(--safe-right)) calc(var(--space-3) + var(--safe-bottom)) calc(var(--space-5) + var(--safe-left));
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: 0 -8px 28px rgba(28, 31, 29, 0.14);
  }

  .pf-summary__bar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }
  .pf-summary__bar > .pf-btn { width: auto; flex: none; min-width: min(240px, 44vw); padding-inline: var(--space-4); }
  .pf-summary__toggle { min-width: 0; }

  .pf-summary__toggle {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--tap-primary);
    padding: 0 var(--space-2);
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-ink);
    text-align: left;
    cursor: pointer;
  }
  .pf-summary__toggle:hover { background: var(--color-surface-2); }
  .pf-summary__toggle-text { display: flex; flex-direction: column; }
  .pf-summary__toggle-label { font-size: var(--font-size-xs); color: var(--color-ink-muted); font-weight: var(--font-weight-medium); }
  .pf-summary__toggle-total { font-size: var(--font-size-2xl); font-weight: var(--font-weight-bold); color: var(--color-primary); line-height: 1.1; }
  .pf-summary__chevron { color: var(--color-ink-muted); transition: transform var(--duration-base) var(--easing-standard); }
  .pf-summary.is-expanded .pf-summary__chevron { transform: rotate(180deg); }

  .pf-summary__body { display: none; }
  .pf-summary.is-expanded .pf-summary__body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: var(--space-4);
    padding-top: var(--space-4);
    margin-top: var(--space-3);
    border-top: 1px solid var(--color-border);
    overflow-y: auto;
  }
  .pf-summary__cta, .pf-summary .pf-saved { display: none; }

  /* iPad Safari keyboard finding: hide the fixed bottom sheet entirely
     while a text input/textarea has focus, so the on-screen keyboard
     (which shrinks the visual viewport, not the layout viewport) can't
     leave it floating over/under the keyboard covering the field being
     typed into. Restored on blur (see app.js). */
  .pf-summary.pf-summary--keyboard-collapsed { display: none; }

  /* Open sheet: never taller than the VISIBLE screen below the app header
     (iOS 'vh' includes the area under Safari's toolbar, which pushed the
     sheet's top under the header), and its body scrolls inside it. */
  .pf-summary.is-expanded:not(.pf-summary--editing) {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
  }
  .pf-summary.is-expanded:not(.pf-summary--editing) > .pf-summary__bar { flex: none; }
  .pf-summary.is-expanded:not(.pf-summary--editing) .pf-summary__body {
    flex: 1 1 auto;
    min-height: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* A field inside the sheet is being typed into: take the sheet out of the
     fixed position so the iOS keyboard and its scrolling can't clip it. */
  .pf-summary.pf-summary--editing {
    position: static;
    max-height: none;
    overflow: visible;
    margin-top: var(--space-4);
    padding-bottom: calc(var(--space-6) + var(--safe-bottom));
    box-shadow: none;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
  }
}

@media (max-width: 820px) {
  .pf-summary.is-expanded .pf-summary__body { grid-template-columns: 1fr; }
}

/* Line card refinements: variant chips inside the card */
.pf-line-card { box-shadow: var(--shadow-sm); }
.pf-line-card__main { gap: 6px; }
.pf-line-card__name { line-height: var(--line-height-tight); }
.pf-line-card__code { flex-wrap: wrap; }
.pf-line-card__price { text-align: right; min-width: 72px; }
.pf-line-card__total { min-width: 96px; font-size: var(--font-size-lg); }
.pf-line-card__qty--static { font-weight: var(--font-weight-semibold); min-width: 64px; text-align: center; }
.pf-line-card__remove { color: var(--color-ink-muted); }
.pf-line-card__remove:hover { color: var(--color-danger-700); background: var(--color-danger-100); }
.pf-qty-stepper__btn:disabled { color: var(--color-ink-muted); opacity: 0.45; cursor: not-allowed; }
.pf-qty-stepper__btn:disabled:hover { background: var(--color-surface-2); }

.pf-variant-chips--sm { gap: var(--space-2); margin-top: 2px; }
.pf-variant-chips--sm .pf-variant-chip {
  position: relative;
  min-height: 40px;
  padding: 0 var(--space-3);
  font-size: var(--font-size-sm);
}
/* 48px hit area around the 40px visual chip */
.pf-variant-chips--sm .pf-variant-chip::after {
  content: "";
  position: absolute;
  inset: -4px -2px;
}
.pf-variant-chip:not(.is-selected):hover { border-color: var(--color-primary); background: var(--color-primary-tint); }
.pf-variant-chip.is-selected { cursor: default; font-weight: var(--font-weight-semibold); }
.pf-variant-chip[disabled] { opacity: 0.6; }

/* Static (non-interactive) variant label */
.pf-variant-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-ink);
  white-space: nowrap;
  flex: none;
}
.pf-variant-tag .pf-variant-chip__dot { width: 10px; height: 10px; }

@media (max-width: 819px) {
  .pf-line-card { grid-template-columns: 1fr auto auto; grid-template-areas: "main main remove" "price qty total"; row-gap: var(--space-3); }
  .pf-line-card__price { text-align: left; }
}

/* =========================================================
   Review screen
   ========================================================= */

.pf-review {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(400px, 460px);
  gap: var(--space-5);
  align-items: start;
  max-width: 1320px;
  margin-inline: auto;
}
.pf-review__sign { position: sticky; top: 0; }

@media (orientation: portrait), (max-width: 900px) {
  .pf-review { grid-template-columns: minmax(0, 1fr); }
  .pf-review__sign { position: static; }
}

.pf-review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
}
.pf-review-head__main { min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.pf-review-head__name { font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); line-height: var(--line-height-tight); }
.pf-review-head__facts { display: flex; gap: var(--space-6); margin: 0; }
.pf-review-head__facts dt { font-size: var(--font-size-xs); color: var(--color-ink-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: var(--font-weight-semibold); }
.pf-review-head__facts dd { margin: 0; font-weight: var(--font-weight-semibold); font-size: var(--font-size-lg); }

.pf-review-lines { display: flex; flex-direction: column; }
.pf-review-line {
  display: grid;
  grid-template-columns: 48px 48px minmax(0, 1fr) auto 104px;
  align-items: center;
  gap: var(--space-3);
  min-height: 64px;
  padding: var(--space-2) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.pf-review-line:last-child { border-bottom: none; }
.pf-review-line__qty { font-weight: var(--font-weight-bold); color: var(--color-primary); }
.pf-review-line__main { display: flex; flex-direction: column; min-width: 0; }
.pf-review-line__name { font-weight: var(--font-weight-semibold); }
.pf-review-line__meta { font-size: var(--font-size-sm); color: var(--color-ink-muted); }
.pf-review-line__total { text-align: right; font-weight: var(--font-weight-semibold); }

.pf-review__reason { min-height: 1.45em; font-size: var(--font-size-sm); color: var(--color-danger-700); text-align: center; }
.pf-review__reason:empty { display: none; }

/* Inline-edit field: shows the value with an Edit button; editing (or no
   value yet) shows the input instead. */
[data-inline-edit] .pf-inline-edit__input { display: none; }
[data-inline-edit][data-editing] .pf-inline-edit__input { display: block; }
[data-inline-edit][data-editing] .pf-inline-edit__view { display: none; }
.pf-inline-edit__view {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--tap-min);
  padding: 0 var(--space-1) 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}
.pf-inline-edit__value { font-weight: var(--font-weight-medium); overflow-wrap: anywhere; }

.pf-signature-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pf-signature-state {
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  background: var(--color-warning-100);
  color: var(--color-warning-700);
}
.pf-signature-pad.is-signed { border-style: solid; border-color: var(--color-success-700); }
.pf-signature-pad:not(.is-signed) { border-color: var(--color-warning-700); }
.pf-signature-pad.is-signed .pf-signature-pad__hint { display: none; }
.pf-signature-state.is-signed { background: var(--color-success-100); color: var(--color-success-700); }
.pf-signature-pad__stored {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  background: #FFFFFF;
}
/* The pad surface is always white (see .pf-signature-pad__canvas), so its
   hint, baseline and Clear button keep light-surface colours in dark mode. */
.pf-signature-pad__hint { color: #5E6660; }
.pf-signature-pad__baseline { border-bottom-color: #D5CEC1; }
.pf-signature-pad__clear { color: #1F4D3A; background: rgba(255, 255, 255, 0.85); }
.pf-signature-pad__clear:hover { background: #E6EFEA; }

/* =========================================================
   Send screen
   ========================================================= */

.pf-center {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: var(--space-6);
}

.pf-send-card {
  width: min(600px, 100%);
  padding: var(--space-7);
  gap: var(--space-5);
  box-shadow: var(--shadow-lg);
}

.pf-success { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); }
.pf-success__icon {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-success-100);
  color: var(--color-success-700);
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--color-success-100) 45%, transparent);
  margin-bottom: var(--space-2);
  animation: pf-pop 320ms var(--easing-standard);
}
@keyframes pf-pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.pf-success__sub { font-size: var(--font-size-lg); color: var(--color-ink-muted); }

.pf-send-steps--row {
  flex-direction: row;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-5);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
}
.pf-send-steps--row .pf-send-step { gap: var(--space-2); }
.pf-send-steps--row .pf-send-step__dot { width: 20px; height: 20px; }

.pf-banner__icon { flex: none; }
.pf-banner--stacked { align-items: flex-start; padding: var(--space-4) var(--space-5); }
.pf-banner__title { font-weight: var(--font-weight-bold); font-size: var(--font-size-lg); }
.pf-banner--stacked .pf-banner__message { font-weight: var(--font-weight-regular); color: var(--color-ink); }

.pf-details summary { cursor: pointer; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); min-height: 32px; display: flex; align-items: center; }
.pf-details p { font-size: var(--font-size-xs); color: var(--color-ink-muted); overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.pf-actions { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.pf-actions--center { justify-content: center; }
.pf-actions--grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.pf-actions--grid > :first-child { grid-column: 1 / -1; }
.pf-actions--grid > :last-child:nth-child(2) { grid-column: 1 / -1; }

.pf-send-step.is-error .pf-send-step__dot::after {
  content: "!";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: var(--font-weight-bold);
  color: var(--color-danger-700);
}

/* =========================================================
   Quotes list: summary strip + table polish
   ========================================================= */

.pf-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 0;
}
.pf-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
}
.pf-stat dt { font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-ink-muted); }
.pf-stat dd { margin: var(--space-1) 0 0; font-size: var(--font-size-2xl); font-weight: var(--font-weight-bold); line-height: 1.15; }
.pf-stat--accent dd { color: var(--color-success-700); }

.pf-table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.pf-table-wrap .pf-table { border: none; border-radius: 0; }
.pf-table td { vertical-align: middle; }
.pf-table--quotes td { padding-block: var(--space-2); height: 68px; font-size: var(--font-size-md); }
.numeric-col { text-align: right !important; }
.pf-col-actions { text-align: right !important; width: 1%; white-space: nowrap; }
.pf-col-total { font-weight: var(--font-weight-semibold); }
.pf-row-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }
.pf-row-actions form { display: contents; }
.pf-row-link { color: var(--color-ink); font-weight: var(--font-weight-semibold); text-decoration: none; }
.pf-row-link--muted { color: var(--color-ink-muted); font-weight: var(--font-weight-medium); }
.pf-cell-main { display: block; font-weight: var(--font-weight-medium); }
.pf-cell-meta { display: block; font-size: var(--font-size-xs); color: var(--color-ink-muted); }
.pf-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--font-size-xs); font-weight: var(--font-weight-bold); padding: 2px 6px; border-radius: 6px; background: var(--color-surface-2); }
.pf-cell-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--font-size-xs); overflow-wrap: anywhere; }
.pf-cell-error {
  font-size: var(--font-size-xs);
  color: var(--color-ink-muted);
  max-width: 420px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pf-status-pill--sending { background: var(--color-warning-100); color: var(--color-warning-700); }

.pf-col-quote { white-space: nowrap; }
.pf-col-quote .pf-status-pill { display: none; margin-top: var(--space-1); }

@media (max-width: 1100px) {
  .pf-col-lines { display: none; }
}
@media (max-width: 900px) {
  .pf-col-time, .pf-col-status { display: none; }
  .pf-col-quote .pf-status-pill { display: inline-flex; }
  .pf-col-quote .pf-row-link { display: block; }
  .pf-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-table--quotes th, .pf-table--quotes td { padding-inline: var(--space-3); }
}

/* Phones: a quote is a small card (number and total, customer, actions) so
   the list never scrolls sideways. */
@media (max-width: 640px) {
  .pf-table--quotes, .pf-table--quotes tbody { display: block; width: 100%; }
  .pf-table--quotes thead {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .pf-table--quotes tr.pf-table__row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-3);
    padding: var(--space-3); border-bottom: 1px solid var(--color-border); align-items: center;
  }
  .pf-table--quotes tr.pf-table__row > td {
    display: block; height: auto; padding: var(--space-1) 0; border: 0; min-width: 0;
    grid-column: 1 / -1; white-space: normal; overflow-wrap: anywhere;
  }
  .pf-table--quotes tr.pf-table__row > td:first-child { grid-column: 1; grid-row: 1; }
  .pf-table--quotes tr.pf-table__row > td.numeric-col { grid-column: 2; grid-row: 1; white-space: nowrap; }
  .pf-table--quotes tr.pf-table__row > td.pf-col-actions { width: auto; text-align: left !important; }
  .pf-table--quotes .pf-row-actions { flex-wrap: wrap; justify-content: flex-start; }
}

/* =========================================================
   Login
   ========================================================= */

.pf-login {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background:
    radial-gradient(1000px 520px at 50% -10%, var(--color-primary-tint), transparent 70%),
    var(--color-bg);
}

.pf-login__card {
  width: min(420px, 100%);
  padding: var(--space-8) var(--space-7) var(--space-7);
  gap: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}

.pf-login__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.pf-login__brand .pf-app-bar__badge { margin: 0; }
.pf-login__mark { width: 64px; height: 64px; border-radius: 16px; box-shadow: var(--shadow-md); }
.pf-login__foot { font-size: var(--font-size-sm); color: var(--color-ink-muted); text-align: center; }

/* =========================================================
   Forms / sheets misc
   ========================================================= */

.pf-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-4); }
.pf-form-grid > * { min-width: 0; }
@media (max-width: 600px) { .pf-form-grid { grid-template-columns: minmax(0, 1fr); } }
.pf-field__req { color: var(--color-danger-700); }
.pf-select { -webkit-appearance: none; appearance: none; padding-right: var(--space-7);
  background-image: linear-gradient(45deg, transparent 50%, var(--color-ink-muted) 50%), linear-gradient(135deg, var(--color-ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
.pf-modal__header { align-items: flex-start; gap: var(--space-3); }
.pf-modal .pf-input, .pf-modal .pf-select { width: 100%; }

.pf-convert__label { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); }
.pf-checklist { display: flex; flex-direction: column; gap: var(--space-2); }
.pf-checklist li { position: relative; padding-left: var(--space-6); color: var(--color-ink-muted); }
.pf-checklist li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.35em;
  width: 12px;
  height: 7px;
  border-left: 2px solid var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  transform: rotate(-45deg);
}

.pf-input { width: 100%; }

/* =========================================================
   Typed quantity (a number field between the -/+ buttons) and the
   quote History list.
   ========================================================= */
.pf-qty-stepper__input {
  width: 72px;
  min-width: 56px;
  height: var(--tap-min);
  padding: 0 var(--space-2);
  border: none;
  border-inline: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-surface);
  color: var(--color-ink);
  font: inherit;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-md);
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.pf-qty-stepper__input::-webkit-inner-spin-button,
.pf-qty-stepper__input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.pf-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.pf-history__item {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: var(--space-1) var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border);
}
.pf-history__item:first-child { border-top: none; }
.pf-history__when { color: var(--color-ink-muted); font-size: var(--font-size-sm); }
.pf-history__what { font-weight: var(--font-weight-medium); }
.pf-history__meta { color: var(--color-ink-muted); font-size: var(--font-size-sm); }
@media (max-width: 520px) {
  .pf-history__item { grid-template-columns: 1fr; }
}

/* Programme selector on the builder (programmes come from the database and
   have long labels, so a select rather than a segmented control). */
.pf-programme { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; min-width: 0; }
.pf-programme .pf-select { max-width: 100%; }
/* No programme chosen yet (nothing is preselected): make the choice stand out. */
.pf-programme--needed { background: var(--color-accent-tint); border: 2px solid var(--color-accent); border-radius: var(--radius-md, 8px); padding: var(--space-3); flex: 1 1 100%; }
.pf-programme__prompt { font-weight: var(--font-weight-medium); color: var(--color-gold-text); }

/* Line price change: a numeric input (decimal keypad) with the original
   list price and a "Price changed" badge under it. */
.pf-line-card__price--edit { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); }
.pf-price-input { width: 7rem; text-align: right; min-height: var(--tap-min); padding: var(--space-2) var(--space-3); }
.pf-price-was { color: var(--color-ink-muted); font-size: var(--font-size-sm); }
@media (max-width: 760px) {
  .pf-line-card__price--edit { align-items: flex-start; }
}

/* =========================================================
   Admin screens (Administrator role): section nav, landing cards, tables
   that scroll sideways on a narrow screen, inline price forms.
   ========================================================= */
.pf-admin-nav { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pf-admin-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
}
.pf-admin-nav__link.is-active { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-ink-on-primary); }
.pf-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.pf-admin-card { display: flex; flex-direction: column; gap: var(--space-2); min-height: 120px; color: var(--color-ink); text-decoration: none; }
.pf-admin-card:hover { border-color: var(--color-primary); }
.pf-admin-card__title { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); }
.pf-table-scroll { overflow-x: auto; }
.pf-table-scroll .pf-table { min-width: 640px; }
.pf-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.pf-filter .pf-field { min-width: 12rem; }
.pf-filter .pf-field--grow { flex: 1 1 16rem; }
.pf-inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.pf-inline-form .pf-input--price { width: 8rem; }
.pf-inline-form .pf-input--breaks { width: 16rem; max-width: 100%; }
.pf-check { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap-min); }
.pf-check input { width: 24px; height: 24px; }
.pf-check > label { flex: 1; cursor: pointer; padding-block: var(--space-2); }
/* A customer's other contacts on the admin customer page (one form each). */
.pf-contact-row { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.pf-pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pf-pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--font-size-xs); overflow-wrap: anywhere; white-space: pre-wrap; margin: 0; }
.pf-status-pill--on { background: var(--color-success-100); color: var(--color-success-700); }
.pf-status-pill--off { background: var(--color-surface-2); color: var(--color-ink-muted); box-shadow: inset 0 0 0 1px var(--color-border); }
.pf-issue--error td:first-child { box-shadow: inset 3px 0 0 var(--color-danger-700); }
.pf-issue--warning td:first-child { box-shadow: inset 3px 0 0 var(--color-warning-700); }
.pf-company-preview { display: flex; gap: var(--space-5); align-items: flex-start; flex-wrap: wrap; }
.pf-company-preview img { max-height: 80px; max-width: 220px; object-fit: contain; }
.pf-preview-note { color: var(--color-ink-muted); font-size: var(--font-size-sm); }

/* =========================================================
   Public signing page (no login) and the "Customer signing" panel
   ========================================================= */
.pf-public { background: var(--color-bg); }
.pf-public__col { width: 100%; max-width: 760px; margin-inline: auto; }
.pf-public__message { text-align: center; align-items: center; padding-block: var(--space-7); }
.pf-public__subhead { font-weight: var(--font-weight-semibold); }
.pf-public__lines td, .pf-public__lines th { overflow-wrap: anywhere; }
.pf-public .pf-table-scroll .pf-table { min-width: 0; }
.pf-signing__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pf-signing__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.pf-signing__actions form { margin: 0; }
.pf-signing__facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-4); margin: 0; }
.pf-signing__facts dt { color: var(--color-ink-muted); }
.pf-signing__facts dd { margin: 0; overflow-wrap: anywhere; }

/* =========================================================
   Product thumbnails (served from /img/<code>, cached by the app)
   Fixed-size box so a late-loading picture never shifts the layout.
   Markup: {{template "product_thumb" (dict "Code" .ItemCode "S" "thumb" "Px" 48)}}
   ========================================================= */
.pf-thumb {
  display: block;
  flex: none;
  object-fit: contain;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.pf-thumb--preview { width: 240px; height: 240px; max-width: 100%; }
.pf-image-panel { display: flex; gap: var(--space-5); align-items: flex-start; flex-wrap: wrap; }
.pf-image-health { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }


/* =========================================================
   Follow-up list (S20)
   Markup: ul.pf-followups > li.pf-followup--{low|mid|high}
     (.pf-followup__head with .pf-age-chip, dl.pf-followup__meta,
      .pf-followup__actions with <details class="pf-followup__more">)
   The age chip carries its meaning in text and in a shape, not in
   colour alone.
   ========================================================= */

.pf-status-pill--lost { background: var(--color-danger-100); color: var(--color-danger-700); box-shadow: inset 0 0 0 1px var(--color-danger-700); }

.pf-followups { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.pf-followup {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left-width: 6px;
  border-radius: var(--radius-md);
}
.pf-followup--low { border-left-color: var(--color-success-700); }
.pf-followup--mid { border-left-color: var(--color-warning-700); }
.pf-followup--high { border-left-color: var(--color-danger-700); }
.pf-followup__head { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.pf-followup__quote { font-weight: var(--font-weight-bold); font-size: var(--font-size-lg); min-height: var(--tap-min); display: inline-flex; align-items: center; }
.pf-followup__customer { flex: 1 1 200px; display: grid; }
.pf-followup__meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3) var(--space-5); margin: 0; }
.pf-followup__meta dt { font-size: var(--font-size-xs); color: var(--color-ink-muted); }
.pf-followup__meta dd { margin: 0; font-size: var(--font-size-sm); }
.pf-followup__flags { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.pf-followup__flags:empty { display: none; }
.pf-followup__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: flex-start; }
.pf-followup__actions form { display: contents; }
.pf-followup__more { position: relative; }
.pf-followup__more > summary { list-style: none; cursor: pointer; }
.pf-followup__more > summary::-webkit-details-marker { display: none; }
.pf-followup__panel {
  display: grid !important;
  gap: var(--space-2);
  min-width: 260px;
  margin-top: var(--space-2);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.pf-age-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  border: 1px solid currentColor;
}
.pf-age-chip--low { background: var(--color-success-100); color: var(--color-success-700); }
.pf-age-chip--mid { background: var(--color-warning-100); color: var(--color-warning-700); }
.pf-age-chip--high { background: var(--color-danger-100); color: var(--color-danger-700); }
.pf-age-chip__shape { display: inline-block; width: 12px; height: 12px; background: currentColor; }
.pf-age-chip__shape--circle { border-radius: 50%; }
.pf-age-chip__shape--diamond { transform: rotate(45deg) scale(0.85); }
.pf-age-chip__shape--triangle { clip-path: polygon(50% 0, 100% 100%, 0 100%); }

.pf-chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.pf-badge--lost { background: var(--color-danger-100); color: var(--color-danger-700); }

/* ---- Quote fields (Drop 3: notes, PO, discount) ------------------------ */
.pf-quote-fields .pf-textarea { width: 100%; }
.pf-quote-fields .pf-input { width: 100%; }
.pf-notes { white-space: pre-line; margin: 0; }
.pf-discount { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.pf-discount__input { width: 6.5rem; text-align: right; }

/* =========================================================
   Phone width (<= 640px) fixes from the iPhone screen review.
   Kept at the end so they win over the earlier rules.
   ========================================================= */
@media (max-width: 640px) {
  /* Builder: the page scrolls, not a small box around the lines. */
  .pf-app__main.pf-app__main--fixed { overflow-y: auto; display: block; }
  .pf-builder { flex: 0 0 auto; min-height: auto; }
  .pf-builder__main { min-height: auto; }
  .pf-builder__lines { flex: 0 0 auto; overflow: visible; overscroll-behavior: auto; }

  /* Review: facts wrap in two columns, lines fit the width. */
  .pf-review-head__facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); width: 100%; }
  .pf-review-head__facts > div { min-width: 0; }
  .pf-review-head__facts > div:first-child { grid-column: 1 / -1; }
  .pf-review-head__facts dd { font-size: var(--font-size-md); overflow-wrap: anywhere; }
  .pf-review-line {
    grid-template-columns: auto 40px minmax(0, 1fr) auto;
    padding-inline: var(--space-3);
    gap: var(--space-2) var(--space-3);
  }
  .pf-review-line__main { grid-column: 3; }
  .pf-review-line__total { grid-column: 4; grid-row: 1; }
  .pf-review-line > .pf-variant-tag { grid-column: 3; justify-self: start; }
  .pf-review-line__name, .pf-review-line__meta { overflow-wrap: anywhere; }

  /* Stat tiles: long multi-currency values wrap inside the card. */
  .pf-stat { min-width: 0; padding: var(--space-3) var(--space-4); }
  .pf-stat dd { font-size: var(--font-size-xl); overflow-wrap: break-word; }

  /* Admin section links: one swipeable row instead of a tall block. */
  .pf-admin-nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--space-1); }
  .pf-admin-nav__link { flex: 0 0 auto; white-space: nowrap; }
}

/* Line cards on phones/tablets in portrait: an earlier 819px rule dropped the
   picture from the grid areas, which scattered the stepper and the picture. */
@media (max-width: 819px) {
  .pf-line-card {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas:
      "thumb main remove"
      "price price price"
      "qty qty total";
    align-items: start;
    row-gap: var(--space-3);
  }
  .pf-line-card > .pf-thumb { grid-area: thumb; }
  .pf-line-card__qty { justify-self: start; align-self: center; }
  .pf-line-card__total { align-self: center; }
  .pf-line-card__price, .pf-line-card__price--edit { text-align: left; align-items: flex-start; min-width: 0; }
}

/* Sent/ordered quotes put several actions in the bottom bar: on a phone they
   wrap under the total instead of running off the right edge. */
@media (max-width: 900px) {
  .pf-summary__bar { flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
  .pf-summary__bar > .pf-summary__toggle { flex: 1 1 100%; min-height: 0; }
  .pf-summary__bar > form,
  .pf-summary__bar > details,
  .pf-summary__bar > a,
  .pf-summary__bar > .pf-btn { flex: 1 1 28%; min-width: 0; }
  .pf-summary__bar .pf-btn { width: 100%; min-width: 0; padding-inline: var(--space-2); white-space: normal; text-align: center; }
  .pf-builder--readonly .pf-builder__main { padding-bottom: 180px; }
}
@media (max-width: 640px) {
  .pf-summary__bar > form,
  .pf-summary__bar > details,
  .pf-summary__bar > a,
  .pf-summary__bar > .pf-btn { flex-basis: 40%; }
  .pf-builder--readonly .pf-builder__main { padding-bottom: 220px; }
}

/* Customer signing page: numbers and column headings never break inside a
   word; the item name takes the slack. */
.pf-public__lines th.numeric-col,
.pf-public__lines td.numeric-col { overflow-wrap: normal; white-space: nowrap; }
@media (max-width: 640px) {
  .pf-public__lines th, .pf-public__lines td { padding-inline: var(--space-2); }
  .pf-public__lines th { letter-spacing: 0; }
}

/* A fieldset sizes to its widest child by default; a select with a long
   option text made the whole Email server step wider than a phone. */
fieldset { min-width: 0; }
.pf-field .pf-select, .pf-field .pf-input { max-width: 100%; }

/* Long button labels wrap on a phone instead of running off the screen. */
@media (max-width: 640px) {
  .pf-btn { white-space: normal; text-align: center; max-width: 100%; }
}

/* Action groups on a phone: one full-width button per row (the two-column
   grid squeezed "View in My quotes" into three lines), start-aligned. */
@media (max-width: 640px) {
  .pf-actions--grid { grid-template-columns: minmax(0, 1fr); }
  .pf-actions--grid > .pf-btn { width: 100%; }
  .pf-page__head .pf-actions { justify-content: flex-start; width: 100%; }
}

/* My quotes on a phone: the whole card opens the quote (app.js), and the
   links and small buttons inside it are at least 44 px tall to tap. */
@media (max-width: 640px) {
  .pf-table--quotes .pf-row-link { display: inline-flex; align-items: center; min-height: 44px; }
  .pf-table--quotes .pf-row-actions .pf-btn { min-height: 44px; }
}

/* =========================================================
   iPhone first (Dec 2026 review): the phone's camera is the scanner, so
   scanning and the quote's lines get the space and the thumb zone.
   Checked on iPhone SE (375x667) up to 15 Pro Max (430x932).
   ========================================================= */

/* The Scan button lives in the bottom bar on phones only. */
.pf-summary__scan { display: none; }

/* A line that a scan or an add just created or raised flashes once. */
@keyframes pf-line-added {
  from { box-shadow: 0 0 0 3px var(--color-primary); background: var(--color-primary-tint); }
  to { box-shadow: var(--shadow-sm); background: var(--color-surface); }
}
.pf-line-card.is-just-added { animation: pf-line-added 1.4s var(--easing-standard); }
@media (prefers-reduced-motion: reduce) {
  .pf-line-card.is-just-added { animation: none; outline: 3px solid var(--color-primary); }
}

/* Camera sheet: the picture never pushes Done off a small screen; a green
   or red frame says at a glance whether the item went in. */
.pf-camera-scan__frame {
  border-radius: 14px;
  border: 4px solid transparent;
  overflow: hidden;
  background: #000;
}
.pf-camera-scan__video {
  display: block;
  width: 100%;
  height: min(42vh, 360px);
  min-height: 200px;
  object-fit: cover;
  background: #000;
}
@keyframes pf-scan-ok { from { border-color: var(--color-success-700); } to { border-color: transparent; } }
@keyframes pf-scan-error { from { border-color: var(--color-danger-700); } to { border-color: transparent; } }
.pf-camera-scan__frame.is-ok { animation: pf-scan-ok 0.9s ease-out; }
.pf-camera-scan__frame.is-error { animation: pf-scan-error 1.4s ease-out; }
.pf-camera-scan__result {
  margin-top: var(--space-3);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
}
.pf-camera-scan__result.is-error { color: var(--color-danger-700); }
.pf-camera-scan__message { margin-top: var(--space-1); }
.pf-camera-scan__done { margin-top: var(--space-4); }
.pf-camera-scan .pf-modal__header .pf-icon-btn { min-width: 48px; min-height: 48px; font-size: 26px; }

.pf-line-card__each { display: none; }

@media (max-width: 640px) {
  /* Header: the back arrow is a full 44 px target. */
  .pf-app-bar__back { min-width: 44px; justify-content: center; }

  /* Search: the event is already in the header, so the lines get the row. */
  #pf-quote-event { display: none; }

  /* Bottom bar while editing: row 1 the total (tap for the panel), row 2
     Scan and Review side by side, both in thumb reach. */
  .pf-builder:not(.pf-builder--readonly) .pf-summary { padding-top: var(--space-2); }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-2);
  }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__bar > .pf-summary__toggle {
    grid-column: 1 / -1;
    min-height: var(--tap-min);
    padding: 0 var(--space-1);
  }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__toggle-text {
    flex: 1 1 auto;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    min-width: 0;
  }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__toggle-label { font-size: var(--font-size-sm); }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__saved { display: none; }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__toggle-total { font-size: var(--font-size-xl); white-space: nowrap; }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__bar > .pf-btn,
  .pf-builder:not(.pf-builder--readonly) .pf-summary__bar > a.pf-btn {
    width: 100%;
    min-width: 0;
    min-height: var(--tap-primary);
    padding-inline: var(--space-2);
  }
  .pf-summary__scan { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); }
  .pf-builder__lines { padding-bottom: 150px; }

  /* Line card: name, code and line total beside the picture; unit price and
     quantity on one row underneath. 375 px wide phones have room for both
     (the "each" word is dropped below 381 px). */
  .pf-line-card {
    grid-template-columns: 56px minmax(0, 1fr) auto 44px;
    grid-template-areas:
      "thumb main main remove"
      "thumb total total remove"
      "price price qty qty";
    column-gap: var(--space-3);
    row-gap: var(--space-2);
    padding: var(--space-3);
  }
  .pf-line-card__main { gap: 2px; }
  /* A just-added line scrolled into view stays clear of the bottom bar. */
  .pf-line-card { scroll-margin-top: 130px; scroll-margin-bottom: 160px; }
  .pf-line-card__total {
    grid-area: total;
    justify-self: start;
    align-self: start;
    text-align: left;
    min-width: 0;
    font-size: var(--font-size-md);
  }
  .pf-line-card__price, .pf-line-card__price--edit {
    grid-area: price;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-self: center;
    gap: var(--space-1) var(--space-2);
  }
  .pf-line-card__qty { grid-area: qty; justify-self: end; align-self: center; }
  .pf-line-card__remove { align-self: start; }
  .pf-qty-stepper__input { width: 60px; }
  .pf-line-card__each { display: inline; font-size: var(--font-size-sm); color: var(--color-ink-muted); }

  /* 16 px or iOS zooms the page when the field is tapped; no spin arrows. */
  .pf-price-input { width: 6rem; font-size: 16px; padding-inline: var(--space-2); -moz-appearance: textfield; appearance: textfield; }
  .pf-price-input::-webkit-inner-spin-button,
  .pf-price-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
}
@media (max-width: 380px) {
  .pf-line-card__each { display: none; }
}
/* 320 px phones (first iPhone SE): price and quantity each get their own row. */
@media (max-width: 360px) {
  /* Unit price and line total share a row; the quantity goes underneath. */
  .pf-line-card {
    grid-template-areas:
      "thumb main main remove"
      "price price total total"
      "qty qty qty qty";
  }
  .pf-line-card__total { justify-self: end; align-self: center; text-align: right; }
}

/* Camera sheet: the product card shown before anything is added. */
.pf-camera-scan.is-confirming .pf-camera-scan__video { height: min(22vh, 180px); min-height: 120px; }
.pf-camera-scan__confirm {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}
.pf-camera-scan__name { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); line-height: var(--line-height-tight); }
.pf-camera-scan__meta { margin-top: 2px; color: var(--color-ink-muted); font-size: var(--font-size-sm); }
.pf-camera-scan__qty { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-3); }
.pf-camera-scan__qty-label { font-weight: var(--font-weight-medium); }
.pf-camera-scan__qty .pf-qty-stepper__input { width: 72px; font-size: 18px; }
.pf-camera-scan__actions { display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-3); margin-top: var(--space-4); }
.pf-camera-scan__next { margin-top: var(--space-4); }

/* =========================================================
   Admin screens on a phone (Dec 2026 review): less padding and smaller
   gaps so the content gets the width. Main area and page container were
   each padding 24px a side (48px of empty space each side). Taps stay
   >= 44px.
   ========================================================= */
@media (max-width: 640px) {
  .pf-app__main:has(.pf-admin-nav, .pf-admin-grid) { padding: var(--space-3) var(--space-3) calc(var(--space-4) + var(--safe-bottom)); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) { padding-inline: 0; padding-block: 0 var(--space-5); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)).stack--loose,
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .stack--loose { gap: var(--space-4); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .stack { gap: var(--space-3); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .stack--tight { gap: var(--space-1); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .text-2xl { font-size: var(--font-size-xl); line-height: var(--line-height-tight); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .pf-page__head { gap: var(--space-2); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .pf-page__head p { font-size: var(--font-size-sm); }

  /* Section links: a slimmer swipeable row; the fade hints there are more. */
  .pf-admin-nav { gap: var(--space-1); margin-inline: calc(-1 * var(--space-3)); padding-inline: var(--space-3);
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
  .pf-admin-nav__link { min-height: 44px; padding: 0 var(--space-3); font-size: var(--font-size-sm); }

  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .pf-card { padding: var(--space-3); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .pf-card__head { min-height: 44px; padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .pf-table th,
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .pf-table td { padding: var(--space-2) var(--space-3); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .pf-admin-grid { gap: var(--space-2); }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .pf-admin-card { min-height: 0; }
  .pf-page:is(:has(> .pf-admin-nav), :has(> .pf-admin-grid)) .pf-section-title { margin-block: 0; }
}

/* Phones: regular pages (not the quote builder, not bare screens) use a 12px
   margin instead of main 24px + container 24px a side. */
@media (max-width: 640px) {
  .pf-app__main:not(.pf-app__main--fixed):not(.pf-app__main--bare) { padding: var(--space-3) var(--space-3) calc(var(--space-4) + var(--safe-bottom)); }
  .pf-app__main:not(.pf-app__main--fixed) > .container { padding-inline: 0; }

  /* Customer rows: the Customer/Lead badge moves onto the details line and
     the name may wrap, so the whole width goes to the customer's details. */
  button.pf-result-row:has(> .pf-badge) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "name name chev" "badge meta chev";
    column-gap: var(--space-2);
    row-gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
  }
  button.pf-result-row:has(> .pf-badge) > .pf-result-row__main { display: contents; }
  button.pf-result-row:has(> .pf-badge) .pf-result-row__name { grid-area: name; white-space: normal; overflow-wrap: anywhere; }
  button.pf-result-row:has(> .pf-badge) .pf-result-row__meta { grid-area: meta; align-self: center; overflow-wrap: anywhere; }
  button.pf-result-row:has(> .pf-badge) > .pf-badge { grid-area: badge; align-self: center; justify-self: start; padding: 1px var(--space-2); }
  button.pf-result-row:has(> .pf-badge) > .pf-result-row__chevron { grid-area: chev; align-self: center; }
}

/* Phones: item search results. The name may wrap and the lighting tag
   (RGB/LED/Standard) goes on its own line under the code, so the name and
   code get the width between the picture and the add button. */
@media (max-width: 640px) {
  .pf-results--popover .pf-result-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    grid-template-areas: "thumb name add" "thumb short add" "thumb meta add" "thumb tag add" "thumb note note";
    column-gap: var(--space-3);
    row-gap: 2px;
    align-items: center;
    padding: var(--space-2) var(--space-3);
  }
  .pf-results--popover .pf-result-row > .pf-thumb { grid-area: thumb; align-self: start; }
  .pf-results--popover .pf-result-row > .pf-result-row__main { display: contents; }
  .pf-results--popover .pf-result-row__name { grid-area: name; white-space: normal; overflow-wrap: anywhere; }
  .pf-results--popover .pf-result-row__short { grid-area: short; overflow-wrap: anywhere; }
  .pf-results--popover .pf-result-row__meta { grid-area: meta; overflow-wrap: anywhere; }
  .pf-results--popover .pf-result-row__note { grid-area: note; margin-top: 0; }
  .pf-results--popover .pf-result-row > .pf-variant-tag { grid-area: tag; justify-self: start; margin-top: 2px; padding-block: 1px; }
  .pf-results--popover .pf-result-row > .pf-result-row__add { grid-area: add; }
}

/* Phones: a smaller bottom bar on the quote (was ~175px of the screen), and
   it slides away while the rep scrolls down the lines (app.js). */
@media (hover: none) {
  .pf-summary__toggle:hover { background: transparent; }
}
@media (max-width: 640px) {
  .pf-cta-more { display: none; }
  .pf-builder:not(.pf-builder--readonly) .pf-summary {
    padding-top: var(--space-1);
    padding-bottom: calc(var(--space-2) + var(--safe-bottom));
    transition: transform 0.22s var(--easing-standard);
  }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__bar { row-gap: var(--space-1); }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__bar > .pf-summary__toggle { min-height: 44px; }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__toggle-total { font-size: var(--font-size-lg); }
  .pf-builder:not(.pf-builder--readonly) .pf-summary__bar > .pf-btn,
  .pf-builder:not(.pf-builder--readonly) .pf-summary__bar > a.pf-btn { min-height: var(--tap-min); white-space: nowrap; }
  .pf-builder:not(.pf-builder--readonly) .pf-summary.is-tucked:not(.is-expanded) {
    transform: translateY(calc(100% + 8px));
  }
  /* 25px under the buttons; the home-indicator area only where Safari's
     toolbar doesn't already cover it. */
  .pf-builder:not(.pf-builder--readonly) .pf-summary {
    padding-bottom: max(25px, calc(var(--safe-bottom) - var(--pf-bottom-gap, 0px)));
  }
}
/* Fixed bottom sheet sits where the app shell ends, and the list leaves room
   for the whole bar at its end (see fitBottom, app.js). */
@media (max-width: 900px), (orientation: portrait) {
  .pf-summary:not(.pf-summary--editing) { bottom: var(--pf-bottom-gap, 0px); }
  /* History and the signing panel come after the lines, so the room goes
     at the end of the whole Items area, not under the lines list. */
  .pf-builder:not(.pf-builder--readonly) .pf-builder__lines { padding-bottom: var(--space-2); }
  .pf-builder .pf-builder__main { padding-bottom: calc(var(--pf-bar-h, 120px) + var(--space-4)); }
}

/* My quotes on a phone: the status shows once (beside the number; a draft
   just says Draft), and the time sits beside the customer, not on its own
   row. */
@media (max-width: 640px) {
  .pf-table--quotes tr.pf-table__row > td.pf-col-status .pf-status-pill { display: none; }
  .pf-table--quotes tr.pf-table__row > td.pf-col-status:not(:has(.text-sm)) { display: none; }
  .pf-table--quotes tr.pf-table__row > td:nth-child(2) { grid-column: 1; grid-row: 2; }
  .pf-table--quotes tr.pf-table__row > td.pf-col-time { grid-column: 2; grid-row: 2; text-align: right; align-self: start; }
  /* The line count sat under the total (both are number columns) and printed
     over its last digit. */
  .pf-table--quotes tr.pf-table__row > td.pf-col-lines { display: none; }
}
