/* Brand tokens — from layerweaver/styles.css */
:root {
  --primary:       #A083D5;
  --primary-dim:   #c4a9e8;
  --secondary:     #EFCF20;
  --dark:          #000000;
  --light:         #FFFFFF;
  --gray:          #F5F5F5;
  --gray-dark:     #333333;
  --gray-medium:   #666666;
  --gray-border:   #E0E0E0;

  /* Dashboard-specific */
  --surface:       #FAFAFA;
  --card-bg:       #FFFFFF;
  --card-shadow:   0 2px 8px rgba(0,0,0,0.08);
  --card-radius:   12px;
  --header-h:      56px;

  /* Status colours */
  --status-unfulfilled: #F59E0B;
  --status-transit:     #3B82F6;
  --status-delivered:   #10B981;
  --status-dispute:     #EF4444;
  --status-paused:      #9CA3AF;

  --font-primary:   'Montserrat', sans-serif;
  --font-secondary: 'Open Sans', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-secondary);
  font-size: 14px;
  background: var(--surface);
  color: var(--gray-dark);
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────── */
.dash-header {
  background: var(--dark);
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 100;
}

.dash-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  background: var(--primary);
  color: #fff;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 15px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.5px;
}

.brand-label {
  color: var(--light);
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dash-time {
  color: var(--gray-medium);
  font-size: 12px;
}

/* ── Ops stats, as a horizontal strip in the title bar ───────────────── */
.header-stats {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
}

.header-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  white-space: nowrap;
}

.header-stat-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.14);
  flex-shrink: 0;
}

.header-stat-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  color: var(--light);
}

.stat-value-warn { color: #F87171 !important; }

.header-stat-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--gray-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

.header-stat-trend {
  font-size: 10px;
  font-weight: 700;
  cursor: default;
}

.header-stat-clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 6px;
  margin: -2px -6px;
  transition: background 0.15s ease;
}

.header-stat-clickable:hover,
.header-stat-clickable:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

/* Below 1100px the stats no longer fit beside the logo - they drop to
   their own swipeable row under it instead of disappearing. */
@media (max-width: 1100px) {
  .dash-header { height: auto; }
  .dash-header-inner { flex-wrap: wrap; row-gap: 0; padding-top: 8px; }
  .header-stats {
    order: 3;
    width: 100%;
    height: auto;
    overflow-x: auto;
    padding: 6px 0 10px;
    scrollbar-width: none;
  }
  .header-stats::-webkit-scrollbar { display: none; }
}

/* ── Revenue modal ────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-border);
  flex-shrink: 0;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 15px;
  color: var(--gray-dark);
}

.modal-title i { color: var(--primary); }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-medium);
  font-size: 16px;
  padding: 6px;
  border-radius: 6px;
  line-height: 1;
}

.modal-close:hover { background: var(--gray); color: var(--gray-dark); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.wallet-report-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--gray-border);
  background: var(--gray);
  font-size: 11px;
}

.btn-wallet-upload {
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 10px;
  font-size: 11px;
}

/* ── Revenue bar chart ───────────────────────────── */
.revenue-chart-week {
  margin-bottom: 20px;
}

.revenue-chart-week:last-child { margin-bottom: 0; }

.revenue-chart-week-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-medium);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.revenue-chart-week-total {
  font-weight: 700;
  color: var(--gray-dark);
  text-transform: none;
  letter-spacing: normal;
}

.revenue-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  margin-top: 56px;
}

.revenue-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
  min-width: 0;
}

.revenue-bar-track {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex: 1;
  position: relative;
}

.revenue-bar {
  width: 60%;
  min-width: 10px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  position: relative;
  cursor: default;
  transition: background 0.15s ease;
}

.revenue-bar:hover { background: #7C5FB5; }

.revenue-bar-col.is-today .revenue-bar { background: var(--secondary); }
.revenue-bar-col.is-today .revenue-bar:hover { background: #C9B319; }

.revenue-bar-label {
  font-size: 10px;
  color: var(--gray-medium);
  text-align: center;
  line-height: 1.3;
}

.revenue-bar-col.is-today .revenue-bar-label {
  color: var(--gray-dark);
  font-weight: 700;
}

.revenue-bar-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: var(--gray-dark);
  color: var(--light);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 4px;
  white-space: normal;
  width: max-content;
  max-width: 200px;
  text-align: center;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 1;
}

.revenue-bar-track:hover .revenue-bar-tooltip { opacity: 1; }

.revenue-bar-col:first-child .revenue-bar-tooltip { left: 0; transform: translateY(-6px); }
.revenue-bar-col:last-child .revenue-bar-tooltip { left: auto; right: 0; transform: translateY(-6px); }

/* ── Grid ─────────────────────────────────────────── */
.dash-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 24px 40px;
}

