/* ===== Shared states and small controls (style guide, project six, part B). Tokens from tokens.css. ===== */
/* Skeleton: bars in the shape of what is coming */
.skel { display: grid; gap: 10px; padding: 12px 0; }
.skel-bar { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--hp-neutral-soft) 25%, var(--hp-surface-hover) 50%, var(--hp-neutral-soft) 75%); background-size: 200% 100%; animation: skel-shimmer 1.4s ease-in-out infinite; }
.skel-bar.tall { height: 22px; width: 40%; }
@keyframes skel-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel-bar { animation: none; } }
/* Empty, no results, error: one shape */
.state-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 28px 16px; border-radius: var(--hp-radius-sm); color: var(--hp-text-2); }
.state-card .state-icon { font-size: 28px; line-height: 1; color: var(--hp-text-3); margin-bottom: 4px; }
.state-card .state-title { font-size: 14px; font-weight: 600; color: var(--hp-text); }
.state-card .state-line { font-size: 13px; line-height: 1.45; max-width: 48ch; }
.state-card .btn-admin { margin-top: 8px; }
.state-card.error { background: var(--hp-red-soft); border: 1px solid color-mix(in srgb, var(--hp-red) 35%, transparent); }
.state-card.error .state-title { color: var(--hp-red); }
/* Toast: bottom center, one at a time. Taps pass through it to the page; only its buttons catch them.
   --hp-toast-lift is the height of a bar at the bottom of the screen (the rep app's tab bar sets it); 0 on the admin. */
