/* ===================== Store portal (direction F) =====================
   Loaded after styles.css, on /admin only. White cards on the grey ground,
   one navy accent, ink for primary actions. Tokens come from styles.css. */

body.portal { background: var(--bg); }

/* ---------- Top bar ---------- */
.portal-topbar { background: var(--surface); backdrop-filter: none; gap: 14px; justify-content: flex-start; }
.portal-topbar .topbar-actions { margin-left: auto; }
.portal-pill { background: var(--accent-soft); border-radius: 999px; color: var(--accent); flex: none; font-size: 0.75rem; font-weight: 700; padding: 4px 10px; white-space: nowrap; }
.store-switch { flex: 0 1 auto; min-width: 0; }
.store-switch select { border-radius: 999px; font-size: 0.88rem; font-weight: 600; max-width: 260px; min-height: 36px; padding: 0 30px 0 12px; }

/* ---------- Layout ---------- */
.portal .admin { gap: 16px; max-width: 1200px; padding-top: 20px; }
.portal .admin-head { align-items: flex-end; }
.portal .admin-greeting h1 { font-size: clamp(1.35rem, 3vw, 1.7rem); }
.admin-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-head-actions .secondary { min-height: 40px; }

/* Sub-nav: one scrollable row, never wraps, never widens the page. */
.portal-subnav { background: var(--surface); border: 0; border-radius: 16px; flex-wrap: nowrap; gap: 2px; overflow-x: auto; padding: 4px 6px; scrollbar-width: none; }
.portal-subnav::-webkit-scrollbar { display: none; }
.portal-subnav .tab { border-bottom-width: 2px; color: #4b5563; flex: none; min-height: 44px; padding: 0 14px; }
[data-theme="dark"] .portal-subnav .tab { color: var(--muted); }
.portal-subnav .tab.active { border-bottom-color: var(--ink); color: var(--text); }
.portal .tab-badge { background: var(--ink); color: var(--ink-contrast); }

/* ---------- Cards ---------- */
.portal .kpi, .portal .dash-card, .portal .add-card, .portal .analytics, .portal .tab-panel > .card,
.portal .stack > .card, .portal .dash-cmd { border: 0; border-radius: 22px; box-shadow: none; }
.portal .card { border: 0; }
.portal .add-card summary { padding: 16px 20px; }
.portal .add-card[open] summary { border-bottom-color: var(--border); }
.portal .dash-card { padding: 20px 22px; }
.portal .dash-card-head { margin-bottom: 10px; }
.portal .dash-cmd { background: var(--surface); }
.portal .dash-cmd-icon { background: var(--accent); color: var(--accent-contrast); }
.portal .mini-thumb { background: var(--surface-2); color: var(--muted); }

.portal .kpi-row { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.portal .kpi { gap: 6px; padding: 16px 18px; }
.portal .kpi-value { font-size: 1.7rem; }
.portal .dash-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* ---------- Needs action ---------- */
.needs-list { display: flex; flex-direction: column; }
.needs-row { align-items: center; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 12px 0; }
.needs-row:first-child { border-top: 0; }
/* An order waiting for the store's OK stands out from the queue. */
.needs-row.is-held { background: var(--warn-soft); border-radius: 14px; border-top-color: transparent; padding: 12px; }
.needs-row.is-held + .needs-row { border-top-color: transparent; }
.needs-main { display: flex; flex: 1 1 220px; flex-direction: column; line-height: 1.35; min-width: 0; }
.needs-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.needs-amt { font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.needs-actions { display: flex; gap: 8px; }
.needs-actions button { min-height: 40px; }

/* Primary actions are ink; the accent stays for AI. */
.portal .needs-actions button:not(.secondary), .portal .order-actions button:not(.secondary):not(.ghost),
.portal .fail-form button[type="submit"] { background: var(--ink); background-image: none; border-color: var(--ink); color: var(--ink-contrast); }

/* ---------- Orders ---------- */
.order-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.order-filters .chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--ink-contrast); }
.portal .order-card { border-radius: 22px; padding: 0; }
.portal .order-summary { align-items: center; display: flex; gap: 12px; padding: 16px 20px; }
.portal .order-summary-main { flex: 1; min-width: 0; }
.portal .order-summary h3 { font-size: 1.02rem; margin: 2px 0 6px; }
.order-badges { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; }
/* A plain .badge (test order, refunded) still needs a chip behind it. */
.portal .badge:not([class*="badge-"]) { background: var(--surface-2); color: var(--muted); }
.order-summary-amt { font-variant-numeric: tabular-nums; }
.portal .order-detail { border-top: 1px solid var(--border); display: grid; gap: 14px; padding: 16px 20px 20px; }
.order-detail-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.order-detail-side { display: flex; flex-direction: column; gap: 6px; }
.order-money { background: var(--surface-2); border-radius: 16px; display: grid; gap: 4px; margin-top: 6px; padding: 12px 14px; }
.pick-head { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin-bottom: 6px; }
.pick-head h4 { font-size: 0.98rem; margin: 0; }
.pick-list { display: flex; flex-direction: column; }
.pick-row { align-items: center; border-top: 1px solid var(--border); cursor: pointer; display: flex; font-weight: 500; gap: 12px; padding: 10px 0; }
.pick-row:first-child { border-top: 0; }
.pick-row input[type="checkbox"] { accent-color: var(--ink); flex: none; height: 22px; min-height: 0; width: 22px; }
.pick-qty { flex: none; font-variant-numeric: tabular-nums; font-weight: 700; min-width: 40px; }
.pick-name { display: flex; flex: 1; flex-direction: column; line-height: 1.35; min-width: 0; }
.pick-row.is-picked .pick-name strong { color: var(--muted); text-decoration: line-through; }
.fail-form { background: var(--warn-soft); border-radius: 16px; display: grid; gap: 10px; padding: 14px; }
.fail-form .field { display: grid; gap: 4px; }

/* ---------- New-order alert ---------- */
.order-alert { align-items: center; background: var(--ink); border-radius: 16px; color: var(--ink-contrast); display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 10px 10px 10px 16px; position: sticky; top: 76px; z-index: 15; }
.order-alert[hidden] { display: none; }
.order-alert-dot { animation: alertPulse 1.4s ease-in-out infinite; background: #4ade80; border-radius: 50%; flex: none; height: 10px; width: 10px; }
.order-alert-text { flex: 1 1 200px; font-weight: 600; min-width: 0; }
.order-alert button { background: var(--ink-contrast); background-image: none; color: var(--ink); min-height: 38px; }
.order-alert .order-alert-x { background: transparent; border: 0; color: var(--ink-contrast); font-size: 1.4rem; min-width: 38px; padding: 0; }
@keyframes alertPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .order-alert-dot { animation: none; } }

/* ---------- Catalog, stores, everything else in cards ---------- */
.portal .product-grid { gap: 12px; }
.portal .product-card { background: var(--surface); border: 0; border-radius: 18px; }
.portal .product-card:hover { box-shadow: none; transform: none; }
.portal .product-card:hover .product-thumb { transform: none; }
.portal .search-row { flex-wrap: wrap; }
.portal .search-row input { flex: 1 1 220px; }
.portal .analytics { padding: 16px 18px; }
.portal .stat-mini { background: var(--surface-2); border: 0; box-shadow: none; }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .portal .admin { padding: 14px 16px 64px; }
  .portal-topbar { gap: 8px; }
  .portal-pill { display: none; }
  .portal-topbar .topbar-link[href="/shop"] { display: none; }
  .store-switch { flex: 1 1 auto; }
  .store-switch select { max-width: 100%; width: 100%; }
  .admin-head-actions { width: 100%; }
  .admin-head-actions button { flex: 1; }
  .portal .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal .kpi-value { font-size: 1.35rem; }
  .needs-amt { min-width: 0; text-align: left; }
  .needs-actions { width: 100%; }
  .needs-actions button { flex: 1; }
  .order-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .portal .order-summary, .portal .order-detail { padding-left: 16px; padding-right: 16px; }
  .order-alert { top: 64px; }
  .portal .dash-cmd { align-items: flex-start; }
  .portal .dash-cmd-row { flex-direction: column; }
}

/* ---------- Print: just the picking sheet ---------- */
.print-area { display: none; }
@media print {
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing .print-area { color: #000; display: block; font: 12pt/1.4 "Figtree", system-ui, sans-serif; }
  .print-area h1 { font-size: 18pt; margin: 0 0 6pt; }
  .print-area p { margin: 0 0 4pt; }
  .print-area table { border-collapse: collapse; margin-top: 10pt; width: 100%; }
  .print-area th, .print-area td { border-bottom: 1px solid #999; padding: 6pt 4pt; text-align: left; vertical-align: top; }
  .print-area td.box { width: 18pt; }
  .print-area td.box::before { border: 1.5px solid #000; content: ""; display: inline-block; height: 12pt; width: 12pt; }
}

/* Weighed lines: a box for the actual weight from the scale. */
.pick-weight { align-items: center; display: inline-flex; flex: none; gap: 6px; margin-left: auto; }
.pick-weight input { min-height: 40px; padding: 0 10px; text-align: right; width: 84px; }
.pick-weighed { color: var(--success); flex: none; font-size: 0.85rem; font-weight: 600; margin-left: auto; }
.pick-weigh-bar { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; margin-top: 10px; }