/* ── Top stat row ─────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
}

.stat-tile {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.stat-tile-value {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 22px;
  color: var(--primary);
  line-height: 1.1;
}

.stat-tile-label {
  font-size: 11px;
  color: var(--gray-medium);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-tile-sub {
  font-size: 11px;
  color: var(--gray-medium);
}

/* ── Main layout: Live Traffic + stats on the left, Orders on the right ── */
.main-row {
  display: grid;
  grid-template-columns: 15% 1fr;
  gap: 20px;
  align-items: start;
}

/* Live Traffic sticks below the header as the page scrolls through the
   (unbounded, naturally-tall) Orders column next to it. Sized to fit
   whatever vertical space is available in the viewport rather than its
   own content — card-body-pad scrolls internally only as a fallback if
   real data ever needs more room than that. */
.left-col {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  height: calc(100vh - var(--header-h) - 48px);
  display: flex;
  flex-direction: column;
}

.left-col .realtime-group {
  flex: 1;
  min-height: 0;
}

.left-col .card-body-pad {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.right-col {
  display: flex;
  flex-direction: column;
}

.right-col-card {
  flex: 1;
  min-height: 0;
}

@media (max-width: 1300px) {
  .main-row { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .left-col { display: none; }
}

/* ── Live GA4 realtime funnel row ─────────────────── */
.realtime-group .card-header { gap: 10px; padding: 10px 18px; flex-wrap: wrap; }

.realtime-window-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-medium);
  background: var(--gray);
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.realtime-stats-row {
  grid-template-columns: 1fr;
}

.tile-funnel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  padding: 10px 12px;
  border-top-color: var(--primary);
}

.funnel-step {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.funnel-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.funnel-bar-row .tile-icon {
  color: var(--primary);
  font-size: 12px;
  margin-bottom: 0;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.funnel-bar-track {
  flex: 1;
  position: relative;
  height: 20px;
  border-radius: 5px;
  background: var(--primary-dim);
  overflow: hidden;
  min-width: 0;
}

.funnel-bar-fill {
  position: relative;
  height: 100%;
  min-width: 5px;
  border-radius: 5px;
  background: var(--primary);
  transition: width 0.3s ease;
}

.funnel-bar-label {
  position: absolute;
  top: 50%;
  left: 6px;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--light);
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.funnel-bar-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-dark);
  min-width: 2ch;
  text-align: right;
  flex-shrink: 0;
}

.funnel-conv-pct {
  font-size: 10px;
  color: var(--gray-medium);
  padding-left: 1px;
}

.tile-products {
  justify-content: center;
  padding: 8px;
}

.podium-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.podium-row-23 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.podium-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.podium-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  object-fit: cover;
  background: var(--card-bg);
  cursor: default;
  display: block;
}

.podium-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-medium);
  text-align: center;
}

.podium-rank-1 .podium-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-dark);
}

.realtime-stats-row .stat-tile {
  background: var(--gray);
  box-shadow: none;
  border-top: 4px solid transparent;
  position: relative;
}

.realtime-stats-row .stat-tile-value {
  color: var(--gray-dark);
}

.tile-icon {
  font-size: 15px;
  margin-bottom: 2px;
}

.tile-accent-blue    { border-top-color: #2a78d6; }
.tile-accent-blue    .tile-icon { color: #2a78d6; }

.stats-row .state-msg {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .realtime-stats-row { grid-template-columns: 1fr; }
}


/* ── Cards ────────────────────────────────────────── */
.dash-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-border);
  gap: 10px;
}

.card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Card header that carries only the tab-bar (no title — the tabs themselves
   name the card) plus header-right controls; the tab-bar's own border/padding
   stands in for the header's, so both are zeroed here. */
.card-header-tabs {
  padding: 0 18px 0 0;
  border-bottom: 1px solid var(--gray-border);
}

.card-header-tabs .tab-bar {
  padding: 8px 0 0 18px;
  border-bottom: none;
  flex: 1;
}

.card-title {
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--dark);
}

.card-title i { color: var(--primary); font-size: 15px; }

.reconcile-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.reconcile-caret {
  transition: transform 0.15s ease;
  font-size: 11px !important;
}

.reconcile-collapsed .reconcile-caret {
  transform: rotate(0deg);
}

#card-reconcile:not(.reconcile-collapsed) .reconcile-caret {
  transform: rotate(90deg);
}

.reconcile-collapsed .card-body-pad,
.reconcile-collapsed .card-footer {
  display: none;
}

.reconcile-summary-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.reconcile-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--gray);
  color: var(--gray-medium);
  white-space: nowrap;
}

.reconcile-pill-review {
  background: rgba(239, 207, 32, 0.25);
  color: #8a6d00;
}

.reconcile-pill-review.is-zero {
  background: var(--gray);
  color: var(--gray-medium);
}

.card-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 7px;
  display: none;
}
.card-badge.visible { display: inline-block; }