.ui-toast { position: fixed; left: 50%; bottom: calc(var(--hp-toast-lift, 0px) + 20px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 16px); display: flex; align-items: center; gap: 14px; max-width: min(92vw, 480px); padding: 10px 16px; border-radius: var(--hp-radius-pill); background: var(--hp-text); color: var(--hp-bg); font-size: 13px; font-weight: 600; box-shadow: var(--hp-shadow-2); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 9999; }
.ui-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ui-toast.show .ui-toast-action, .ui-toast.show .ui-toast-close { pointer-events: auto; }
.ui-toast.error { background: var(--hp-surface); color: var(--hp-text); border: 1px solid var(--hp-red); }
.ui-toast .ui-toast-action { border: 0; background: transparent; color: var(--hp-accent-text); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
.ui-toast:not(.error) .ui-toast-action { color: var(--hp-accent); }
.ui-toast .ui-toast-close { border: 0; background: transparent; color: var(--hp-text-2); font: inherit; font-size: 20px; line-height: 1; cursor: pointer; width: 32px; height: 32px; margin: -8px -10px -8px -6px; border-radius: 50%; }
.ui-toast .ui-toast-close:hover { background: var(--hp-surface-hover); color: var(--hp-text); }
/* The question sheet: a bottom sheet on phones, a centered dialog from 701px. It asks about whatever is open, so it sits
   above every dialog and sheet of both pages (the rep app's sheets at 2000 and its history pop-up at 3500, the admin's
   split-overlay dialogs at 3000) and under the toasts (9999). A closing sheet lets clicks through while it fades. */
.ui-sheet { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: flex-end; justify-content: center; background: var(--hp-scrim); opacity: 0; transition: opacity 0.2s; }
.ui-sheet.open { opacity: 1; }
.ui-sheet:not(.open) { pointer-events: none; }
.ui-sheet:not(.armed) .ui-sheet-actions .btn-admin { cursor: default; } /* the first 350ms: taps are ignored while it fades in (ui.js) */
.ui-sheet-in { width: 100%; background: var(--hp-surface); color: var(--hp-text); border-radius: 16px 16px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateY(24px); transition: transform 0.24s ease-out; }
.ui-sheet.open .ui-sheet-in { transform: translateY(0); }
.ui-sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--hp-border-strong); margin: 0 auto 12px; }
.ui-sheet-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.ui-sheet-line { font-size: 13px; line-height: 1.45; color: var(--hp-text-2); margin-bottom: 12px; white-space: pre-line; }
.ui-sheet .field { margin: 4px 0 12px; }
.ui-sheet .field-help[hidden] { display: none; }
.ui-sheet .field input, .ui-sheet .field textarea { width: 100%; }
.ui-sheet-actions { display: flex; gap: 8px; }
.ui-sheet-actions .btn-admin:disabled { opacity: 0.45; cursor: not-allowed; }
.ui-sheet-choices { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; } /* ui.confirm({ choices }) */
.ui-sheet-choice { display: flex; gap: 8px; align-items: center; min-height: var(--hp-tap); }
.ui-sheet-actions .btn-admin { flex: 1; height: var(--hp-tap); }
@media (min-width: 701px) {
  .ui-sheet { align-items: center; padding: 20px; }
  .ui-sheet-in { max-width: 440px; border-radius: var(--hp-radius); padding: 18px 20px 20px; }
  .ui-sheet-handle { display: none; }
  .ui-sheet-actions .btn-admin { height: 40px; flex: 0 1 auto; min-width: 120px; }
  .ui-sheet-actions { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) { .ui-sheet, .ui-sheet-in, .ui-toast { transition: none; } }
/* Busy button: keeps its width, hides its text, shows a spinner */
.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.is-busy::after { content: ''; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border: 2px solid var(--hp-border-strong); border-top-color: var(--hp-on-accent); border-radius: 50%; animation: ui-spin 0.8s linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
/* Field label and help: one rule for both apps */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field-label { display: block; font-size: 12px; font-weight: 500; color: var(--hp-text-2); margin-bottom: 4px; }
.field-help { font-size: 12px; color: var(--hp-text-2); line-height: 1.4; }
.field.is-error input, .field.is-error select, .field.is-error textarea, input.is-error, select.is-error, textarea.is-error { border-color: var(--hp-red) !important; }
.field.is-error .field-help { color: var(--hp-red); }
/* ui.range: the preset buttons wrap, Custom shows two day fields */
.ui-range-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ui-range-custom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 10px; }
.ui-range-custom[hidden] { display: none; }
.ui-range-custom > .field-help { grid-column: 1 / -1; color: var(--hp-red); }
/* ===== Shared pieces (plain screens, part three) ===== */
/* One-line result: the line, then a collapsed Details toggle with the other counts */
.ui-result { display: block; font-size: inherit; line-height: 1.45; color: inherit; min-width: 0; overflow-wrap: anywhere; text-transform: none; letter-spacing: 0; }
.ui-result .ui-result-line { font-weight: 500; }
.ui-result.error .ui-result-line { color: var(--hp-red); }
.ui-result-details { margin-top: 2px; }
.ui-result-details > summary { display: inline-block; cursor: pointer; font-size: 0.95em; font-weight: 600; color: var(--hp-accent-text); list-style: none; padding: 2px 0; }
.ui-result-details > summary::-webkit-details-marker { display: none; }
.ui-result-details > summary::after { content: ' \25BE'; }
.ui-result-details[open] > summary::after { content: ' \25B4'; }
.ui-result-details ul { margin: 4px 0 0; padding-left: 18px; font-size: 0.95em; color: var(--hp-text-2); }
.ui-result-details li { margin: 1px 0; }
/* Card help that folds: first sentence, then More. The word comes from here, so the hint's own text never changes */
.hint-fold:not(.open) > .hint-fold-rest { display: none; }
.hint-fold.cut:not(.open) > .hint-fold-head::after { content: '\2026'; }
.hint-fold-more { border: 0; background: transparent; padding: 0 0 0 4px; margin: 0; font: inherit; font-weight: 600; color: var(--hp-accent-text); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; text-transform: none; letter-spacing: 0; }
.hint-fold-more::before { content: 'More'; }
.hint-fold.open > .hint-fold-more::before { content: 'Less'; }
.hint-fold-more:focus-visible { outline: 2px solid var(--hp-accent); outline-offset: 2px; border-radius: 3px; }
/* The lines behind a result toast's Details */
.ui-sheet-list { margin: 4px 0 14px; padding-left: 18px; font-size: 13px; line-height: 1.45; color: var(--hp-text-2); max-height: 50vh; overflow-y: auto; overflow-wrap: anywhere; }
.ui-sheet-list li { margin: 2px 0; }
/* The empty card inside a table cell or a short list: same shape, less air */
.state-card.compact { padding: 14px 12px; gap: 4px; }
/* A deal's lines and the sale builder's rows (public/sale-builder.js), the same on the rep app and the admin */
.deal-items { border-top: 1px solid var(--hp-border); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.deal-item-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; font-size: 13px; }
.deal-item-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.deal-item-name { font-weight: 600; overflow-wrap: anywhere; }
.deal-item-qty { font-size: 11px; color: var(--hp-text-2); }
.deal-item-side { text-align: right; flex: none; }
.deal-item-amount { font-weight: 600; }
.deal-item-delivered { font-size: 11px; color: var(--hp-green); font-weight: 600; }
.deal-item-pending { font-size: 11px; color: var(--hp-text-2); }
/* Delivered and Posted, two small chips on every sold line (Nov 2026) */
.deal-item-chips { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.deal-item-chip { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; background: var(--hp-neutral-soft); color: var(--hp-text-2); }
.deal-item-chip.done { background: var(--hp-green-soft); color: var(--hp-green); }
.deal-item-chip.wait { background: var(--hp-orange-soft); color: var(--hp-orange); }
.deal-item-chip.closed { background: var(--hp-neutral-soft); color: var(--hp-text-2); }
.deal-item-deliver, .deal-item-link { background: none; border: none; padding: 2px 0; font-size: 11px; color: var(--hp-accent); text-decoration: underline; cursor: pointer; }
.deal-items-hint { font-size: 12px; color: var(--hp-text-2); }
.deal-items-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.items-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.items-row { background: var(--hp-surface-2); border: 1px solid var(--hp-border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.items-row select, .items-row input { width: 100%; min-width: 0; }
.items-row-nums { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: end; }
.items-row-nums label { font-size: 11px; color: var(--hp-text-2); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.items-remove { background: none; border: 1px solid var(--hp-border); color: var(--hp-text-2); border-radius: 8px; width: 38px; height: 38px; cursor: pointer; }
.items-total { font-weight: 700; font-size: 16px; text-align: right; margin: 12px 0; }
.items-sheet-actions { display: flex; gap: 8px; }