.card-body {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  padding: 0;
}

/* ── Tabs (In Transit: Shipped / Manifested) ───────── */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 8px 18px 0;
  border-bottom: 1px solid var(--gray-border);
}

.tab-bar-sub {
  padding: 8px 18px;
  background: var(--gray);
  border-bottom: 1px solid var(--gray-border);
}

.tab-bar-sub .tab-btn {
  font-size: 11px;
}

.hidden { display: none !important; }

/* ── Header stat data-issue marker (e.g. Meta ad spend unavailable) ──
   A small red info icon next to a header stat's value, click-to-open detail
   popup — same interaction pattern as the profit-badge tooltips
   (.calc-tooltip), but anchored to a header stat instead of an order card. */
.stat-warn-icon {
  background: none;
  border: none;
  padding: 0;
  margin-left: 2px;
  color: #DC2626;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
  position: relative;
}

.stat-warn-icon:hover { color: #B91C1C; }

.stat-warn-tooltip {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--gray-dark);
  color: var(--light);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 6px;
  width: 240px;
  white-space: normal;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.stat-warn-icon.stat-warn-open .stat-warn-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.tab-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 12px;
  color: var(--gray-medium);
  padding: 8px 4px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn + .tab-btn { margin-left: 14px; }

.tab-btn:hover { color: var(--dark); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-count {
  background: var(--gray);
  color: var(--gray-medium);
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 6px;
}

.tab-btn.active .tab-count {
  background: var(--primary);
  color: #fff;
}

.card-body-pad { padding: 10px 18px; }

.card-footer {
  padding: 8px 18px;
  border-top: 1px solid var(--gray-border);
  min-height: 32px;
}

.last-updated {
  font-size: 11px;
  color: var(--gray-medium);
}

/* ── Tables ───────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.cell-sub { margin-top: 4px; }

/* Column widths — table-layout:fixed needs explicit guidance per table */
#body-pack th:nth-child(1), #body-pack td:nth-child(1) { width: 14%; }
#body-pack th:nth-child(2), #body-pack td:nth-child(2) { width: 36%; }
#body-pack th:nth-child(3), #body-pack td:nth-child(3) { width: 36%; }
#body-pack th:nth-child(4), #body-pack td:nth-child(4) { width: 14%; }

#body-transit th:nth-child(1), #body-transit td:nth-child(1) { width: 22%; }
#body-transit th:nth-child(2), #body-transit td:nth-child(2) { width: 24%; }
#body-transit th:nth-child(3), #body-transit td:nth-child(3) { width: 24%; }
#body-transit th:nth-child(4), #body-transit td:nth-child(4) { width: 30%; }

th {
  background: var(--gray);
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-medium);
  padding: 9px 14px;
  text-align: left;
  position: sticky;
  top: 0;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-border);
  vertical-align: middle;
  color: var(--gray-dark);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #F9F6FD; }

.td-mono {
  font-family: monospace;
  font-size: 12px;
}

.td-mono a,
a.td-mono {
  color: var(--dark);
  text-decoration: none;
}

.td-mono a:hover,
a.td-mono:hover {
  color: var(--primary);
  text-decoration: underline;
}

.td-muted { color: var(--gray-medium); font-size: 12px; }

/* ── Status badges ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-unfulfilled { background: #FEF3C7; color: #92400E; }
.badge-transit      { background: #DBEAFE; color: #1E40AF; }
.badge-delivered    { background: #D1FAE5; color: #065F46; }
.badge-dispute      { background: #FEE2E2; color: #991B1B; }
.badge-active       { background: #D1FAE5; color: #065F46; }
.badge-paused       { background: #F3F4F6; color: #374151; }

.badge-profit        { background: #D1FAE5; color: #065F46; }
.badge-profit-estimated { background: #FEF3C7; color: #92400E; border: 1px dashed #D97706; }
.badge-cost-missing  { background: #FEF3C7; color: #92400E; }

.badge-campaign      { background: #EDE4FA; color: #5B3E96; }

/* ── Calculation breakdown tooltip (profit / cost-missing badges) ───────
   Click-to-open, not hover-only: several variants contain a real button
   (Add real cost data), which needs to survive the mouse moving off the
   badge and onto the tooltip content — a pure-hover popup makes that
   unreliable. .calc-tooltip-open is toggled by JS on click. */
.calc-tooltip-anchor {
  position: relative;
  cursor: pointer;
}

.calc-tooltip {
  position: absolute;
  top: 100%;
  left: 0;
  transform: translateY(6px);
  background: var(--gray-dark);
  color: var(--light);
  font-size: 11px;
  font-weight: 400;
  padding: 10px 12px;
  border-radius: 6px;
  white-space: normal;
  width: 280px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.calc-tooltip-anchor.calc-tooltip-open .calc-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.calc-tooltip-warn {
  color: #FBBF24;
  font-weight: 600;
}

.calc-tooltip-warn i { margin-right: 4px; }

.calc-tooltip-fix-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--primary);
  color: var(--light);
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.calc-tooltip-fix-btn:hover { opacity: 0.9; }

.calc-tooltip-title {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--light);
}

.calc-tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  line-height: 1.5;
}

.calc-tooltip-row > span:last-child { flex-shrink: 0; }

.calc-tooltip-row .td-muted { color: #9CA3AF; }

.calc-tooltip-total {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: 4px;
  padding-top: 4px;
  font-weight: 700;
}

.calc-tooltip-note {
  margin-top: 6px;
  color: #D1D5DB;
  line-height: 1.4;
}

/* ── Pack & Ship ───────────────────────────────────── */
.ship-to-name {
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 13px;
  color: var(--dark);
}

.order-note {
  margin-top: 4px;
  font-size: 11px;
  color: #92400E;
  background: #FEF3C7;
  border-radius: 4px;
  padding: 3px 6px;
  display: inline-block;
}

.order-note i { margin-right: 3px; }

.kanban-card-order .order-note { flex-basis: 100%; }

.pack-item-list {
  margin: 0;
  padding-left: 18px;
}

.pack-item {
  font-size: 12px;
  line-height: 1.6;
}

.item-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 4px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--dark);
  background: #EDE7F9;
  border-left: 2px solid var(--primary);
  border-radius: 3px;
  padding: 3px 6px;
}

.item-custom-key {
  font-weight: 600;
  color: #6B4FA0;
}

.btn-copy-custom {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  color: #6B4FA0;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
  line-height: 1;
  border-radius: 3px;
}

.btn-copy-custom:hover { background: rgba(107, 79, 160, 0.15); }

/* ── Stock buffer suggestions (Print Queue tab) ──────────────────────── */
.stock-buffer {
  margin: 14px 14px 0;
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  background: var(--gray);
}

.stock-buffer-summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gray-dark);
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  list-style: none;
}

.stock-buffer-summary::-webkit-details-marker { display: none; }

.stock-buffer-summary i { color: var(--primary); }

.stock-buffer-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 12px 12px;
}

.stock-buffer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border-radius: 6px;
  padding: 6px 8px;
  min-width: 0;
}

.stock-buffer-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--gray);
  flex-shrink: 0;
}

.stock-buffer-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.stock-buffer-qty {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

.stock-buffer-print {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}

.stock-buffer-print:hover { opacity: 0.85; }
.stock-buffer-print:disabled { opacity: 0.5; cursor: default; }

.stock-buffer-variants {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  text-align: right;
  max-width: 55%;
}

.item-tally-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px 12px;
}

.item-tally-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  background: var(--card-bg);
  border-radius: 6px;
  padding: 6px 10px;
}

.item-tally-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-dark);
  min-width: 0;
}

.item-tally-qty {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

/* ── Print Queue item filter ──────────────────────── */
.print-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 14px 0;
  flex-wrap: wrap;
}

.print-filter-toggle-group {
  display: flex;
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.print-filter-mode-btn {
  border: none;
  background: var(--card-bg);
  color: var(--gray-medium);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}

.print-filter-mode-btn + .print-filter-mode-btn {
  border-left: 1px solid var(--gray-border);
}

.print-filter-mode-btn.active {
  background: var(--primary);
  color: #fff;
}

.print-filter-dropdown {
  position: relative;
}

.print-filter-summary {
  cursor: pointer;
  list-style: none;
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-dark);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.print-filter-summary::-webkit-details-marker { display: none; }

.print-filter-summary i { color: var(--primary); }

.print-filter-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  padding: 6px;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.print-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--gray-dark);
  border-radius: 5px;
  cursor: pointer;
}

.print-filter-option:hover {
  background: var(--gray);
}

.print-filter-clear {
  border: none;
  background: none;
  color: var(--gray-medium);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.print-filter-clear:hover {
  color: var(--gray-dark);
}

.print-item-card-dimmed {
  opacity: 0.35;
}

/* ── Print Queue swimlane board (Jira-style: order = row, item = card) ── */
.print-board {
  padding: 0 14px 14px;
}

.print-board-header {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 1;
  padding-top: 14px;
}

.kanban-col-header {
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-medium);
  padding: 8px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.print-swimlane {
  border-top: 1px solid var(--gray-border);
  padding: 14px 0;
}

.print-swimlane:first-of-type {
  border-top: none;
}

.print-swimlane-ready {
  background: #F0FDF9;
  margin: 0 -14px;
  padding-left: 14px;
  padding-right: 14px;
}

.print-swimlane-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.print-swimlane-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.kanban-card-order {
  font-size: 12px;
  font-weight: 600;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.order-progress {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-medium);
  white-space: nowrap;
}

.print-swimlane-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.print-swimlane-col {
  background: var(--gray);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 44px;
}

.print-item-card {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  padding: 8px 10px;
}

.print-col-empty {
  font-size: 11px;
  color: var(--gray-medium);
  text-align: center;
  padding: 10px 0;
}

.subtask-item {
  font-size: 12px;
  color: var(--gray-dark);
}

.subtask-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 6px;
}

.btn-kanban-toggle-sm {
  font-size: 10px;
  padding: 3px 7px;
}

.btn-kanban-toggle-sm.btn-icon-only {
  padding: 3px 6px;
}

.kanban-ready-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #D1FAE5;
  color: #065F46;
  font-size: 10px;
  font-weight: 700;
  border-radius: 12px;
  padding: 2px 8px;
}

.btn-kanban-toggle {
  border: none;
  cursor: pointer;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 11px;
  border-radius: 6px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-kanban-primary {
  background: var(--primary);
  color: #fff;
}

.btn-kanban-back {
  background: var(--gray-border);
  color: var(--gray-dark);
}

@media (max-width: 900px) {
  .print-swimlane-cols, .print-board-header { grid-template-columns: 1fr; }
}

/* ── Pack & Ship: To Pack / Manifested / Shipped / Delivered side by side ── */
.packship-cols {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 14px;
}

.packship-col {
  background: var(--gray);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.reconcile-summary { margin-bottom: 10px; font-size: 12px; }

.packship-item {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
}

.packship-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  margin-bottom: 4px;
}

.packship-item-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.order-total {
  color: var(--gray-dark);
}

.packship-empty {
  font-size: 11px;
  color: var(--gray-medium);
  text-align: center;
  padding: 20px 0;
}

.packship-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.packship-items {
  margin-top: 6px;
}

.low-review-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--gray-border);
}

.low-review-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--status-dispute);
  display: flex;
  align-items: center;
  gap: 6px;
}

.low-review-item { border-color: var(--status-dispute); }

.low-review-stars {
  color: var(--secondary);
  letter-spacing: 1px;
}

.low-review-body {
  font-style: italic;
}

.packship-items-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--gray-medium);
  user-select: none;
}

.packship-items-summary::-webkit-details-marker { display: none; }

.packship-items-summary:hover { color: var(--primary); }

.packship-items[open] .packship-items-summary { color: var(--primary); }

.packship-items .pack-item-list { margin-top: 6px; }

.review-product-select {
  width: 100%;
  margin-top: 6px;
  font-size: 11px;
  font-family: var(--font-secondary);
  padding: 4px 6px;
  border: 1px solid var(--gray-border);
  border-radius: 5px;
  background: var(--card-bg);
  color: var(--gray-dark);
}

.btn-review-action {
  border: none;
  cursor: pointer;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 11px;
  border-radius: 6px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: opacity 0.15s, background 0.15s, filter 0.15s;
}

.btn-review-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-review-action:hover:not(:disabled),
.btn-review-action:focus-visible {
  filter: brightness(0.92);
}

.btn-review-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-review-primary {
  background: #25D366; /* WhatsApp brand green */
  color: #fff;
}

.btn-review-dismiss {
  background: var(--gray-border);
  color: var(--gray-dark);
}

/* Lives above #body-worklist (in the static markup) so typing in it never
   gets wiped by a renderWorklist() re-render; only relevant to Pack & Ship. */
.review-prefix-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-border);
  font-size: 12px;
  color: var(--gray-medium);
}

.review-prefix-bar.visible { display: flex; }

.review-prefix-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-weight: 600;
}

.review-prefix-input {
  flex: 1;
  font-size: 12px;
  font-family: var(--font-secondary);
  padding: 6px 10px;
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  color: var(--gray-dark);
}

.review-prefix-input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

@media (max-width: 1200px) {
  .packship-cols { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .packship-cols { grid-template-columns: 1fr; }
}

/* ── Buttons ──────────────────────────────────────── */
.btn-primary, .btn-refresh-all, .btn-section-refresh {
  border: none;
  cursor: pointer;
  font-family: var(--font-primary);
  border-radius: 6px;
  transition: opacity 0.15s, background 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
}

.btn-refresh-all {
  background: transparent;
  color: var(--light);
  border: 1px solid #444;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-section-refresh {
  background: transparent;
  color: var(--gray-medium);
  padding: 4px 6px;
  font-size: 13px;
  border-radius: 4px;
}

.btn-section-refresh:hover { background: var(--gray); color: var(--primary); }
.btn-refresh-all:hover      { background: #1a1a1a; }

.spinning i { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Period select ────────────────────────────────── */
.period-select {
  font-family: var(--font-secondary);
  font-size: 12px;
  color: var(--gray-dark);
  background: var(--gray);
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

/* ── Error / empty states ─────────────────────────── */
.state-msg {
  padding: 40px 18px;
  text-align: center;
  color: var(--gray-medium);
  font-size: 13px;
}

.state-msg i { font-size: 28px; display: block; margin-bottom: 10px; }
.state-msg.error { color: var(--status-dispute); }
.state-msg.error i { color: var(--status-dispute); }

.state-msg-compact { padding: 20px 18px; }
.state-msg-compact i { font-size: 18px; margin-bottom: 6px; }

/* ── Skeleton ─────────────────────────────────────── */
.skeleton-loader {
  height: 200px;
  background: linear-gradient(90deg, var(--gray) 25%, #eeeeee 50%, var(--gray) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin: 16px;
  border-radius: 8px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toasts ────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--dark);
  color: #fff;
  font-family: var(--font-secondary);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-width: 320px;
}

.toast-error {
  border-left: 3px solid var(--status-dispute);
}

.toast-success {
  border-left: 3px solid var(--status-delivered);
}

/* ── Focus / hover states ──────────────────────────── */
a:focus-visible,
button:focus-visible,
.tab-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-kanban-toggle:hover,
.btn-kanban-toggle:focus-visible {
  filter: brightness(0.92);
}

/* ── Revenue trend deltas ──────────────────────────── */
.trend-up   { color: var(--status-delivered); font-weight: 600; }
.trend-down { color: var(--status-dispute);   font-weight: 600; }

/* ── Catalogue: extend-the-catalogue candidates ──────────────────────── */
.catalogue-candidates {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-border);
}

.catalogue-candidates-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-dark);
}

.catalogue-candidates-header i { color: var(--primary); }

.candidate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--gray);
  border-radius: 8px;
  padding: 8px 12px;
}

.candidate-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.candidate-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-dark);
}

.candidate-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-candidate-dismiss {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  color: var(--gray-medium);
}

.btn-candidate-dismiss:hover:not(:disabled) {
  background: var(--gray);
  color: var(--gray-dark);
}

/* ── Catalogue (browse active products + cost data) ─────────────────── */
.catalogue-sort-select {
  font-size: 12px;
  font-family: var(--font-secondary);
  padding: 5px 8px;
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--gray-dark);
}

.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 1100px) {
  .catalogue-grid { grid-template-columns: repeat(2, 1fr); }
}

.catalogue-card {
  background: var(--gray);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catalogue-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  background: var(--card-bg);
}

.catalogue-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-dark);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.catalogue-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.catalogue-rating {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-dark);
  display: flex;
  align-items: center;
  gap: 4px;
}

.catalogue-rating i { color: var(--secondary); }

.catalogue-rating-empty {
  color: var(--gray-medium);
  font-weight: 400;
}

.catalogue-units-sold {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-dark);
  display: flex;
  align-items: center;
  gap: 4px;
}

.catalogue-units-sold i { color: var(--primary); }

.catalogue-units-sold-empty {
  color: var(--gray-medium);
  font-weight: 400;
}

.catalogue-cost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-dark);
}

.catalogue-cost .btn-review-action {
  padding: 2px 8px;
  font-size: 10px;
}

.catalogue-cost-missing {
  color: #92400E;
  background: #FEF3C7;
  border-radius: 4px;
  padding: 4px 6px;
}

.cost-edit-form {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cost-data-divider {
  border: none;
  border-top: 1px solid var(--gray-border);
  margin: 12px 0;
}

.cost-edit-row label,
.cost-edit-grid label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-medium);
}

.cost-edit-row input,
.cost-edit-grid input {
  font-size: 12px;
  font-weight: 400;
  color: var(--dark);
  border: 1px solid var(--gray-border);
  border-radius: 4px;
  padding: 4px 6px;
  width: 100%;
}

.cost-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.cost-calc-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gray);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-dark);
}

.cost-calc-output { color: var(--primary); font-size: 13px; }

.cost-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.cost-edit-actions .btn-review-action {
  flex: 1;
  justify-content: center;
  padding: 4px 6px;
  font-size: 11px;
}

.btn-cost-delete { background: #FEE2E2; color: #991B1B; }

.catalogue-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.catalogue-actions .btn-review-action { flex: 1; justify-content: center; }

.btn-catalogue-view {
  background: var(--gray-border);
  color: var(--gray-dark);
  text-decoration: none;
}

.btn-catalogue-copy {
  background: var(--primary);
  color: #fff;
}

.btn-catalogue-print {
  flex: 1;
  justify-content: center;
  background: var(--primary);
  color: #fff;
}

.catalogue-print-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.print-file-missing-icon {
  color: #D97706;
  font-size: 13px;
  flex-shrink: 0;
  cursor: default;
}

.slicer-switch {
  flex-shrink: 0;
  border: 1px solid var(--gray-border);
  background: var(--card-bg);
  color: var(--gray-dark);
  font-size: 10px;
  font-weight: 600;
  border-radius: 5px;
  padding: 3px 6px;
  cursor: pointer;
}

.slicer-switch:hover { background: var(--gray-border); }

/* ── Tools tab: merge PDFs ───────────────────────── */
.merge-pdf-tool {
  max-width: 480px;
}

/* ── Print Queue: multi-file 3mf chooser ─────────── */
.print-file-choice-variant {
  font-size: 12px;
  color: var(--gray-dark);
  background: var(--gray);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
}

.print-file-choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.print-file-choice {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
}

.print-file-choice-all {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--gray-border);
}

.print-file-choice-all .btn-review-action {
  width: 100%;
  justify-content: center;
}

.merge-pdf-hint {
  font-size: 12px;
  color: var(--gray-dark);
  margin: 0 0 12px;
}

.merge-pdf-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.merge-pdf-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  background: var(--gray);
  font-size: 12px;
  cursor: grab;
}

.merge-pdf-item:active { cursor: grabbing; }

.merge-pdf-drag-handle { color: var(--gray-dark); opacity: 0.5; }

.merge-pdf-item .fa-file-pdf { color: var(--primary); }

.merge-pdf-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-pdf-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gray-dark);
  padding: 2px 4px;
  border-radius: 4px;
}

.merge-pdf-remove:hover { background: var(--gray-border); }

.merge-pdf-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.btn-merge-pdf {
  background: var(--primary);
  color: #fff;
}

.btn-merge-pdf-clear {
  background: var(--gray-border);
  color: var(--gray-dark);
}

.merge-pdf-error {
  margin-top: 10px;
  font-size: 12px;
  color: var(--status-dispute);
}


/* ── Login page ───────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--dark);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-logo { margin-bottom: 4px; }

.login-title {
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 17px;
  color: var(--dark);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-medium);
}

.login-field input {
  font-family: var(--font-secondary);
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  color: var(--gray-dark);
}

.login-field input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

.login-error {
  color: var(--status-dispute);
  font-size: 13px;
  min-height: 1em;
}

.login-error:empty { display: none; }

.login-submit {
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
}

.login-submit:disabled { opacity: 0.6; cursor: default; }

/* Logged-in user + log out, in the header */
.dash-user {
  color: var(--gray-medium);
  font-size: 12px;
}

/* Local fallback copy while the VPS is primary (STANDBY=true) */
.standby-banner {
  background: var(--secondary);
  color: var(--dark);
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 8px 16px;
}


/* ══ Phone layout (≤ 640px) ═══════════════════════════════════════════
   Same page, rearranged for one-handed use on the floor: compact header,
   worklist tabs as a fixed bottom bar, no nested scroll areas, and the
   slicer/print-file buttons hidden (phones have no print helper). */

.mobile-only { display: none; }

.phone-link { color: inherit; text-decoration: none; }

@media (max-width: 640px) {
  .mobile-only { display: revert; }

  /* ── Header: logo + icon buttons; stats strip below (see 1100px rule) ── */
  .dash-header { position: static; }
  .dash-header-inner { padding: 8px 16px 0; }
  .brand-label, .dash-time, .dash-user { display: none; }
  .dash-header-right { gap: 8px; }
  .btn-refresh-all { font-size: 0; gap: 0; padding: 8px 11px; }
  .btn-refresh-all i { font-size: 14px; }
  .header-stats { gap: 14px; }

  /* ── Page frame: room for the bottom tab bar + iPhone home indicator ── */
  .dash-grid {
    margin: 12px auto;
    padding: 0 12px calc(76px + env(safe-area-inset-bottom));
    gap: 12px;
  }
  .card-header { flex-wrap: wrap; padding: 12px 14px; }
  .card-header-right { flex-wrap: wrap; }
  .card-title { min-width: 0; }

  /* ── Reconciliation header: title, pills and Run button wrap ── */
  .reconcile-toggle { flex-wrap: wrap; text-align: left; }
  #reconcileRunNow { flex: 1; justify-content: center; min-height: 40px; }

  /* ── One page scroll, no scroll-within-scroll ── */
  .right-col-card { flex: none; overflow: visible; }
  .card-body { overflow: visible; }
  .card-body-pad { overflow: visible; }

  /* ── Worklist tabs become a fixed bottom bar ── */
  .card-header-tabs { padding: 8px 14px; justify-content: flex-end; }
  #tabs-worklist {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 0 0 env(safe-area-inset-bottom);
    background: var(--dark);
    border-top: 1px solid #222;
    border-bottom: none;
  }
  #tabs-worklist .tab-btn {
    flex-direction: column;
    gap: 3px;
    padding: 9px 2px 8px;
    margin: 0;
    border-bottom: none;
    border-top: 2px solid transparent;
    color: #9a9a9a;
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
    position: relative;
  }
  #tabs-worklist .tab-btn i { font-size: 17px; }
  #tabs-worklist .tab-btn.active { color: var(--primary-dim); border-top-color: var(--primary); }
  #tabs-worklist .tab-count { position: absolute; top: 4px; left: calc(50% + 8px); }

  /* Toasts sit above the bottom bar */
  .toast-container { left: 12px; right: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); }

  /* ── Print Queue: an order is a short list of its items, each tagged
        with its stage - no empty "—" boxes for the other two stages ── */
  .print-board { padding: 0 12px 12px; }
  .print-board-header { grid-template-columns: repeat(3, 1fr); gap: 6px; padding-top: 10px; position: static; }
  .print-board-header .kanban-col-header { font-size: 10px; padding: 6px 4px; justify-content: center; }
  .print-swimlane-header { flex-wrap: wrap; }
  .print-swimlane-cols { display: none; }
  .print-item-list { display: flex; flex-direction: column; gap: 8px; }
  .print-item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    border: 1px solid var(--gray-border);
    border-radius: 8px;
    padding: 10px 12px;
  }
  .print-item-row .subtask-item { flex: 1; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }

  /* Stage tag that is also the control: tap to pick a new stage */
  .stage-select {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    border: none;
    border-radius: 999px;
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 16px; /* under 16px, iOS zooms the page when it's tapped */
    min-height: 38px;
    padding: 6px 28px 6px 12px;
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23333' stroke-width='1.6'/%3E%3C/svg%3E");
    cursor: pointer;
  }
  .stage-select:disabled { opacity: 0.6; }
  .stage-select.stage-queued   { background-color: #FEF3C7; color: #92400E; }
  .stage-select.stage-printing { background-color: #DBEAFE; color: #1E40AF; }
  .stage-select.stage-printed  { background-color: #D1FAE5; color: #065F46; }

  /* Phones can't open a slicer - hide everything that would try to */
  .btn-start-printing, .slicer-switch, .print-file-missing-icon,
  .btn-reopen-print-files, .btn-start-printing-standalone { display: none !important; }

  /* Finger-sized status buttons */
  .subtask-actions { flex-wrap: wrap; gap: 8px; }
  .btn-kanban-toggle-sm { font-size: 13px; padding: 10px 14px; min-height: 42px; flex: 1; justify-content: center; }

  /* ── Pack & Ship: one list at a time, picked from a tab row on top ── */
  .packship-cols { padding: 12px; gap: 12px; }
  .packship-tabbed .packship-col:not(.is-active) { display: none; }
  .packship-tabbed .packship-col > .kanban-col-header { display: none; }
  .packship-subtabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 10px 12px 0;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--card-bg);
  }
  .packship-subtab {
    border: 1px solid var(--gray-border);
    background: var(--card-bg);
    color: var(--gray-medium);
    border-radius: 8px;
    padding: 8px 2px;
    min-height: 44px;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 11px;
    line-height: 1.2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
  }
  .packship-subtab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
  .packship-subtab-count { font-size: 13px; font-weight: 700; }
  .review-prefix-bar.phone-hidden { display: none; }
  .packship-item { font-size: 13px; padding: 12px; }
  .pack-contact { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0; }
  .phone-link { color: var(--status-transit); font-weight: 600; padding: 6px 0; }
  .pack-address {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 6px 0;
    padding: 8px 10px;
    background: var(--gray);
    border-radius: 6px;
    color: var(--gray-dark);
    line-height: 1.4;
    user-select: text;
  }
  .pack-address span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .packship-item-actions { flex-wrap: wrap; gap: 8px; }
  .btn-review-action { min-height: 40px; }
  .review-product-select { width: 100%; min-height: 40px; font-size: 14px; }
  .review-prefix-bar { flex-wrap: wrap; }
  .review-prefix-input { width: 100%; font-size: 16px; }

  /* ── Pop-ups go full screen ── */
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal { max-width: none; max-height: none; height: 100%; border-radius: 0; }

  /* ── Catalogue: one product per row; "extend the catalogue" rows wrap ── */
  .catalogue-grid { grid-template-columns: 1fr; }
  .catalogue-candidates-header { flex-wrap: wrap; }
  .candidate-row { flex-wrap: wrap; }
  .candidate-info { min-width: 0; flex: 1 1 100%; }
  .candidate-actions { flex: 1 1 100%; flex-wrap: wrap; }

  /* Print Queue item filter pop-up: anchor it to the full-width filter
     row rather than the Filter button (which sits mid-screen), so opening
     it can't push the page wider than the phone. */
  .print-filter { position: relative; }
  .print-filter-dropdown { position: static; }
  .print-filter-list { left: 0; right: 0; min-width: 0; }

  /* Inputs at 16px so iOS doesn't zoom the page on focus */
  input, select, textarea { font-size: 16px; }
}
