/* ==========================================================================
   TailAdmin theme layer for the EliteDuka admin.
   Loaded AFTER admin.css (index.html only). Pure CSS: no markup, JS or
   Supabase logic depends on it. To roll back, delete the <link> to this file.
   Palette, shadows and shell proportions follow TailAdmin v2; corner radius follows the POS (tokens.css).
   Icons: TailAdmin icon family (js/icons.js).
   ========================================================================== */

:root {
  /* Colours come from tokens.css (semantic --color-* tokens) via the legacy
     aliases in admin.css. Nothing colour-specific is declared here. */

  /* Radii: NOT set here. One shared radius lives in tokens.css (--radius-control = POS radius). */

  /* TailAdmin shadow-theme-xs / md */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.10), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-card: none;

  /* Shell */
  --sidebar-w: 245px;       /* SIDEBAR-COLLAPSE-1: expanded rail (collapsed = --sidebar-w-collapsed, desktop only) */
  --sidebar-w-collapsed: 66px;
  --header-h: 72px;
  --shell-gutter: 24px;
  /* Font stack: NOT set here. 'Inter', -apple-system, … is defined once in admin.css (--font). */
}

body { color: var(--color-text-secondary); }
h1, h2, h3, h4, h5, h6 { color: var(--text); }

/* ---------- Sidebar ---------- */
.sidebar { border-right: 1px solid var(--shell-sidebar-line); }
.sidebar-brand .txt b { color: var(--color-sidebar-text-strong); }
.sidebar-brand .txt small { color: var(--shell-sidebar-icon); }
.sidebar-brand { padding: 0 24px; border-bottom: 1px solid var(--shell-sidebar-line); }
.sidebar-nav { border-top: 0; padding: 4px 20px 18px; }
.nav-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; padding: 18px 12px 8px;
}
.nav-link { font-weight: 500; padding: 10px 12px; border-radius: var(--radius-control); }
.nav-link i { color: var(--shell-sidebar-icon); }
.nav-link:hover { background: var(--shell-sidebar-hover-bg); color: var(--color-sidebar-text-strong); }
.nav-link:hover i { color: var(--color-sidebar-text-strong); }
.nav-link.active { font-weight: 500; }
/* Active takes precedence over hover: the current page keeps its active look. */
.nav-link.active:hover { background: var(--shell-sidebar-active-bg); color: var(--shell-sidebar-active-text); }
.nav-link.active:hover i { color: var(--shell-sidebar-active-text); }
.nav-divider { background: var(--shell-sidebar-line); }
.sidebar-foot { border-top: 1px solid var(--shell-sidebar-line); }
.sidebar-user { background: var(--color-sidebar-user-bg); border: 1px solid var(--shell-sidebar-line); border-radius: var(--radius-control); }
.sidebar-user .av { color: var(--shell-sidebar-icon); }
.sidebar-user .av:hover, .sidebar-user .av:focus-visible { color: var(--color-sidebar-text-strong); }
.sidebar-user .who b { color: var(--color-sidebar-text-strong); }
.sidebar-user .who span { color: var(--shell-sidebar-icon); }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: var(--shell-sidebar-heading) transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--shell-sidebar-heading); }
.nav-link:focus-visible { outline: 2px solid var(--color-sidebar-text-strong); outline-offset: -2px; }
/* Active page: dark-blue text/icon on the light pill (also keeps hover from washing it out) */
.nav-link.active, .nav-link.active i { color: var(--shell-sidebar-active-text); }

/* ---------- Topbar ---------- */
.topbar { height: var(--header-h); box-shadow: none; border-bottom: 1px solid var(--line); }
.topbar-search {
  background: transparent; border: 1px solid var(--color-border); border-radius: var(--radius-control);
  height: 44px; padding: 0 14px; width: min(430px, 40vw);
}
/* hover: one step darker neutral; focus: crisp 1px brand ring (declared after hover so focus wins) */
.topbar-search:hover { border-color: var(--color-border-strong); }
.topbar-search:focus-within {
  background: var(--color-surface); border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary);
}
.topbar-search input::placeholder { color: var(--color-text-muted); }
.icon-btn { border: 1px solid var(--line); border-radius: 999px; background: var(--color-surface); color: var(--text-faint); }
.icon-btn:hover { background: var(--line-soft); color: var(--text); }
.topbar-account { border-left: 0; }
.topbar-account .av { border-radius: 999px; background: var(--line-soft); width: 42px; height: 42px; }
.topbar-account .who b { font-weight: 500; color: var(--color-text-secondary); }

/* ---------- Page header ---------- */
.page-head h1 { font-size: 22px; font-weight: 600; letter-spacing: 0; color: var(--text); }

/* ---------- Cards ---------- */
.card, .stat-card, .modal { border-color: var(--line); border-radius: var(--radius-control); box-shadow: none; }
.card-head, .card-head-dark { padding: 18px 24px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.card-head .sub, .card-head-dark .sub { font-size: 13px; color: var(--text-faint); }
.card-head-dark h3 i { color: var(--primary); }

/* ---------- KPI cards ---------- */
.stat-card { padding: 22px 24px; background: var(--color-surface); }
.stat-card .label { font-size: 14px; color: var(--text-faint); font-weight: 400; }
.stat-card .value {
  font-family: var(--font); font-size: 30px; font-weight: 600;
  letter-spacing: 0; color: var(--text);
}
.stat-card .sub { color: var(--text-faint); }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius-control); font-weight: 500; box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--color-surface); color: var(--color-text-secondary); border: 1px solid var(--input-line); }
.btn-ghost:hover { background: var(--bg); color: var(--color-text); }
.btn-danger-outline { border-color: var(--color-danger-border); background: var(--color-surface); }
.btn:disabled { box-shadow: none; }

/* ---------- Inputs ---------- */
.field input, .field select, .field textarea,
.filter-select, .search-box {
  border: 1px solid var(--input-line); border-radius: var(--radius-control); background: var(--color-surface);
}
.field input::placeholder, .field textarea::placeholder, .search-box input::placeholder { color: var(--color-text-muted); }
.field input:focus, .field select:focus, .field textarea:focus,
.filter-select:focus, .search-box:focus-within {
  outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-focus-ring);
}

/* ---------- Tables ---------- */
table.dtable th {
  background: transparent; color: var(--text-faint); font-size: 12px; font-weight: 500;
  border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
table.dtable td { color: var(--color-text-secondary); border-bottom: 1px solid var(--line-soft); }
table.dtable tbody tr:hover { background: var(--bg); }

/* ---------- Badges (TailAdmin pill) ---------- */
.badge { border-radius: var(--radius-control); padding: 3px 10px; font-size: 12px; font-weight: 500; }
.badge-muted { background: var(--line-soft); color: var(--text-muted); }

/* ---------- Segmented toggles (TailAdmin "Overview / Sales / Revenue") ---------- */
.range-toggle, .card-head-dark .range-toggle {
  background: var(--line-soft); border: 0; border-radius: var(--radius-control); padding: 3px; gap: 0; flex-wrap: nowrap;
}
.range-btn, .card-head-dark .range-btn {
  background: transparent; border: 0; border-radius: var(--radius-control); padding: 6px 12px;
  font-size: 13px; font-weight: 500; color: var(--color-text-on-tint);
}
.range-btn.active, .card-head-dark .range-btn.active {
  background: var(--color-surface); color: var(--text); box-shadow: var(--shadow-sm);
}
.tab-btn { font-weight: 500; font-size: 13px; }
.tab-btn.active { background: var(--primary-soft); color: var(--primary); }

/* ---------- Modals ---------- */
.modal-overlay { background: var(--color-overlay); }
.modal-head, .modal-foot { border-color: var(--line-soft); }
.modal-head h3 { font-size: 16px; }

/* ---------- Settings sub-nav ---------- */
.settings-nav-link { border-radius: var(--radius-control); font-weight: 500; }
.settings-nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.settings-nav-link.active:hover { background: var(--primary-soft); color: var(--primary); }
.settings-nav-link.active:hover i { color: var(--primary); }

/* ---------- Mobile bottom nav ---------- */
.mobile-bottom-nav { border-top: 1px solid var(--line); }
.bottom-nav-link { border-radius: var(--radius-control); }
.bottom-nav-link.active { background: var(--primary-soft); color: var(--primary); }

@media (max-width: 860px) {
  :root { --header-h: 64px; }
  .topbar-search { width: auto; flex: 1; }
}

/* ==========================================================================
   Dashboard page (TailAdmin layout)
   ========================================================================== */

/* Sales overview (2/3) + revenue gauge (1/3); stacks below 1024px */
.dash-split-grid {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  grid-auto-rows: minmax(340px, auto);
  align-items: stretch;
}
@media (max-width: 1024px) { .dash-split-grid { grid-template-columns: 1fr; } }

/* KPI cards: icon tile + delta pill */
.stat-card .stat-ico {
  width: 46px; height: 46px; border-radius: var(--radius-control); flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--line-soft); color: var(--color-text); font-size: 18px; margin-bottom: 4px;
}
.stat-card .stat-ico.is-warn { background: var(--warning-bg); color: var(--warning-text); }
.stat-card .delta {
  padding: 3px 8px !important; border-radius: var(--radius-control) !important; font-weight: 500 !important;
  background: var(--line-soft) !important; color: var(--text-muted) !important;
}
.stat-card .delta.delta-up   { background: var(--success-bg) !important; color: var(--success-text) !important; }
.stat-card .delta.delta-down { background: var(--danger-bg)  !important; color: var(--danger-text)  !important; }
.stat-card.is-link:hover { border-color: var(--color-primary); }

/* Segmented range toggles on the dashboard (ID rules in admin.css need ID-level overrides) */
#kpiRangeButtons, #salesRangeButtons.range-toggle {
  background: var(--line-soft); border: 0; border-radius: var(--radius-control); padding: 3px; gap: 0;
}
#kpiRangeButtons .range-btn, #salesRangeButtons .range-btn {
  background: transparent; border: 0; border-radius: var(--radius-control); font-weight: 500; color: var(--color-text-on-tint);
}
#kpiRangeButtons .range-btn.active, #salesRangeButtons .range-btn.active {
  background: var(--color-surface); color: var(--text); box-shadow: var(--shadow-sm);
}

/* Inventory tabs + recent-orders table */
#invTabStrip .tab-btn, #invHistoryTabStrip .tab-btn { border: 1px solid transparent; font-weight: 500; }
#invTabStrip .tab-btn.active, #invHistoryTabStrip .tab-btn.active {
  background: var(--primary-soft); color: var(--primary); border-color: transparent;
}
#recentOrdersTable thead th, #invHistoryTable thead th { background: transparent; }
#recentOrdersTable tbody tr:hover, #invHistoryTable tbody tr:hover { background: var(--bg); }
#invMonitorList .rank-row:hover, #popularList .rank-row:hover, #activityList .rank-row:hover { background: var(--bg); }
#view-dashboard .card-head-dark h3 i { border-radius: var(--radius-control); }

/* Revenue-vs-previous-period gauge */

/* ==========================================================================
   Dashboard (TailAdmin layout) — #view-dashboard only. Uses the existing
   EliteDuka tokens (--primary, --line, --radius-*, --text*). Desktop:
   KPI 2×2 + Monthly Sales on the left, Monthly Target on the right.
   ========================================================================== */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px; align-items: start; }
.dash-grid > * { min-width: 0; }
/* Metrics card: ONE white, bordered card holding the four KPI cells. 2 columns on phones
   (2x2), 4 across from 768px. Cells are separated by hairline dividers (see .dash-kpi). */
.dash-kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: #fff; border: 1px solid #E2E8F0; border-radius: var(--radius-control); box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05); overflow: hidden; }
@media (min-width: 768px) { .dash-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
#view-dashboard .dash-grid > .dash-sales-card, #view-dashboard .dash-grid > .dash-demo-card { display: none; }   /* secondary charts: Revenue + Monthly target already cover sales; detail lives in Analytics */
.dash-orders-card { grid-column: 1 / -1; }
.dash-inv-card { grid-column: 1 / -1; }
.dash-grid > .card { margin: 0; }

.dash-card { border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--color-surface); padding: 20px 24px 24px; display: flex; flex-direction: column; box-shadow: none; }
.dash-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.dash-card-head h3 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text); line-height: 1.3; }
.dash-card-head .sub { font-size: 14px; color: var(--text-faint); margin-top: 4px; }
.dash-card-head-wrap { flex-wrap: wrap; row-gap: 12px; }
.dash-head-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* KPI tab bar (Shopify-style): four equal cells in the one card above. No accent bar, no fills:
   every cell has identical text colours whether selected or not. Selection = a barely-there tint
   (same as hover) + aria-selected. Dividers are hairlines: phone 2x2 = a cross; 768px+ = vertical only. */
.dash-kpi { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 76px; min-width: 0; padding: 12px 16px; background: transparent; border: 0; border-radius: 0; box-shadow: none; cursor: pointer; transition: background-color .15s ease; } /* min-h-[76px] flex flex-col justify-between px-4 py-3 */
.dash-kpi:nth-child(even) { border-left: 1px solid #F1F5F9; }
.dash-kpi:nth-child(n+3) { border-top: 1px solid #F1F5F9; }
@media (min-width: 768px) {
  .dash-kpi:nth-child(n+3) { border-top: 0; }
  .dash-kpi:nth-child(n+2) { border-left: 1px solid #F1F5F9; }
}
.dash-kpi:hover, .dash-kpi.is-active { background: var(--color-bg); }
.dash-kpi:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
/* Hierarchy: label (12/500, dashed underline) -> value (20, 24 from 640px; bold) -> trend + timeframe on ONE line (12).
   Label, value and timeframe truncate with an ellipsis instead of wrapping or spilling. */
.dash-kpi-label { display: block; max-width: 100%; font-size: 12px; font-weight: 500; line-height: 16px; color: #64748B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* text-xs font-medium text-slate-500 */
.dash-kpi-val { min-width: 0; margin: 0; font-size: 18px; font-weight: 700; color: #0F172A; line-height: 24px; letter-spacing: -.025em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* text-lg font-bold text-slate-900 tracking-tight tabular-nums */
@media (min-width: 640px) { .dash-kpi-val { font-size: 20px; } } /* sm:text-xl */
/* KSh prefix: text-xs font-medium text-slate-500 mr-1 */
.dash-kpi-val .cur { font-size: 12px; font-weight: 500; line-height: 1; color: #64748B; letter-spacing: 0; margin-right: 4px; }
.dash-kpi-cmp { display: flex; align-items: center; min-width: 0; min-height: 18px; margin-top: 4px; white-space: nowrap; } /* mt-1 min-h-[18px] flex items-center */
.dash-kpi-spacer { display: block; height: 18px; } /* h-[18px] invisible spacer when a card has no trend */
/* Trend: plain text, no pill. ↗ emerald-600 / ↘ rose-600; font-medium text-xs flex items-center gap-0.5 */
.dash-pill { flex: none; display: inline-flex; align-items: center; gap: 2px; padding: 0; background: none; border-radius: 0; font-size: 12px; font-weight: 500; line-height: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dash-pill.is-up   { color: #059669; }
.dash-pill.is-down { color: #E11D48; }

/* Kebab menu */
.dash-kebab { position: relative; flex-shrink: 0; }
.dash-kebab-btn { width: 32px; height: 32px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text-faint); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.dash-kebab-btn:hover, .dash-kebab.open .dash-kebab-btn { background: var(--line-soft); color: var(--text-muted); }
.dash-kebab-menu, .dash-range-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 150px; padding: 6px; background: var(--color-surface); border: 1px solid var(--line); border-radius: var(--radius-control); box-shadow: var(--shadow-md); }
.dash-kebab.open .dash-kebab-menu, .dash-range.open .dash-range-menu { display: block; }
.dash-kebab-menu a, .dash-kebab-menu button, .dash-range-menu button { display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text-muted); font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.dash-kebab-menu a:hover, .dash-kebab-menu button:hover, .dash-range-menu button:hover { background: var(--line-soft); color: var(--text); }
.dash-range-menu button[aria-selected="true"] { color: var(--primary); background: var(--primary-soft); }

/* Segmented tabs + range selector */
.dash-seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--line-soft); border-radius: var(--radius-control); max-width: 100%; }
.dash-seg button { border: 0; background: transparent; color: var(--color-text-on-tint); font: inherit; font-size: 14px; font-weight: 500; padding: 7px 14px; border-radius: var(--radius-control); cursor: pointer; white-space: nowrap; }
.dash-seg button:hover { color: var(--text); }
.dash-seg button.active { background: var(--color-surface); color: var(--text); box-shadow: var(--shadow-sm); }
.dash-inv-card .tab-strip { padding: 3px; border: 0; margin: 0; background: var(--line-soft); }
.dash-range { position: relative; }
.dash-range-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--color-surface); color: var(--text-muted); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow-sm); white-space: nowrap; }
.dash-range-btn:hover { background: var(--bg); }

/* Charts */
.dash-chart { width: 100%; position: relative; }
.dash-chart-sm { height: 220px; }
.dash-chart-lg { height: 320px; }
.dash-empty { height: 100%; min-height: 120px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 14px; font-weight: 600; color: var(--text); padding: 12px; }

/* Monthly Target — card shell/header row come from .dash-pair below. .dash-target-main fills the card
   under the header: the gauge block is vertically centred in the free space and the Target / Revenue /
   Today numbers sit on the bottom padding line. */
.dash-target-main { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: space-between; min-height: 0; padding: 0 20px 20px; }

/* Revenue chart + Monthly Target: one equal-height row. Stacked (1 col) below 1024px; 2/3 + 1/3 from 1024px.
   Both cards stretch to the row height; the chart box takes whatever the card has left (min 260px). */
.dash-pair { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: stretch; }
@media (min-width: 1024px) {
  .dash-pair { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-pair > .dash-stats-card { grid-column: span 2; }
}
.dash-pair > .dash-card { margin: 0; height: 100%; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 0; }
/* Header: identical on both cards — 16/600 title, subtitle 4px under it, right-hand control in a 40px box 4px down */
.dash-pair .dash-card-head h3 { font-size: 16px; font-weight: 600; line-height: 24px; color: var(--color-text); }
/* Header row (both cards): flex items-center justify-between px-5 py-3 border-b border-slate-100.
   Both hold one 40px control, so both rows are exactly 64px tall and the titles share one baseline. */
.dash-pair .dash-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 12px; margin: 0; padding: 12px 20px; border-bottom: 1px solid #F1F5F9; }
/* Monthly Target title: text-sm font-semibold text-slate-900 */
.dash-pair .dash-target-card .dash-card-head h3 { font-size: 14px; font-weight: 600; line-height: 24px; color: #0F172A; position: relative; top: .7px; } /* 14px title; .7px nudge = the baseline difference vs the 16px Revenue title when both are centred in the same 40px row */
.dash-pair .dash-head-tools, .dash-pair .dash-kebab { margin-top: 0; }
.dash-pair .dash-kebab { display: flex; align-items: center; height: 40px; }
/* 3-dots button is the same 40px box as the range dropdown (same top edge, same 4px offset), icon centred in it */
.dash-pair .dash-kebab-btn { width: 40px; height: 40px; }
/* Chart canvas sits BELOW the header row: 16px clearance above it (margin, not padding, so ECharts measures the true canvas size), width:auto so the side margins don't push it past the card edge,
   clipped + isolated so axis labels can never paint over the header; the header is stacked above it. */
.dash-pair .dash-chart-lg { flex: 1 1 0; width: auto; height: auto; min-height: 260px; overflow: hidden; isolation: isolate; margin: 16px 20px 20px; }
.dash-pair .dash-card-head { position: relative; z-index: 2; background: var(--color-surface); }

/* Customers Demographic */
.dash-map { border-radius: var(--radius-control); background: var(--line-soft); border: 1px solid var(--line); overflow: hidden; aspect-ratio: 180 / 97; width: 100%; }
.dash-map svg { display: block; width: 100%; height: 100%; }
.dash-locs { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.dash-locs-empty { margin: 36px 0 12px; text-align: center; font-size: 14px; color: var(--text-faint); }
.dash-loc { display: flex; align-items: center; gap: 12px; }
.dash-loc-ico { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dash-loc-name { flex: 1 1 auto; min-width: 0; }
.dash-loc-name b { display: block; font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-loc-name span { font-size: 12px; color: var(--text-faint); }
.dash-loc-bar { flex: 0 0 38%; max-width: 130px; height: 8px; border-radius: var(--radius-control); background: var(--line); overflow: hidden; }
.dash-loc-bar i { display: block; height: 100%; background: var(--primary); border-radius: var(--radius-control); }
.dash-loc-pct { width: 38px; text-align: right; font-size: 14px; font-weight: 500; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Tables */
.dash-table-wrap { overflow-x: auto; }
table.dash-table { min-width: 520px; }
table.dash-table th { background: var(--bg); font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-faint); padding: 10px 12px; }
table.dash-table td { padding: 12px; }
.dash-orders-card table.dash-table { min-width: 500px; }
.dash-ord { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.dash-ord .row-thumb { width: 50px; height: 50px; border-radius: var(--radius-control); }
.dash-ord span { min-width: 0; display: block; }
.dash-ord b { display: block; font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.dash-ord small { display: block; font-size: 12px; color: var(--text-faint); margin-top: 2px; white-space: nowrap; }
.dash-sku { color: var(--text-faint); }
.dash-inv-empty { padding: 28px 12px; text-align: center; color: var(--text-faint); font-size: 14px; }
.dash-inv-card .row-thumb { width: 50px; height: 50px; border-radius: var(--radius-control); }
.dash-inv-card .row-title .name { font-weight: 600; }

@media (max-width: 1279px) {
  .dash-demo-card { grid-column: 1 / -1; height: auto; }
  .dash-orders-card { grid-column: 1 / -1; }
}
@media (max-width: 1023px) {
  .dash-grid { gap: 16px; }
  .dash-kpis, .dash-pair, .dash-sales-card, .dash-demo-card, .dash-orders-card, .dash-inv-card { grid-column: 1 / -1; grid-row: auto; }
}
@media (max-width: 640px) {
  .dash-card { padding: 18px 16px 20px; }
  .dash-chart-lg { height: 280px; }
  .dash-seg button { padding: 7px 10px; font-size: 13.5px; }
  .dash-loc-bar { flex-basis: 30%; }
}
.dash-total { font-weight: 500; color: var(--text-muted); white-space: nowrap; }

/* ==========================================================================
   MOBILE SHELL (Shopify / Stripe mobile pattern)
   - Lucide nav glyphs use a 2px stroke
   - <=640px  : minimal 48px top bar (store switcher left; bell + avatar right), no breadcrumb/search
   - <=860px  : 56px fixed bottom bar with 4 core tabs (Dashboard, Orders, POS, Products)
   Everything else (customers, settings, ...) stays reachable from the store switcher, which opens the side drawer.
   ========================================================================== */
/* Icons: Lucide, 2px stroke on every glyph (the .ts group gets fill:none / stroke:currentColor from icons.js, so colour always follows the text colour) */

.topbar-store { display: none; }

@media (max-width: 860px) {
  .mobile-bottom-nav {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center;
    height: calc(56px + env(safe-area-inset-bottom, 0px)); padding: 0 0 env(safe-area-inset-bottom, 0px);
    background: #fff; border-top: 1px solid #E2E8F0; box-shadow: none; z-index: 50;
  }
  .bottom-nav-link {
    height: 56px; padding: 0; gap: 0; min-width: 0; border-radius: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: none; color: #94A3B8; text-decoration: none; -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-link:hover { background: none; color: #475569; }
  .bottom-nav-link:active { background: none; }
  .bottom-nav-link i.ai { display: flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1; }
  .bottom-nav-link span { display: block; margin-top: 2px; font-size: 10px; font-weight: 500; letter-spacing: -.025em; line-height: 12px; }
  .bottom-nav-link.active { background: none; color: #168A4E; }
  .bottom-nav-link.active span { font-weight: 600; }
  /* POS: icon in a blue circle (p-2 rounded-full shadow-sm), highlighted whether or not it is the active tab */
  .bottom-nav-pos i.ai { width: 36px; height: 36px; font-size: 20px; border-radius: 50%; background: #168A4E; color: #fff; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05); transform: none; }
  .bottom-nav-pos:hover i.ai, .bottom-nav-pos:active i.ai { background: #168A4E; transform: none; }
  .bottom-nav-pos.active i.ai { background: #168A4E; }
  .bottom-nav-pos:hover { color: #475569; }
  .bottom-nav-pos.active:hover { color: #168A4E; }
  .bottom-nav-pos i.ai, .bottom-nav-pos:hover i.ai, .bottom-nav-pos.active i.ai { color: #fff; }   /* POS glyph always white on its blue circle */
  /* room for the 56px bar */
  .content { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .view#view-pos { height: calc(100vh - var(--header-h) - 56px - env(safe-area-inset-bottom, 0px)); }
  @supports (height: 100dvh) {
    .view#view-pos { height: calc(100dvh - var(--header-h) - 56px - env(safe-area-inset-bottom, 0px)); }
  }
}

@media (max-width: 640px) {
  :root { --header-h: 48px; }
  /* h-12 flex items-center justify-between px-4 border-b border-slate-100 bg-white */
  .topbar { height: 48px; padding: 0 16px; gap: 8px; background: #fff; border-bottom: 1px solid #F1F5F9; box-shadow: none; }
  .topbar-left { gap: 0; }
  .menu-toggle, .topbar-search { display: none; }
  .page-crumb { display: none; }                         /* hide "Admin > Dashboard" */
  .topbar-right { gap: 4px; }
  #refreshBtn, #viewStorefrontLink, #topbarSettingsLink { display: none; }
  .topbar-account { padding-left: 0; margin-left: 0; border-left: 0; gap: 0; }
  .topbar-account .who { display: none; }
  .topbar-account .av { width: 32px; height: 32px; border-radius: 50%; background: var(--bg); font-size: 18px; color: #64748B; }
  .topbar-account .av:hover, .topbar-account .av:focus-visible { background: #F1F5F9; color: #334155; }
  .topbar-right .icon-btn { width: 36px; height: 36px; background: transparent; color: #64748B; }                 /* text-slate-500 */
  .topbar-right .icon-btn:hover, .topbar-right .icon-btn:focus-visible { background: #F1F5F9; color: #334155; }   /* hover:text-slate-700 */
  .topbar-store {
    display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; height: 36px; padding: 0 8px 0 0;
    background: none; border: 0; cursor: pointer; color: #0F172A; font: inherit;
  }
  .topbar-store .mark { flex: none; width: 24px; height: 24px; border-radius: 6px; overflow: hidden; display: inline-flex; }
  .topbar-store .mark img { width: 100%; height: 100%; object-fit: contain; }
  .topbar-store b { min-width: 0; font-size: 14px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-store i.ai { flex: none; font-size: 16px; color: #94A3B8; }
}

/* ---- Analytics page: reuses the Dashboard's .dash-* blocks; only the grid shapes differ ---- */
.dash-pair.an-single { grid-template-columns: minmax(0, 1fr); }
.dash-pair.an-single > .dash-card { grid-column: 1 / -1; }
@media (min-width: 1024px) { .dash-pair.an-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dash-pair .an-chart-pad { margin: 0 20px 20px; width: auto; }
.dash-pair .dash-table-wrap { margin: 0 0 4px; }

.dash-badge { display: inline-flex; align-items: center; height: 18px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap; font-variant-numeric: tabular-nums; background: var(--line-soft); color: var(--text-muted); }
.dash-badge.is-success { background: var(--success-bg); color: var(--success-text); }
.dash-badge.is-warning { background: var(--warning-bg); color: var(--warning-text); }
.dash-badge.is-muted   { background: var(--line-soft); color: var(--text-muted); }

/* Analytics page-level range toolbar (one control for the whole page) */
.an-toolbar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 12px; }
.an-custom-row { display: none; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.an-refresh { display: inline-flex; align-items: center; gap: 6px; }


/* ---------- Analytics: Store performance (storefront analytics KPIs) ----------
   Reuses .dash-kpis / .dash-kpi / .dash-pill; the cells are informational (not chart tabs), so they are not clickable. */
.an-sec-head { grid-column: 1 / -1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 -8px; }
.an-sec-head h3 { margin: 0; font-size: 16px; font-weight: 600; line-height: 24px; color: var(--color-text); }
.an-sec-head .sub { font-size: 13px; color: var(--text-faint); }
.an-sec-head-2 { margin-top: 12px; }
.an-perf-notice { grid-column: 1 / -1; }
.an-perf-notice:empty { display: none; }
.an-perf-notice .alert-banner { margin-bottom: 0; }
.dash-kpi.is-static { cursor: default; }
.dash-kpi.is-static:hover { background: transparent; }
.an-funnel-foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 20px 20px; padding-top: 14px; border-top: 1px solid #F1F5F9; }
.an-funnel-foot:empty { display: none; }
.an-funnel-foot > div { display: flex; flex-direction: column; min-width: 0; }
.an-funnel-foot b { font-size: 16px; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }
.an-funnel-foot span { font-size: 12px; color: var(--text-faint); }
.dash-pair.an-pair > .dash-card { justify-content: flex-start; }


/* ---------- Analytics visual QA ---------- */
/* Segmented date range: one joined control, existing tokens only */
.range-toggle.is-segmented { display: inline-flex; flex-wrap: nowrap; gap: 0; padding: 0; max-width: 100%; overflow-x: auto; background: var(--color-surface); border: 1px solid var(--line); border-radius: var(--radius-control); scrollbar-width: none; }
.range-toggle.is-segmented::-webkit-scrollbar { display: none; }
.range-toggle.is-segmented .range-btn { flex: 0 0 auto; white-space: nowrap; border: 0; border-radius: 0; background: transparent; color: var(--text-muted); box-shadow: none; }
.range-toggle.is-segmented .range-btn + .range-btn { border-left: 1px solid var(--line); }
.range-toggle.is-segmented .range-btn:hover { background: var(--bg); color: var(--text); }
.range-toggle.is-segmented .range-btn.active { background: var(--primary); color: #fff; }
.range-toggle.is-segmented .range-btn:first-child { border-radius: calc(var(--radius-control) - 1px) 0 0 calc(var(--radius-control) - 1px); }
.range-toggle.is-segmented .range-btn:last-child { border-radius: 0 calc(var(--radius-control) - 1px) calc(var(--radius-control) - 1px) 0; }

/* (i) methodology trigger + popover */
.an-sec-head { position: relative; align-items: center; }
.an-info { position: relative; display: inline-flex; align-items: center; }
.an-info-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-faint); cursor: pointer; }
.an-info-btn:hover, .an-info-btn[aria-expanded="true"] { background: var(--line-soft); color: var(--text); }
.an-info-pop { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 320px; max-width: calc(100vw - 32px); padding: 12px 14px; background: var(--color-surface); border: 1px solid var(--line); border-radius: var(--radius-control); box-shadow: var(--shadow-md); font-size: 13px; line-height: 19px; color: var(--text-muted); font-weight: 400; }
.an-info-pop[hidden] { display: none; }
.an-info-pop p { margin: 6px 0 0; }
.an-info-title { font-weight: 600; color: var(--text); }
@media (max-width: 480px) { .an-info { position: static; } .an-sec-head { position: relative; } .an-info-pop { left: 0; right: 0; width: auto; max-width: none; } }

/* Compact tracking note (replaces the large banner / footer) */
.an-note { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 18px; color: var(--text-muted); }
.an-note .ai { flex: 0 0 auto; margin-top: 1px; color: var(--text-faint); }
.an-note b { font-weight: 600; color: var(--text); }

/* Chart metric selector */
.an-metric { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--text-faint); }
.an-metric select { min-width: 150px; }

/* Tables: numeric columns right-aligned, roomier cells, contained horizontal scroll */
table.dash-table th.num, table.dash-table td.num { text-align: right; white-space: nowrap; }
table.dash-table th, table.dash-table td { padding-left: 16px; padding-right: 16px; }
table.dash-table th:first-child, table.dash-table td:first-child { padding-left: 20px; }
table.dash-table th:last-child, table.dash-table td:last-child { padding-right: 20px; }
#biProductTable, #biCategoryTable { min-width: 680px; }
.dash-table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
@media (max-width: 480px) {
  .range-toggle.is-segmented .range-btn { padding-left: 9px; padding-right: 9px; }
}
@media (max-width: 360px) {
  .range-toggle.is-segmented .range-btn { padding-left: 6px; padding-right: 6px; font-size: 11.5px; }
}

/* Customer journey steps + New vs returning footer. The transition lines sit under the funnel chart and stay quieter than it:
   small type, hairline dividers, plain text (no pills, no warning colours). Each row is the step pair on the left and one short
   line on the right; on phones the line drops under the pair so every row has the same shape. */
.an-steps { margin: 4px 20px 4px; border-top: 1px solid #F1F5F9; }
.an-step { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; padding: 11px 0; border-bottom: 1px solid #F1F5F9; font-size: 12.5px; line-height: 18px; }
.an-step:last-child { border-bottom: 0; }
.an-step-path { min-width: 0; color: var(--text-faint); }
.an-step-path span { margin: 0 3px; }
.an-step-metrics { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; color: var(--text-faint); font-variant-numeric: tabular-nums; min-width: 0; }
.an-step-metrics b { font-weight: 600; color: var(--text); }
.an-step-sep { color: #CBD5E1; }
@media (max-width: 480px) {
  .an-steps { margin-left: 16px; margin-right: 16px; }
  .an-step { flex-direction: column; align-items: flex-start; gap: 3px; padding: 10px 0; }
}
.an-steps + .an-funnel-foot { margin-top: 14px; }
.an-seg-foot { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.an-seg-chart { min-height: 120px; }
.an-info-pop { max-height: 70vh; overflow-y: auto; }
.an-seg-chart.dash-chart-sm { height: 140px; }

/* Analytics: New vs returning segment table (sessions / orders / conversion). Compact 4-column table, so it does not need
   the 520px minimum the wider source tables use. On phones the "visitors" suffix is dropped (the card subtitle already says
   these are visitors) and the delta pill is allowed to wrap onto its own line, so the table fits down to 320px without scrolling;
   the wrapper still scrolls if a card is ever narrower than that. */
table.dash-table.an-seg-table { min-width: 0; width: 100%; }
.an-seg-table-wrap { margin: 4px 0 14px; }
.an-seg-table th, table.dash-table.an-seg-table th.num { white-space: normal; line-height: 16px; vertical-align: bottom; }
.an-seg-table td:first-child { white-space: nowrap; color: var(--color-text); font-weight: 500; }
.an-seg-table td.num { font-variant-numeric: tabular-nums; }
table.dash-table.an-seg-table td.an-seg-rate { white-space: normal; }
.an-seg-table td.an-seg-rate .dash-pill { margin-left: 4px; }
@media (max-width: 480px) {
  table.dash-table.an-seg-table th { font-size: 11px; }
  table.dash-table.an-seg-table th, table.dash-table.an-seg-table td { padding-left: 8px; padding-right: 8px; }
  table.dash-table.an-seg-table th:first-child, table.dash-table.an-seg-table td:first-child { padding-left: 14px; }
  table.dash-table.an-seg-table th:last-child, table.dash-table.an-seg-table td:last-child { padding-right: 14px; }
  .an-seg-table .an-seg-sfx { display: none; }
}
@media (max-width: 360px) {
  table.dash-table.an-seg-table th, table.dash-table.an-seg-table td { padding-left: 5px; padding-right: 5px; }
  table.dash-table.an-seg-table th:first-child, table.dash-table.an-seg-table td:first-child { padding-left: 12px; }
  table.dash-table.an-seg-table th:last-child, table.dash-table.an-seg-table td:last-child { padding-right: 12px; }
}

/* ==========================================================================
   MOBILE-NAV-1 (<=860px) — brand-blue header, white-circle logo, 5-tab bottom
   bar (Dashboard · Orders · POS · Products · More) + "More" bottom sheet.
   The hamburger drawer is retired on phones/tablets; desktop keeps the white
   sidebar untouched. Admin always uses EliteDuka royal blue (--color-primary), never
   a merchant's storefront colour.
   ========================================================================== */
.more-sheet, .more-sheet-backdrop { display: none; }
@media (max-width: 860px) {
  :root { --header-h: 56px; }

  /* Header */
  .topbar { height: 56px; padding: 0 14px; gap: 8px; background: var(--color-primary); border-bottom: 0; box-shadow: none; }
  .topbar-left { gap: 0; }
  .menu-toggle { display: none !important; }
  .topbar-store {
    display: inline-flex; align-items: center; gap: 10px; max-width: 100%; min-width: 0; height: 44px; padding: 0 8px 0 0;
    background: none; border: 0; cursor: pointer; color: var(--color-on-primary); font: inherit; -webkit-tap-highlight-color: transparent;
  }
  .topbar-store .mark {
    flex: none; width: 36px; height: 36px; border-radius: 50%; background: #fff; padding: 5px; box-sizing: border-box;
    display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  }
  .topbar-store .mark img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
  .topbar-store .mark.is-initial { padding: 0; color: var(--color-primary); font-size: 16px; font-weight: 700; line-height: 1; }
  .topbar-store b { min-width: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--color-on-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-store i.ai { flex: none; font-size: 16px; color: rgba(255, 255, 255, .75); }
  .topbar-right { gap: 4px; }
  .topbar-right .icon-btn { width: 40px; height: 40px; border: 0; background: transparent; color: var(--color-on-primary); }
  .topbar-right .icon-btn:hover, .topbar-right .icon-btn:focus-visible { background: rgba(255, 255, 255, .16); color: var(--color-on-primary); }
  .topbar .icon-btn .notif-dot { top: 8px; right: 8px; border-color: var(--color-primary); }
  .topbar-account { padding-left: 0; margin-left: 0; border-left: 0; gap: 0; }
  .topbar-account .who { display: none; }
  .topbar-account .av { width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, .18); color: var(--color-on-primary); font-size: 18px; }
  .topbar-account .av:hover, .topbar-account .av:focus-visible { background: rgba(255, 255, 255, .28); color: var(--color-on-primary); }
  .topbar-account .av:focus-visible, .topbar-store:focus-visible, .topbar-right .icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

  /* The drawer is unreachable now — keep its links out of the tab order */
  .sidebar:not(.open) { visibility: hidden; }

  /* Bottom bar: 5 columns (the 5th, "More", is a <button>) */
  .mobile-bottom-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  button.bottom-nav-link { border: 0; font-family: inherit; cursor: pointer; }
  .bottom-nav-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }

  /* More sheet */
  .more-sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 59; background: var(--color-overlay); opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility 0s linear .2s; }
  .more-sheet-backdrop.show { opacity: 1; visibility: visible; transition-delay: 0s; }
  .more-sheet {
    display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-height: 82vh;
    background: var(--color-surface); border-radius: var(--radius-control) var(--radius-control) 0 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, .16); padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(100%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s;
  }
  @supports (height: 100dvh) { .more-sheet { max-height: 82dvh; } }
  .more-sheet.open { transform: none; visibility: visible; transition-delay: 0s; }
  .more-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 20px; flex: none; }
  .more-sheet-head b { font-size: 16px; font-weight: 600; color: var(--color-text); }
  .more-sheet-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--color-surface-muted); color: var(--color-text-secondary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
  .more-sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 18px; }
  .more-group + .more-group { margin-top: 6px; }
  .more-group-label { padding: 12px 4px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--color-text-muted); }
  .more-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 4px; }
  .more-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 2px; border: 0; background: none; font: inherit; cursor: pointer; min-width: 0; -webkit-tap-highlight-color: transparent; }
  .more-tile-ic { width: 46px; height: 46px; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
  .more-tile-ic i.ai { display: flex; align-items: center; justify-content: center; font-size: 20px; color: inherit; }
  .more-tile-tx { max-width: 100%; font-size: 11.5px; line-height: 1.25; text-align: center; color: var(--color-text-secondary); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .more-tile:active .more-tile-ic { background: var(--color-primary-soft-border); }
  .more-tile.active .more-tile-ic { background: var(--color-primary); color: var(--color-on-primary); }
  .more-tile.active .more-tile-tx { color: var(--color-primary); font-weight: 600; }
  .more-tile:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: var(--radius-control); }
  body.more-open { overflow: hidden; }
  @media (prefers-reduced-motion: reduce) { .more-sheet, .more-sheet-backdrop { transition: none; } }
}
@media (max-width: 340px) { .more-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 861px) { .more-sheet, .more-sheet-backdrop { display: none !important; } }

/* MOBILE-NAV-2 — quick-action row + new-orders count badge */
.dash-quick { display: none; }
.dash-quick-wrap { display: none; }
.ord-chips { display: none; }
.count-badge {
  position: absolute; top: -3px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
  border-radius: 999px; background: var(--color-danger); color: #fff; box-shadow: 0 0 0 2px var(--color-surface);
  font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.count-badge[hidden] { display: none; }
@media (max-width: 860px) {
  .dash-quick {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; grid-column: 1 / -1;
    padding: 10px 6px 6px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-control);
  }
  a.more-tile { text-decoration: none; }
  .more-tile-ic { position: relative; }
  .bottom-nav-link { position: relative; }
  .bottom-nav-link .count-badge { top: 4px; left: calc(50% + 2px); right: auto; }
}

/* ==========================================================================
   MOBILE-DASH-1 (<=860px) — Claude-reference mobile shell + Dashboard.
   Order on the Dashboard: header row -> Revenue hero -> the other KPI cards
   -> quick actions (+ More) -> remaining dashboard cards -> bottom nav.
   Logic is untouched: the KPI cells are still the same .dash-kpi[data-metric]
   chart tabs (click / keyboard handlers in admin.js), quick tiles are the same
   links, the header store button still opens the More sheet. Colours come from
   the EliteDuka royal blue tokens; the geometry (radii, circle sizes, type scale) is
   measured from the reference. Desktop/tablet >860px are not touched.
   ========================================================================== */
@media (max-width: 860px) {
  :root { --header-h: 64px; --m-gutter: 20px; }

  /* ---- Header row: store circle | store pill | bell | account ---- */
  .topbar { height: 64px; padding: 10px var(--m-gutter); gap: 12px; }
  .topbar-left { flex: 1; min-width: 0; gap: 0; }
  .topbar-store { position: relative; flex: 1; width: 100%; height: 44px; padding: 0; gap: 10px; }
  .topbar-store .mark { width: 44px; height: 44px; padding: 8px; }
  .topbar-store .mark.is-initial { padding: 0; font-size: 19px; font-weight: 600; }
  .topbar-store b {
    flex: 1; min-width: 0; display: block; height: 44px; padding: 0 40px 0 16px; border-radius: var(--radius-control);
    background: rgba(255, 255, 255, .14); font-size: 15px; font-weight: 500; line-height: 44px; letter-spacing: 0;
    color: rgba(255, 255, 255, .92); text-align: left;
  }
  .topbar-store i.ai { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 16px; color: rgba(255, 255, 255, .8); }
  .topbar-right { gap: 12px; }
  .topbar-right .icon-btn, .topbar-account .av {
    width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .14); color: var(--color-on-primary);
  }
  .topbar-right .icon-btn:hover, .topbar-right .icon-btn:focus-visible,
  .topbar-account .av:hover, .topbar-account .av:focus-visible { background: rgba(255, 255, 255, .24); }
  .topbar-right .icon-btn i.ai, .topbar-account .av i.ai { font-size: 20px; }
  .topbar .icon-btn .notif-dot { top: 10px; right: 11px; }

  /* ---- Dashboard only: header scrolls away with the hero, no page title ---- */
  body[data-route="dashboard"] .topbar { position: static; }
  body[data-route="dashboard"] .page-head { display: none; }
  body[data-route="dashboard"] .content { padding: 0 var(--m-gutter) calc(96px + env(safe-area-inset-bottom, 0px)); }
  body[data-route="dashboard"] .dash-grid { gap: 28px; }

  /* ---- KPI block: revenue hero + three cards ---- */
  #statGrid.dash-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0;
    background: none; border: 0; border-radius: 0; box-shadow: none; overflow: visible;
  }
  #statGrid > .skel:first-child { grid-column: 1 / -1; height: 200px; margin: 0 calc(-1 * var(--m-gutter)); border-radius: 0 0 var(--radius-hero-mobile) var(--radius-hero-mobile); }
  #statGrid > .skel:not(:first-child) { display: none; }

  #statGrid .dash-kpi { border: 0; }
  #statGrid .dash-kpi[data-metric="revenue"] {
    grid-column: 1 / -1; grid-row: 1; margin: 0 calc(-1 * var(--m-gutter));
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start; text-align: center;
    min-height: 0; padding: 24px var(--m-gutter) 64px;
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-deep) 100%);
    border-radius: 0 0 var(--radius-hero-mobile) var(--radius-hero-mobile); color: var(--color-on-primary);
  }
  #statGrid .dash-kpi[data-metric="revenue"]:hover, #statGrid .dash-kpi[data-metric="revenue"].is-active {
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-deep) 100%);
  }
  #statGrid .dash-kpi[data-metric="revenue"]:focus-visible { outline: 2px solid #fff; outline-offset: -6px; }
  #statGrid .dash-kpi[data-metric="revenue"] .dash-kpi-label {
    max-width: 100%; font-size: 13px; font-weight: 400; line-height: 16px; letter-spacing: 0; color: rgba(255, 255, 255, .74);
  }
  #statGrid .dash-kpi[data-metric="revenue"] .dash-kpi-val {
    max-width: 100%; margin-top: 12px; overflow: visible; font-size: clamp(38px, 11.6vw, 48px); font-weight: 600;
    line-height: 1.1; letter-spacing: -.03em; color: var(--color-on-primary);
  }
  #statGrid .dash-kpi[data-metric="revenue"] .dash-kpi-val .cur {
    font-size: .46em; font-weight: 500; margin-right: .22em; color: rgba(255, 255, 255, .78); letter-spacing: 0;
  }
  #statGrid .dash-kpi[data-metric="revenue"] .dash-kpi-cmp { justify-content: center; margin-top: 12px; min-height: 26px; }
  #statGrid .dash-kpi[data-metric="revenue"] .dash-kpi-spacer { height: 26px; }
  #statGrid .dash-kpi[data-metric="revenue"] .dash-pill {
    padding: 4px 11px; border-radius: var(--radius-control); background: rgba(255, 255, 255, .18); color: var(--color-on-primary);
    font-size: 12.5px; font-weight: 600; line-height: 18px;
  }

  /* ---- KPI strip (MOBILE-DASH-2): the DESKTOP KPI design (one bordered card, hairline dividers, label / value /
     trend, EliteDuka corner token) sitting where the reference's cards sit, overlapping the hero's bottom edge.
     The cells are the same .dash-kpi chart tabs; only their paint changes. No glyph circles, no per-card shadow. ---- */
  #statGrid .dash-kpi:not([data-metric="revenue"]) {
    grid-row: 2; position: relative; z-index: 1; margin-top: -48px; min-height: 76px; justify-content: space-between;
    padding: 10px 12px 8px; background: var(--color-surface); border: 0; border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
    border-radius: 0; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05);
  }
  #statGrid .dash-kpi[data-metric="customers"] { border-left: 1px solid var(--color-border); border-radius: var(--radius-control) 0 0 var(--radius-control); }
  #statGrid .dash-kpi[data-metric="aov"]       { border-right: 1px solid var(--color-border); border-radius: 0 var(--radius-control) var(--radius-control) 0; }
  #statGrid .dash-kpi[data-metric="orders"], #statGrid .dash-kpi[data-metric="aov"] { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05), inset 1px 0 0 var(--color-border-soft); }
  #statGrid .dash-kpi:not([data-metric="revenue"]):hover { background: var(--color-surface); }
  #statGrid .dash-kpi:not([data-metric="revenue"]).is-active { background: var(--color-bg); }
  #statGrid .dash-kpi:not([data-metric="revenue"]):focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
  #statGrid .dash-kpi:not([data-metric="revenue"]) .dash-kpi-label { min-height: 30px; font-size: 11.5px; font-weight: 500; line-height: 15px; letter-spacing: 0; color: var(--color-text-muted); white-space: normal; overflow: visible; text-overflow: clip; }
  #statGrid .dash-kpi:not([data-metric="revenue"]) .dash-kpi-val { margin-top: 2px; font-size: clamp(14px, 4.2vw, 17px); font-weight: 700; line-height: 24px; letter-spacing: -.025em; color: var(--color-text); }
  #statGrid .dash-kpi:not([data-metric="revenue"]) .dash-kpi-val .cur { font-size: 10.5px; margin-right: 3px; }
  #statGrid .dash-kpi:not([data-metric="revenue"]) .dash-kpi-cmp { margin-top: 2px; min-height: 18px; }

  /* ---- Quick Actions card (MOBILE-DASH-3): M-PESA-style white card, title + "View all", 4 x 2 grid of tinted tiles.
     Tiles use the EliteDuka corner token (square, not circles). ---- */
  .dash-quick-wrap { display: block; grid-column: 1 / -1; padding: 16px 12px 14px; background: var(--color-surface); border-radius: var(--radius-card-mobile); box-shadow: var(--shadow-card-mobile); }
  .dash-quick-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 14px; }
  .dash-quick-head h3 { margin: 0; font-size: 17px; font-weight: 600; line-height: 24px; letter-spacing: -.01em; color: var(--color-text); }
  .dash-quick-all { display: inline-flex; align-items: center; gap: 2px; padding: 4px 0 4px 8px; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 500; color: var(--color-primary); cursor: pointer; }
  .dash-quick-all i.ai { font-size: 16px; }
  .dash-quick { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 4px; padding: 0; background: none; border: 0; border-radius: 0; }
  .dash-quick .more-tile { gap: 8px; padding: 0; align-items: center; }
  .dash-quick .more-tile-ic { width: 48px; height: 48px; border-radius: var(--radius-control); background: var(--color-primary-soft); color: var(--color-primary); box-shadow: none; }
  .dash-quick .more-tile:active .more-tile-ic { background: var(--color-primary-soft-border); }
  .dash-quick .more-tile-ic i.ai { font-size: 22px; }
  .dash-quick .more-tile-tx { display: block; max-width: 100%; font-size: 12.5px; font-weight: 400; line-height: 16px; letter-spacing: 0; white-space: normal; overflow: visible; text-align: center; color: var(--color-text-secondary); }
  .dash-quick .count-badge { top: -5px; right: -5px; }

  /* ---- Remaining dashboard cards ---- */
  .dash-grid > .card, .dash-pair > .card { border: 0; border-radius: var(--radius-card-mobile); box-shadow: var(--shadow-card-mobile); }
  .dash-card > .dash-card-head, .dash-pair .dash-card-head { border-radius: var(--radius-card-mobile) var(--radius-card-mobile) 0 0; } /* head paints white; keep the card's rounded top corners */
  .dash-card-head h3, .dash-pair .dash-card-head h3 { font-size: 17px; font-weight: 600; line-height: 24px; letter-spacing: -.01em; color: var(--color-text); }

  /* Recent orders: heading above a white list card (the reference's "Recent transactions") */
  .dash-grid > .dash-orders-card { padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
  .dash-orders-card .dash-card-head { align-items: center; margin-bottom: 12px; }
  .dash-orders-card .dash-card-head .btn { width: auto; height: auto; min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; font-size: 14px; font-weight: 500; color: var(--color-text-muted); }
  .dash-orders-card .dash-table-wrap { margin: 0; padding: 4px 16px; background: var(--color-surface); border-radius: var(--radius-card-mobile); box-shadow: var(--shadow-card-mobile); overflow: hidden; }
  #recentOrdersTable, #recentOrdersTable tbody { display: block; width: 100%; min-width: 0; }
  #recentOrdersTable thead { display: none; }
  #recentOrdersTable tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--color-border-soft); }
  #recentOrdersTable tr:first-child { border-top: 0; }
  #recentOrdersTable td { display: block; padding: 0; border: 0; background: none; }
  #recentOrdersTable td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; min-width: 0; }
  #recentOrdersTable td:nth-child(2) { display: none; }
  #recentOrdersTable td:nth-child(3) { grid-column: 2; grid-row: 1; text-align: right; font-size: 15px; font-weight: 600; color: var(--color-text); }
  #recentOrdersTable td:nth-child(4) { grid-column: 2; grid-row: 2; justify-self: end; margin-top: 4px; }
  #recentOrdersTable td[colspan] { grid-column: 1 / -1; grid-row: auto; }
  #recentOrdersTable .dash-ord .row-thumb { width: 44px; height: 44px; border-radius: var(--radius-control); }
  #recentOrdersTable .dash-ord b { font-size: 15px; font-weight: 600; color: var(--color-text); }
  #recentOrdersTable .dash-ord small { font-size: 12.5px; color: var(--color-text-muted); }

  /* ---- Bottom bar ---- */
  .mobile-bottom-nav { height: calc(64px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--color-border-soft); box-shadow: 0 -6px 24px rgba(16, 24, 40, .05); }
  .bottom-nav-link { height: 64px; color: var(--color-text-muted); }
  .bottom-nav-link i.ai { font-size: 24px; }
  .bottom-nav-link span { margin-top: 4px; font-size: 11px; font-weight: 500; letter-spacing: 0; line-height: 14px; }
  .bottom-nav-link.active, .bottom-nav-link.active:hover { color: var(--color-primary); }
  .bottom-nav-pos i.ai { width: 40px; height: 40px; margin-top: -10px; font-size: 20px; background: var(--color-primary); box-shadow: 0 4px 12px rgba(22,138,78, .32); }
  .bottom-nav-pos:hover i.ai, .bottom-nav-pos:active i.ai, .bottom-nav-pos.active i.ai { background: var(--color-primary); }
  .bottom-nav-pos span { margin-top: 3px; }
  .bottom-nav-link .count-badge { top: 6px; }
}

/* ==========================================================================
   MOBILE-DASH-3 (<=860px) — Orders on phones: status chips, "Needs action" / "All orders" sections, card rows.
   Desktop/tablet >860px untouched. Card rows apply to the Orders table only (.ord-cards, not POS Sales).
   ========================================================================== */
@media (max-width: 860px) {
  #view-orders #orderStatusFilter { display: none; } /* the chip row below replaces it on phones (value still drives the filter) */
  .ord-chips { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
  .ord-chips[hidden] { display: none; }
  .ord-chips::-webkit-scrollbar { display: none; }
  .ord-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-control); background: var(--color-surface); font: inherit; font-size: 13.5px; font-weight: 500; color: var(--color-text-secondary); cursor: pointer; }
  .ord-chip.is-on { background: var(--color-primary-soft); border-color: var(--color-primary-soft-border); color: var(--color-primary); }
  .ord-chip b { min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 999px; background: var(--color-danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; }
  .ord-chip b[hidden] { display: none; }

  #view-orders .table-wrap { overflow: visible; }
  table.ord-cards, table.ord-cards tbody { display: block; width: 100%; min-width: 0; }
  table.ord-cards thead { display: none; }
  table.ord-cards tr { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: start; padding: 12px 16px; border-top: 1px solid var(--color-border-soft); }
  table.ord-cards tr:first-child { border-top: 0; }
  table.ord-cards tr:not(.ord-sec) > td { display: none; padding: 0; border: 0; background: none; }
  table.ord-cards tr > td:nth-child(2)  { display: block; grid-column: 1; grid-row: 1; font-size: 15px; font-weight: 600; color: var(--color-text); }
  table.ord-cards tr > td:nth-child(2) a::after { content: ""; position: absolute; inset: 0; } /* whole card taps through to the order */
  table.ord-cards tr > td:nth-child(4)  { display: block; grid-column: 1; grid-row: 2; margin-top: 2px; font-size: 13px; color: var(--color-text-muted); }
  table.ord-cards tr > td:nth-child(12) { display: block; grid-column: 1; grid-row: 3; margin-top: 2px; font-size: 12px; color: var(--color-text-muted); }
  table.ord-cards tr > td:nth-child(7)  { display: block; grid-column: 2; grid-row: 1; text-align: right; font-size: 15px; font-weight: 600; color: var(--color-text); }
  table.ord-cards tr > td:nth-child(11) { display: block; grid-column: 2; grid-row: 2 / span 2; justify-self: end; margin-top: 4px; }

  table.ord-cards tr.ord-sec { display: block; padding: 0; border-top: 0; }
  table.ord-cards tr.ord-sec > td { display: flex; align-items: center; justify-content: space-between; padding: 9px 16px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; border: 0; }
  table.ord-cards tr.ord-sec b { font-size: 12px; font-variant-numeric: tabular-nums; }
  table.ord-cards tr.ord-sec.is-action > td { background: var(--color-warning-soft); color: var(--color-warning-text); box-shadow: inset 3px 0 0 var(--color-warning); }
  table.ord-cards tr.ord-sec.is-rest > td { background: var(--color-surface-muted); color: var(--color-text-muted); }
}

/* ==========================================================================
   MOBILE-DASH-4 (<=860px, screen only) — every admin table becomes a fintech-style card list.
   Classes come from js/mobile-tables.js (mc-cards / mc-row / mc-title / mc-sub / mc-amt / mc-status / mc-meta / mc-act / mc-chk / mc-img).
   Print and desktop untouched. Orders (.ord-cards) and #recentOrdersTable keep their own MOBILE-DASH-1/3 layouts.
   Row grid: 8 equal columns. title 1-5 | amount 6-8, subtitle 1-5 | status 6-8, then label/value pairs (2-up), then [Select] + actions.
   ========================================================================== */
.mc-sortbar { display: none; }
@media screen and (max-width: 860px) {
  .table-wrap.mc-wrap { overflow-x: clip; max-width: 100%; }
  table.mc-cards, table.mc-cards tbody { display: block; width: 100%; min-width: 0 !important; max-width: 100%; } /* !important: #biProductTable / #view-stores set id-level min-widths */
  table.mc-cards thead { display: none; }

  table.mc-cards tr.mc-row {
    position: relative; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); column-gap: 12px; align-items: start;
    padding: 14px 16px; background: transparent; border-top: 1px solid var(--color-border-soft);
  }
  table.mc-cards tbody:first-of-type tr.mc-row:first-child { border-top: 0; }
  /* keeps auto-placed label/value cells out of rows 1-2 no matter which top cells exist */
  table.mc-cards tr.mc-row::before { content: ""; grid-area: 1 / 1 / 3 / -1; pointer-events: none; }
  table.mc-cards tr.mc-row:hover { background: transparent; }
  table.mc-cards tr.mc-row[data-mc-tap] { cursor: pointer; }
  table.mc-cards tr.mc-row[data-mc-tap]:active { background: var(--color-bg); }
  table.mc-cards tr.mc-row.mc-expanded { background: var(--color-bg); }
  table.mc-cards tr.mc-row.mc-has-img { padding-left: 72px; }
  table.mc-cards tr.mc-row.variant-row-dirty { background: var(--color-warning-soft); }

  table.mc-cards tr.mc-row > td {
    display: block; min-width: 0; padding: 0; border: 0; background: none; white-space: normal; overflow-wrap: anywhere;
    font-size: 13.5px; color: var(--color-text-secondary); text-align: left;
  }
  table.mc-cards tr.mc-row > td.num { text-align: left; }
  table.mc-cards tr.mc-row > td, table.mc-cards tr.mc-row > td::before, table.mc-cards tr.mc-row > td.num { font-family: var(--font-sans, inherit); }

  /* title / subtitle / amount / status */
  table.mc-cards tr.mc-row > td.mc-title { grid-column: 1 / 6; grid-row: 1; font-size: 15px; font-weight: 600; line-height: 20px; color: var(--color-text); }
  table.mc-cards tr.mc-row:not(.mc-has-amt):not(.mc-has-status) > td.mc-title { grid-column: 1 / -1; }
  table.mc-cards tr.mc-row > td.mc-title a { color: inherit; text-decoration: none; }
  table.mc-cards tr.mc-row > td.mc-title .row-title { max-width: none; }
  table.mc-cards tr.mc-row > td.mc-title .row-title .name { white-space: normal; font-size: 15px; font-weight: 600; color: var(--color-text); }
  table.mc-cards tr.mc-row > td.mc-title .row-thumb { width: 44px; height: 44px; }
  table.mc-cards tr.mc-row > td.mc-sub { grid-column: 1 / 6; grid-row: 2; margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--color-text-muted); }
  table.mc-cards tr.mc-row:not(.mc-has-amt):not(.mc-has-status) > td.mc-sub { grid-column: 1 / -1; }
  table.mc-cards tr.mc-row > td.mc-amt { grid-column: 6 / -1; grid-row: 1; text-align: right; font-size: 15px; font-weight: 600; line-height: 20px; font-variant-numeric: tabular-nums; color: var(--color-text); white-space: nowrap; }
  table.mc-cards tr.mc-row > td.mc-status { grid-column: 6 / -1; grid-row: 2; justify-self: end; margin-top: 3px; text-align: right; }
  table.mc-cards tr.mc-row:not(.mc-has-amt) > td.mc-status { grid-row: 1; margin-top: 0; }
  table.mc-cards tr.mc-row:not(.mc-has-sub):not(.mc-has-amt) > td.mc-status { grid-row: 1; }
  table.mc-cards tr.mc-row > td.mc-title:empty, table.mc-cards tr.mc-row > td.mc-sub:empty { display: none; }

  /* stand-alone image column (Categories) */
  table.mc-cards tr.mc-row > td.mc-img { position: absolute; left: 16px; top: 14px; width: 44px; height: 44px; }
  table.mc-cards tr.mc-row > td.mc-img img { width: 44px; height: 44px; border-radius: var(--radius-control); object-fit: cover; }

  /* label / value pairs */
  table.mc-cards tr.mc-row > td.mc-meta { order: 5; grid-column: span 4; margin-top: 12px; font-size: 13.5px; line-height: 18px; color: var(--color-text); }
  table.mc-cards tr.mc-row > td.mc-meta.mc-wide { grid-column: 1 / -1; }
  table.mc-cards tr.mc-row > td.mc-meta.mc-empty { display: none; }
  table.mc-cards tr.mc-row > td.mc-meta[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px; font-size: 11.5px; font-weight: 500; line-height: 14px; letter-spacing: .01em; color: var(--color-text-muted);
  }
  table.mc-cards tr.mc-row > td.mc-meta .meta { white-space: normal; }

  /* bulk-select + actions share the bottom line */
  table.mc-cards tr.mc-row > td.mc-act { order: 10; grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--color-border-soft); }
  table.mc-cards tr.mc-row > td.mc-act:empty { display: none; }
  table.mc-cards tr.mc-row > td.mc-act .cell-actions, table.mc-cards tr.mc-row > td.mc-act .row-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  table.mc-cards tr.mc-row > td.mc-act .tbl-icon-btn { width: 38px; height: 38px; }
  table.mc-cards tr.mc-row > td.mc-act .btn { min-height: 40px; }

  /* placeholder rows: skeletons, "Loading…", "No data", "+N more" */
  table.mc-cards tr.mc-plain { display: block; padding: 0; border-top: 1px solid var(--color-border-soft); }
  table.mc-cards tr.mc-plain:first-child { border-top: 0; }
  table.mc-cards tr.mc-plain > td { display: block; padding: 14px 16px; border: 0; white-space: normal; }

  /* editable tables (variants, delivery brackets, invoice line items): every cell is a labelled field */
  table.mc-cards tr.mc-form-row > td.mc-meta { grid-column: span 4; }
  table.mc-cards tr.mc-form-row > td.mc-meta.mc-wide { grid-column: 1 / -1; }
  table.mc-cards tr.mc-form-row > td.mc-meta.mc-empty { display: block; }
  table.mc-cards tr.mc-form-row > td.mc-meta:not(.mc-wide):nth-child(n) { margin-top: 10px; }
  table.mc-cards tr.mc-form-row > td.mc-title { grid-column: 1 / -1; }
  table.mc-cards tr.mc-form-row input:not([type="checkbox"]):not([type="radio"]), table.mc-cards tr.mc-form-row select, table.mc-cards tr.mc-form-row textarea {
    width: 100%; min-width: 0; height: 42px; padding: 8px 10px; box-sizing: border-box; font-size: 16px; /* 16px stops iOS zooming into the field */
  }
  table.mc-cards tr.mc-form-row .variant-input { min-width: 0; }

  /* sort bar: replaces the hidden column headers */
  .mc-sortbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--color-border-soft); background: var(--color-surface); }
  .mc-sortbar label { flex: none; font-size: 12.5px; font-weight: 500; color: var(--color-text-muted); }
  .mc-sortbar select { flex: 1; min-width: 0; height: 36px; }
  .mc-sort-dir { flex: none; width: 36px; height: 36px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-control); background: var(--color-surface); font-size: 16px; line-height: 1; color: var(--color-text-secondary); cursor: pointer; }
  .mc-sort-dir:active { background: var(--color-bg); }

  /* analytics / dashboard cards: tighter, no per-row actions */
  table.dash-table.mc-cards tr.mc-row { padding: 12px 0; }
  .dash-table-wrap.mc-wrap { padding-left: 16px; padding-right: 16px; }
  .dash-table-wrap.mc-wrap table.mc-cards tr.mc-row { padding-left: 0; padding-right: 0; }
  .dash-table-wrap.mc-wrap table.mc-cards tr.mc-plain > td { padding-left: 0; padding-right: 0; }
  table.dash-table.mc-cards tr.mc-row > td.mc-meta { margin-top: 8px; font-size: 13px; }

  /* invoice document: keep the paper look, just stop the 6 columns overflowing */
  table.inv-lines.mc-cards tr.mc-row { padding-left: 0; padding-right: 0; }

  /* key line (date / stock) stays on the collapsed card, like the date on an order card */
  table.mc-cards tr.mc-row > td.mc-meta.mc-key { order: 0; grid-column: 1 / -1; grid-row: 3; margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--color-text-muted); }
  table.mc-cards tr.mc-row > td.mc-meta.mc-key::before { display: none; }
  table.mc-cards tr.mc-row > td.mc-meta.mc-key.mc-labeled::before { display: inline; content: attr(data-label) ": "; margin: 0; font-size: 12px; font-weight: 400; }

  /* solid status chips on phone cards: success green, warning/danger red, everything else blue; white text */
  table.mc-cards .badge, table.ord-cards .badge, table.mc-cards .dash-badge {
    border: 0; background: var(--color-primary); color: #fff; font-weight: 600;
  }
  table.mc-cards .badge.badge-success, table.ord-cards .badge.badge-success, table.mc-cards .dash-badge.is-success { background: #039855; color: #fff; }
  table.mc-cards .badge.badge-warning, table.mc-cards .badge.badge-danger,
  table.ord-cards .badge.badge-warning, table.ord-cards .badge.badge-danger, table.mc-cards .dash-badge.is-warning { background: #D92D20; color: #fff; }

  /* ---------- lean list cards: only the important info; tapping the card opens the item ---------- */
  table.mc-cards tr.mc-row.mc-lean { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
  table.mc-cards tr.mc-row.mc-lean > td.mc-meta:not(.mc-key), table.mc-cards tr.mc-row.mc-lean > td.mc-act { display: none; }
  table.mc-cards tr.mc-row.mc-lean > td.mc-title .row-title .meta, table.mc-cards tr.mc-row.mc-lean > td.mc-title .badge { display: none; }
  /* bulk-select checkbox: only while Select mode is on */
  table.mc-cards tr.mc-row > td.mc-chk { display: none; }
  table.mc-cards.mc-selecting tr.mc-row, table.ord-cards.mc-selecting tr:not(.ord-sec) { padding-left: 52px; }
  table.mc-cards.mc-selecting tr.mc-row.mc-has-img { padding-left: 108px; }
  table.mc-cards.mc-selecting tr.mc-row.mc-has-img > td.mc-img { left: 52px; }
  table.mc-cards.mc-selecting tr.mc-row > td.mc-chk, table.ord-cards.mc-selecting tr:not(.ord-sec) > td:nth-child(1) {
    display: block; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); margin: 0; padding: 0; border: 0; width: 22px; height: 22px;
  }
  table.mc-cards.mc-selecting tr.mc-row > td.mc-chk input, table.ord-cards.mc-selecting tr:not(.ord-sec) > td:nth-child(1) input { width: 22px; height: 22px; margin: 0; }
  table.ord-cards.mc-selecting tr:not(.ord-sec) > td:nth-child(2) a::after { pointer-events: none; }
  table.ord-cards tr:not(.ord-sec) { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
  /* ⋮ menu for rows with more than one action */
  table.mc-cards tr.mc-row.mc-lean.mc-menu { padding-right: 52px; }
  table.mc-cards tr.mc-row.mc-lean.mc-menu > td.mc-act {
    grid-area: auto; display: block; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; margin: 0; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  }
  table.mc-cards tr.mc-row.mc-lean.mc-menu > td.mc-act > * { display: none; }
  table.mc-cards tr.mc-row.mc-lean.mc-menu > td.mc-act::after { content: "\22EE"; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; font-size: 24px; line-height: 1; color: var(--color-text-muted); }
  table.mc-cards tr.mc-row.mc-lean.mc-menu > td.mc-act:active { background: var(--color-bg); }
  table.mc-cards.mc-selecting tr.mc-row.mc-lean.mc-menu { padding-right: 16px; }
  table.mc-cards.mc-selecting tr.mc-row.mc-lean.mc-menu > td.mc-act { display: none; }

  /* toolbar */
  .mc-sortbar[hidden], .mc-sortbar [hidden] { display: none !important; }
  .mc-sort-wrap { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
  .mc-count { flex: 1; font-size: 13px; color: var(--color-text-muted); }
  .mc-sel-btn, .mc-sel-all { flex: none; height: 36px; padding: 0 14px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-control); background: var(--color-surface); font-size: 13.5px; font-weight: 600; color: var(--color-text); cursor: pointer; }
  .mc-sel-btn.is-on { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }


  /* action sheet (⋮) */
  .mc-sheet { position: fixed; inset: 0; z-index: 1000; }
  .mc-sheet-bg { position: absolute; inset: 0; background: rgba(16, 24, 40, .45); }
  .mc-sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--color-surface); border-radius: 18px 18px 0 0; animation: mcSheetUp .18s ease-out; }
  @keyframes mcSheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
  .mc-sheet-grab { width: 36px; height: 4px; margin: 4px auto 10px; border-radius: 2px; background: var(--color-border-strong); }
  .mc-sheet-title { padding: 2px 8px 10px; font-size: 14px; font-weight: 600; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mc-sheet-item { display: block; width: 100%; height: 52px; padding: 0 12px; border: 0; border-top: 1px solid var(--color-border-soft); background: none; text-align: left; font-size: 16px; color: var(--color-text); cursor: pointer; }
  .mc-sheet-item.is-danger { color: #D92D20; }
  .mc-sheet-cancel { margin-top: 6px; border-top: 0; border-radius: var(--radius-control); background: var(--color-bg); text-align: center; font-weight: 600; }

  /* Products: name (+ thumbnail), price, status chip and quantity. Quantity is plain, full-strength text (red when low). */
  table.mc-cards.mc-core tr.mc-row > td.mc-sub, table.mc-cards.mc-core tr.mc-row > td.mc-key { display: none; }
  table.mc-cards.mc-core tr.mc-row { grid-template-columns: minmax(0, 1fr) auto; padding-top: 12px; padding-bottom: 12px; }
  table.mc-cards.mc-core tr.mc-row > td.mc-title { grid-column: 1; grid-row: 1; }
  table.mc-cards.mc-core tr.mc-row > td.mc-amt { grid-column: 2; grid-row: 1; }
  table.mc-cards.mc-core tr.mc-row > td.mc-status { grid-column: 2; grid-row: 2; justify-self: end; margin-top: 4px; }
  table.mc-cards.mc-core tr.mc-row.mc-lean > td.mc-meta.mc-qty { display: block; grid-column: 1; grid-row: 2; order: 0; margin-top: 4px; font-size: 14px; font-weight: 600; line-height: 22px; color: var(--color-text); }
  table.mc-cards.mc-core tr.mc-row.mc-lean > td.mc-meta.mc-qty.mc-low { color: #D92D20; }
  table.mc-cards.mc-core tr.mc-row.mc-lean > td.mc-meta.mc-qty > * { display: none; }
  table.mc-cards.mc-core tr.mc-row.mc-lean > td.mc-meta.mc-qty::before { content: attr(data-qty); display: block; margin: 0; font-size: 14px; font-weight: 600; line-height: 22px; letter-spacing: 0; color: inherit; }
  /* Categories reuse the Products card: tree dashes + name at full strength (nothing muted), count bottom-left, status bottom-right */
  table.mc-cards.mc-core tr.mc-row > td.mc-title .cat-tree-prefix { color: inherit; font-family: inherit; }
  table.mc-cards.mc-core tr.mc-row > td.mc-title .cat-origin, table.mc-cards.mc-core tr.mc-row > td.mc-title .cat-taxpath { display: none; }
  /* Stores list: store name + plan subheadline (full-strength text, not muted) on the left, status chip on the right; tap opens the store */
  #storesTbody tr.mc-row { padding-top: 14px; padding-bottom: 14px; align-items: center; }
  #storesTbody tr.mc-row > td.mc-title { grid-column: 1 / 7; }
  #storesTbody tr.mc-row > td.mc-title .store-sub { display: block; font-size: 13.5px; font-weight: 400; color: var(--color-text); opacity: 1; }
  #storesTbody tr.mc-row > td.mc-title .row-title .name { font-size: 15px; font-weight: 600; }
  #storesTbody tr.mc-row > td.mc-status { grid-column: 7 / -1; grid-row: 1; margin-top: 0; }
  /* strike-through "was" price never fits next to the price on a phone card */
  table.mc-cards tr.mc-row > td.mc-amt span[style*="line-through"], table.mc-cards tr.mc-row > td.mc-amt s, table.mc-cards tr.mc-row > td.mc-amt del { display: none; }

  /* Analytics / dashboard tables: name + headline number + at most two supporting figures */
  table.mc-dash tr.mc-row > td.mc-hide, table.mc-dash tr.mc-row > td.mc-empty { display: none; }
  table.mc-dash tr.mc-row > td.mc-show { order: 5; grid-column: span 4; margin-top: 6px; }
  table.mc-dash tr.mc-row > td.mc-title { font-size: 14px; }
  table.mc-dash tr.mc-row > td.mc-sub { display: none; }
}

/* ==========================================================================
   MOBILE-DASH-5 (<=860px, screen only) — fintech-style Home.
   Hero (today's sales) -> range chips -> 4 quick actions -> Needs attention ->
   Recent activity -> collapsed Trends. Customers Demographic, Monthly Sales,
   Inventory Alerts, Recent Orders, the KPI strip and the 4 extra quick tiles are
   hidden on phones only; desktop/tablet and print are untouched.
   ========================================================================== */
.dm-hero, .dm-attn, .dm-feed, .dm-trends-btn, .dm-target { display: none; }
@media screen and (max-width: 860px) {
  #view-dashboard { --dm-gap: 28px; }
  /* 4 quick actions in one row */
  #view-dashboard .dash-quick { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  /* removed from the phone home (kept on desktop) */
  #view-dashboard #statGrid.dash-kpis,
  #view-dashboard .dash-grid > .dash-sales-card,
  #view-dashboard .dash-grid > .dash-demo-card,
  #view-dashboard .dash-grid > .dash-orders-card,
  #view-dashboard .dash-grid > .dash-inv-card,
  #view-dashboard .dash-pair > .dash-target-card,
  #view-dashboard .dash-stats-card .dash-head-tools,
  #view-dashboard .dash-quick .more-tile:not([data-dm-quick]) { display: none !important; }

  /* hero: same blue gradient hero as DASH-1 (bleeds to the screen edges, rounded bottom), white 3-cell strip overlapping its bottom edge */
  .dm-hero { display: block; position: relative; grid-column: 1 / -1; margin: 0 calc(-1 * var(--m-gutter)) 20px; padding: 14px var(--m-gutter) 12px; text-align: center; color: var(--color-on-primary);
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-deep) 100%); border-radius: 0 0 var(--radius-hero-mobile) var(--radius-hero-mobile); }
  .dm-range { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; max-width: 280px; margin: 0 auto; padding: 4px; background: rgba(255, 255, 255, .14); border-radius: var(--radius-control); }
  .dm-range button { min-height: 40px; border: 0; border-radius: calc(var(--radius-control) - 2px); background: none; font: inherit; font-size: 14px; font-weight: 500; color: rgba(255, 255, 255, .86); cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .dm-range button.is-on { background: #fff; color: var(--color-primary); font-weight: 600; }
  .dm-range button:focus-visible, .dm-trends-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
  .dm-hero .dm-range button:focus-visible, .dm-hero .dm-eye:focus-visible { outline-color: #fff; }
  .dm-eye { position: absolute; top: 66px; right: calc(var(--m-gutter) - 8px); display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; color: rgba(255, 255, 255, .86); cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .dm-eye i.ai { font-size: 22px; }
  .dm-eye:active { background: rgba(255, 255, 255, .18); }
  .dm-hero-label { margin-top: 18px; font-size: 13px; line-height: 16px; color: rgba(255, 255, 255, .74); }
  .dm-hero-val { margin-top: 12px; font-size: clamp(38px, 11.6vw, 48px); font-weight: 600; line-height: 1.1; letter-spacing: -.03em; color: var(--color-on-primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .dm-hero-val.is-long { font-size: clamp(30px, 9vw, 38px); }
  .dm-hero-val .cur { margin-right: .22em; font-size: .46em; font-weight: 500; letter-spacing: 0; color: rgba(255, 255, 255, .78); }
  .dm-hero-chg { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 12px; min-height: 26px; font-size: 12.5px; color: rgba(255, 255, 255, .74); }
  .dm-chg { padding: 4px 11px; border-radius: var(--radius-control); background: rgba(255, 255, 255, .18); color: var(--color-on-primary); font-size: 12.5px; font-weight: 600; line-height: 18px; }
  .dm-chg.is-flat { color: rgba(255, 255, 255, .86); font-weight: 500; }
  .dm-split { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 20px 0 -44px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-control); box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05); text-align: left; }
  .dm-split-i { display: block; min-width: 0; padding: 10px 12px 8px; color: var(--color-text); text-decoration: none; -webkit-tap-highlight-color: transparent; }
  a.dm-split-i { cursor: pointer; }
  a.dm-split-i:active { background: var(--color-surface-muted); }
  a.dm-split-i:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
  .dm-split-i b, .dm-split-i .dm-amt { color: var(--color-text); opacity: 1; }
  .dm-split-i + .dm-split-i { border-left: 1px solid var(--color-border-soft); }
  .dm-split-i span:not(.dm-amt) { display: block; font-size: 11.5px; font-weight: 500; line-height: 15px; color: var(--color-text-muted); }
  .dm-split-i b { display: block; margin-top: 6px; font-size: clamp(14px, 4.2vw, 17px); font-weight: 700; line-height: 24px; letter-spacing: -.025em; color: var(--color-text); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Needs attention + Recent activity */
  .dm-attn, .dm-feed { display: block; grid-column: 1 / -1; }
  .dm-attn[hidden] { display: none !important; }
  .dm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .dm-head h3 { margin: 0; font-size: 17px; font-weight: 600; line-height: 24px; letter-spacing: -.01em; color: var(--color-text); }
  .dm-head a { padding: 8px 0 8px 12px; font-size: 14px; font-weight: 500; color: var(--color-text-muted); text-decoration: none; }
  .dm-list { padding: 4px 16px; background: var(--color-surface); border-radius: var(--radius-card-mobile); box-shadow: var(--shadow-card-mobile); overflow: hidden; }
  .dm-attn-row, .dm-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 0; border-top: 1px solid var(--color-border-soft); color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
  .dm-attn-row:first-child, .dm-row:first-child { border-top: 0; }
  .dm-attn-ic { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: var(--radius-control); }
  .dm-attn-ic i.ai { font-size: 20px; }
  .dm-attn-ic.is-warn { background: var(--color-warning-soft); color: var(--color-warning-text); }
  .dm-attn-ic.is-bad { background: var(--color-danger-soft); color: var(--color-danger-text); }
  .dm-attn-tx { flex: 1; min-width: 0; }
  .dm-attn-tx b { display: block; font-size: 15px; font-weight: 600; color: var(--color-text); }
  .dm-attn-tx small { display: block; font-size: 12.5px; color: var(--color-text-muted); }
  .dm-attn-n { font-size: 17px; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }
  .dm-attn-go { flex: none; font-size: 18px; color: var(--color-text-placeholder); }
  .dm-row { justify-content: space-between; align-items: flex-start; }
  .dm-row-main { flex: 1; min-width: 0; }
  .dm-row-main b { display: block; overflow: hidden; font-size: 15px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text); }
  .dm-row-main small { display: block; overflow: hidden; font-size: 12.5px; line-height: 17px; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-muted); }
  .dm-row-side { display: flex; flex: none; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 46%; }
  .dm-row-side > b { font-size: 15px; font-weight: 600; color: var(--color-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .dm-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 18px; color: #fff; white-space: nowrap; }
  .dm-chip.is-ok { background: #039855; }
  .dm-chip.is-bad { background: #D92D20; }
  .dm-chip.is-info { background: var(--color-primary); }
  .dm-empty { padding: 20px 0; font-size: 14px; text-align: center; color: var(--color-text-muted); }

  /* Trends: collapsed by default. The cards stay laid out (zero-height, clipped) so ECharts sizes them correctly. */
  .dm-trends-btn { display: flex; align-items: center; justify-content: space-between; grid-column: 1 / -1; width: 100%; min-height: 52px; padding: 0 16px; border: 0; border-radius: var(--radius-card-mobile); background: var(--color-surface); box-shadow: var(--shadow-card-mobile); font: inherit; font-size: 17px; font-weight: 600; color: var(--color-text); cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .dm-trends-btn i.ai { font-size: 20px; color: var(--color-text-muted); transition: transform .2s ease; }
  .dm-trends-open .dm-trends-btn i.ai { transform: rotate(180deg); }
  .dm-target { display: block; grid-column: 1 / -1; padding: 14px 16px; background: var(--color-surface); border-radius: var(--radius-card-mobile); box-shadow: var(--shadow-card-mobile); }
  .dm-target-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
  .dm-target-top b { font-size: 15px; font-weight: 600; color: var(--color-text); }
  .dm-target-top span { font-size: 15px; font-weight: 700; color: var(--color-primary); font-variant-numeric: tabular-nums; }
  .dm-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--color-surface-muted); }
  .dm-bar i { display: block; height: 100%; border-radius: 999px; background: var(--color-primary); }
  .dm-target small { display: block; margin-top: 8px; font-size: 12.5px; color: var(--color-text-muted); }
  #view-dashboard:not(.dm-trends-open) .dash-pair,
  #view-dashboard:not(.dm-trends-open) .dm-target { height: 0; margin-top: calc(-1 * var(--dm-gap)); padding: 0; overflow: hidden; visibility: hidden; }
}


/* ==========================================================================
   Dashboard — traffic source pills (#dashSources)
   White cards, compact metric trio, official brand logos from admin/brand-logos.
   Desktop: wrapping grid. Phone: one swipeable row.
   ========================================================================== */
.dash-src { grid-column: 1 / -1; background: var(--color-surface); border: 1px solid #E2E8F0; border-radius: var(--radius-control); box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05); padding: 18px 20px 20px; }
.dash-src[hidden] { display: none !important; }
.dash-src-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dash-src-head h3 { margin: 0; font-size: 17px; font-weight: 600; line-height: 24px; letter-spacing: -.01em; color: var(--color-text); }
.dash-src-head p { margin: 2px 0 0; font-size: 13px; line-height: 18px; color: var(--color-text-secondary); }
.dash-src-head a { flex-shrink: 0; padding: 4px 0 4px 8px; font-size: 14px; font-weight: 500; color: var(--color-primary); text-decoration: none; }
.dash-src-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 12px; }
.srcp { display: flex; flex-direction: column; gap: 14px; padding: 14px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; min-width: 0; }
.srcp-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.srcp-logo { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 9px; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 1px var(--color-border-soft); }
.srcp-logo img { display: block; width: 32px; height: 32px; }
.srcp-mono { background: var(--color-surface-muted); color: var(--color-text); font-size: 14px; font-weight: 600; }
.srcp-name { font-size: 15px; font-weight: 600; line-height: 20px; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srcp-m { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.srcp-m > div { min-width: 0; }
.srcp-m dt { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--color-text-secondary); white-space: nowrap; }
.srcp-m dd { margin: 2px 0 0; font-size: 17px; line-height: 22px; font-weight: 600; letter-spacing: -.01em; color: var(--color-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.srcp-empty { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--color-text-secondary); }
@media screen and (max-width: 860px) {
  .dash-src { border: 0; border-radius: var(--radius-card-mobile); box-shadow: var(--shadow-card-mobile); padding: 16px 0 16px 16px; }
  .dash-src-head { padding-right: 16px; }
  .dash-src-row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 16px 4px 0; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .dash-src-row::-webkit-scrollbar { display: none; }
  .srcp { flex: 0 0 min(232px, 72vw); scroll-snap-align: start; }
  .srcp-empty { padding-right: 16px; }
}

/* ==========================================================================
   Dashboard — share your store (#dashShare)
   ========================================================================== */
.dash-share { grid-column: 1 / -1; background: var(--color-surface); border: 1px solid #E2E8F0; border-radius: var(--radius-control); box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05); padding: 18px 20px 20px; }
.dash-share[hidden] { display: none !important; }
.dash-share-head h3 { margin: 0; font-size: 17px; font-weight: 600; line-height: 24px; letter-spacing: -.01em; color: var(--color-text); }
.dash-share-head h3 { margin-bottom: 12px; }
.dash-share-head p { margin: 2px 0 14px; font-size: 13px; line-height: 18px; color: var(--color-text-secondary); }
.dash-share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dash-share-url { flex: 1 1 240px; min-width: 0; height: 40px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--color-text); background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: var(--radius-control); text-overflow: ellipsis; }
.dash-share-social { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--color-border-soft); }
.dash-share-hint { margin: 0 0 10px; font-size: 13px; line-height: 18px; color: var(--color-text-secondary); }
.dash-share-plat img { display: block; width: 18px; height: 18px; }
@media screen and (max-width: 860px) {
  .dash-share { border: 0; border-radius: var(--radius-card-mobile); box-shadow: var(--shadow-card-mobile); padding: 16px; }
  .dash-share-row .btn { flex: 1 1 100%; justify-content: center; }
  .dash-share-social .dash-share-row .btn { flex: 1 1 calc(50% - 5px); }
}

/* ==========================================================================
   DASH-6 — dashboard polish (desktop/tablet > 860px; phones keep the MOBILE-DASH-5 home).
   Sales by channel, Needs attention strip, empty-state copy. Presentation only: same tokens, no new colours.
   ========================================================================== */
.dash-chan { grid-column: 1 / -1; }
.dash-chan-table { width: 100%; border-collapse: collapse; }
.dash-chan-table th, .dash-chan-table td { padding: 12px; text-align: left; font-size: 14px; color: var(--color-text); border-top: 1px solid var(--color-border-soft); vertical-align: middle; }
.dash-chan-table thead th { padding: 10px 12px; font-size: 12px; font-weight: 500; color: var(--text-faint); background: var(--bg); border-top: 0; }
.dash-chan-table tbody th, .dash-chan-table tfoot th { font-weight: 600; }
.dash-chan-table tbody th a { color: var(--color-text); text-decoration: none; }
.dash-chan-table tbody th a:hover { color: var(--color-primary); text-decoration: underline; }
.dash-chan-table tbody th a:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 2px; }
.dash-chan-table .dash-chan-n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-chan-table tfoot th, .dash-chan-table tfoot td { font-weight: 700; border-top: 1px solid var(--line); }
.dash-chan-share { display: flex; align-items: center; gap: 10px; }
.dash-chan-bar { flex: 0 1 140px; min-width: 60px; height: 8px; border-radius: var(--radius-control); background: var(--line); overflow: hidden; }
.dash-chan-bar i { display: block; height: 100%; background: var(--primary); border-radius: var(--radius-control); }
.dash-chan-share span { width: 38px; font-size: 14px; font-weight: 500; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.dash-chan-empty { padding: 28px 12px; text-align: center; font-size: 14px; color: var(--text-faint); }

@media screen and (min-width: 861px) {
  /* Needs attention: one slim strip under the KPIs (only when something needs attention; markup/JS shared with the phone home). */
  .dm-attn:not([hidden]) { display: block; grid-column: 1 / -1; padding: 14px 20px; background: var(--color-surface); border: 1px solid #E2E8F0; border-radius: var(--radius-control); box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05); }
  .dm-attn .dm-head { margin-bottom: 8px; }
  .dm-attn .dm-head h3 { margin: 0; font-size: 14px; font-weight: 600; line-height: 20px; color: var(--color-text); }
  .dm-attn .dm-list { display: flex; flex-wrap: wrap; gap: 4px 32px; }
  .dm-attn-row { display: flex; align-items: center; gap: 12px; min-width: 240px; padding: 6px 8px; margin: 0 -8px; border-radius: var(--radius-control); color: inherit; text-decoration: none; }
  .dm-attn-row:hover { background: var(--color-bg); }
  .dm-attn-row:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
  .dm-attn-ic { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; border-radius: var(--radius-control); }
  .dm-attn-ic i.ai { font-size: 18px; }
  .dm-attn-ic.is-warn { background: var(--color-warning-soft); color: var(--color-warning-text); }
  .dm-attn-ic.is-bad { background: var(--color-danger-soft); color: var(--color-danger-text); }
  .dm-attn-tx { flex: 1; min-width: 0; }
  .dm-attn-tx b { display: block; font-size: 14px; font-weight: 600; color: var(--color-text); }
  .dm-attn-tx small { display: block; font-size: 12px; color: var(--color-text-muted); }
  .dm-attn-n { font-size: 16px; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }
  .dm-attn-go { flex: none; font-size: 16px; color: var(--color-text-placeholder); }
}
@media screen and (max-width: 860px) {
  /* the hero already splits Online / POS / WhatsApp on phones */
  #view-dashboard .dash-grid > .dash-chan { display: none; }
  /* Every phone item spans the full row, but the 12 tracks + 28px gap summed to 308px of gutters alone, wider than the
     280px content box at 320px (the full-bleed hero spilled 28px sideways). Rows keep their gap; columns need none. */
  body[data-route="dashboard"] .dash-grid { column-gap: 0; }
}

/* ==========================================================================
   PHASE 7 — usability polish (phones only, screen only). Presentation only.
   Pager controls were 36x32 with a 27px / 12px page-size select; bring them to the 40px touch size and 16px select
   text (stops iOS zooming into the field) already used by the mobile Sort bar. Pager rows keep the label on its own
   line and spread the controls across the width so Previous / Next sit under the thumb.
   ========================================================================== */
@media screen and (max-width: 860px) {
  .pagination-bar { gap: 10px; }
  .pagination-bar > span:first-child { flex: 1 1 100%; }
  .pagination-bar .pg-pages { flex: 1 1 100%; justify-content: space-between; gap: 8px; }
  .pagination-bar .pg-pages button { min-width: 44px; min-height: 40px; }
  .pagination-bar .pg-size { min-height: 40px; padding: 6px 8px; font-size: 16px; }
  .pagination-bar .pg-info { font-size: 13px; }
  /* Categories' pager has only Previous / Next: keep it on one row, label left, buttons right. */
  #catPaginationBar > span:first-child { flex: 1 1 auto; }
  #catPaginationBar .pg-pages { flex: 0 0 auto; }
}

.dash-toolbar { display: contents; }
.dash-range-bar { display: none; }
@media screen and (max-width: 860px) { .dash-custom-row { display: none !important; } }

/* ==========================================================================
   DASHBOARD DESKTOP LAYOUT (>= 861px; phones are untouched)
   Reading order, top to bottom: quick actions (top-right) -> KPIs (Revenue top-left) -> Needs attention (only when
   something needs action) -> Revenue chart + Monthly target -> Sales by channel + Traffic sources -> Recent orders +
   Stock alerts -> Share your store. Visual order is set with `order` so the phone DOM order is not disturbed.
   ========================================================================== */
@media screen and (min-width: 861px) {
  /* Quick actions: a slim toolbar above the KPIs, right-aligned (primary action sits top-right). */
  /* Toolbar row above the KPIs: period selector on the left, quick actions on the right; wraps on narrow content widths. */
  .dash-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; grid-column: 1 / -1; order: -1; margin-bottom: -8px; }
  .dash-range-bar { display: block; min-width: 0; max-width: 100%; }
  .dash-custom-row { flex: 1 1 100%; order: 3; }
  /* The period now lives in the toolbar, not in the Revenue card. */
  #view-dashboard .dash-stats-card .dash-range { display: none; }
  .dash-quick-wrap { display: flex; margin-left: auto; justify-content: flex-end; padding: 0; background: none; border: 0; box-shadow: none; }
  .dash-quick-head { display: none; }
  .dash-quick { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 0; background: none; border: 0; }
  .dash-quick .more-tile { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 1px solid var(--color-border); border-radius: var(--radius-control); background: var(--color-surface); color: var(--color-text); font: inherit; font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; }
  .dash-quick .more-tile:hover { background: var(--color-bg); border-color: var(--color-text-placeholder); }
  .dash-quick .more-tile:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
  .dash-quick .more-tile-ic { width: auto; height: auto; background: none; border-radius: 0; color: var(--color-primary); font-size: 16px; }
  .dash-quick .more-tile-ic i.ai { font-size: 16px; color: inherit; }
  .dash-quick .more-tile-tx { display: inline; max-width: none; font-size: 14px; line-height: 20px; text-align: left; color: inherit; overflow: visible; white-space: nowrap; }
  /* POS sale is the most frequent action: filled primary button. */
  .dash-quick .more-tile[data-dm-route="pos"] { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
  .dash-quick .more-tile[data-dm-route="pos"] .more-tile-ic { color: inherit; }
  .dash-quick .more-tile[data-dm-route="pos"]:hover { background: var(--color-primary); filter: brightness(.94); }
  .dash-quick .more-tile[data-dm-route="pos"] { order: 1; }   /* rightmost = primary action */
}
@media screen and (min-width: 1280px) {
  /* Row 4: where sales happen (1/2) + where visitors come from (1/2); the channel table needs ~440px, so not 1/3. Traffic sources hides itself when analytics is off;
     Sales by channel then spans the full row (:has fallback below). */
  #view-dashboard .dash-grid > .dash-chan { order: 1; grid-column: span 6; align-self: stretch; }
  #view-dashboard .dash-grid > .dash-src { order: 2; grid-column: span 6; align-self: stretch; }
  /* Full-width fallback only once analytics is known to be unavailable (JS sets data-off); while the traffic data is still
     loading the half-width slot is kept, so the page does not jump when it arrives. */
  #view-dashboard .dash-grid:has(> .dash-src[data-off]) > .dash-chan { grid-column: 1 / -1; }
  /* Row 5: Recent orders (2/3) + Stock alerts (1/3), equal height. */
  #view-dashboard .dash-grid > .dash-orders-card { order: 3; grid-column: span 8; align-self: stretch; }
  #view-dashboard .dash-grid > .dash-inv-card { order: 4; grid-column: span 4; align-self: stretch; }
  /* Share your store: last. */
  #view-dashboard .dash-grid > .dash-share { order: 5; }
}
@media screen and (min-width: 861px) and (max-width: 1279px) {
  #view-dashboard .dash-grid > .dash-chan { order: 1; grid-column: 1 / -1; }
  #view-dashboard .dash-grid > .dash-src { order: 2; }
  #view-dashboard .dash-grid > .dash-orders-card { order: 3; }
  #view-dashboard .dash-grid > .dash-inv-card { order: 4; }
  #view-dashboard .dash-grid > .dash-share { order: 5; }
}
/* Half-width Traffic sources on 1024-1439px screens: two compact source cards per row instead of one tall column. */
@media screen and (min-width: 1280px) and (max-width: 1439px) {
  #view-dashboard .dash-src-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #view-dashboard .dash-src .srcp { padding: 12px; gap: 12px; }
  #view-dashboard .dash-src .srcp-m { grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 6px; }
  #view-dashboard .dash-src .srcp-m dd { font-size: 15px; }
}

/* Reserve the KPI row height on desktop so the page does not jump when the figures load. */
@media screen and (min-width: 861px) { #view-dashboard #statGrid.dash-kpis { min-height: 88px; } }
/* Traffic sources: while loading (still hidden, no data-off) keep its slot empty rather than collapsing it. */
@media screen and (min-width: 1280px) { #view-dashboard .dash-grid > .dash-src[hidden]:not([data-off]) { display: block !important; visibility: hidden; } }

/* Laptop widths (861-1439px): keep the period selector and all four quick actions on ONE row by showing the three secondary
   actions as icon-only buttons (full label in the tooltip); New POS sale keeps its label. */
@media screen and (min-width: 861px) and (max-width: 1439px) {
  .dash-quick .more-tile:not([data-dm-route="pos"]) { width: 40px; padding: 0; justify-content: center; }
  .dash-quick .more-tile:not([data-dm-route="pos"]) .more-tile-tx { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
}


/* Monthly target: merchant-set goal, progress bar, inline editor. */
.dash-target-main { justify-content: center; gap: 0; padding: 20px; }
.tg-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.tg-pct { font-size: 32px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; color: var(--text, var(--color-text)); font-variant-numeric: tabular-nums; }
.tg-bar { height: 10px; overflow: hidden; border-radius: 999px; background: var(--line, #E4E7EC); }
.tg-bar i { display: block; height: 100%; border-radius: 999px; background: var(--color-primary, var(--primary)); transition: width .4s ease; }
.tg-nums { margin-top: 12px; font-size: 13px; color: var(--color-text-muted, #667085); font-variant-numeric: tabular-nums; }
.tg-nums b { font-weight: 600; color: var(--text, var(--color-text)); }
.tg-hint { display: block; margin-top: 4px; font-size: 12.5px; color: var(--text-faint, #98A2B3); }
.tg-empty { text-align: center; padding: 8px 0; }
.tg-empty b { display: block; font-size: 15px; font-weight: 600; color: var(--text, var(--color-text)); }
.tg-empty p { margin: 6px 0 14px; font-size: 13px; line-height: 19px; color: var(--color-text-muted, #667085); }
.tg-lbl { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--color-text-muted, #667085); }
.tg-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tg-input { flex: 1 1 140px; min-width: 0; height: 40px; padding: 0 12px; font: inherit; font-size: 15px; border: 1px solid var(--line, #D0D5DD); border-radius: 8px; background: var(--color-surface, #fff); color: var(--text, var(--color-text)); font-variant-numeric: tabular-nums; }
.tg-input:focus { outline: 2px solid var(--color-primary, var(--primary)); outline-offset: 0; border-color: transparent; }
.tg-btn { height: 40px; padding: 0 14px; font: inherit; font-size: 14px; font-weight: 600; border-radius: 8px; border: 1px solid var(--line, #D0D5DD); background: var(--color-surface, #fff); color: var(--text, var(--color-text)); cursor: pointer; }
.tg-btn-primary { background: var(--color-primary, var(--primary)); border-color: transparent; color: var(--color-on-primary, #fff); }
.tg-link { padding: 0; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--color-primary, var(--primary)); cursor: pointer; }
.tg-clear { display: block; margin-top: 12px; color: var(--danger-text, #B42318); }
@media (max-width: 860px) {
  .dm-target .tg-pct { font-size: 24px; }
  .dm-target .tg-top { margin-bottom: 8px; }
  .dm-target .dm-target-top { margin-bottom: 10px; }
  .dm-target .tg-empty { text-align: left; padding: 0; }
  .dm-target .tg-empty p { margin-bottom: 10px; }
}


/* Analytics tabs */
#view-analytics [data-an-tab][hidden] { display: none !important; }
.an-tabs-wrap { grid-column: 1 / -1; min-width: 0; }
.an-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line, #E4E7EC); -webkit-overflow-scrolling: touch; }
.an-tabs::-webkit-scrollbar { display: none; }
.an-tab { flex: 0 0 auto; height: 44px; padding: 0 16px; font: inherit; font-size: 14px; font-weight: 600; color: var(--color-text-muted, #667085); background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.an-tab:hover { color: var(--text, var(--color-text)); }
.an-tab.active { color: var(--color-primary, var(--primary)); border-bottom-color: var(--color-primary, var(--primary)); }
.an-tab:focus-visible { outline: 2px solid var(--color-primary, var(--primary)); outline-offset: -2px; border-radius: 6px; }
.an-tab-sub { margin: 10px 0 0; font-size: 13px; line-height: 18px; color: var(--color-text-muted, #667085); }


/* ---------- Analytics redesign: KPI cards, comparison, chart headline (Shopify / Stripe style) ---------- */
.an-compare { font-size: 13px; color: var(--text-faint); white-space: nowrap; }
.an-compare:empty { display: none; }
.dash-kpis.an-perf-strip { gap: 12px; background: transparent; border: 0; box-shadow: none; border-radius: 0; overflow: visible; }
.an-perf-strip .dash-kpi, .an-perf-strip .dash-kpi:nth-child(n) { background: #fff; border: 1px solid var(--color-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); padding: 14px 16px 12px; min-height: 112px; justify-content: flex-start; gap: 2px; overflow: hidden; }
.an-perf-strip .dash-kpi-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.an-perf-strip .dash-kpi-val { font-size: 22px; line-height: 30px; font-weight: 700; color: var(--color-text); }
@media (min-width: 640px) { .an-perf-strip .dash-kpi-val { font-size: 24px; } }
.an-perf-strip .dash-kpi-cmp { gap: 6px; margin-top: 2px; overflow: hidden; }
.an-perf-strip .dash-pill { padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.an-perf-strip .dash-pill.is-up, .an-stat-summary .dash-pill.is-up { background: rgba(18, 183, 106, .12); color: #067647; }
.an-perf-strip .dash-pill.is-down, .an-stat-summary .dash-pill.is-down { background: rgba(240, 68, 56, .10); color: #B42318; }
.an-vs, .an-stat-cmp { font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.an-spark { height: 34px; margin: 8px -6px -4px; }
.an-stat-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 14px 20px 0; }
.an-stat-summary:empty { display: none; }
.an-stat-summary .dash-pill { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.an-stat-val { font-size: 28px; line-height: 36px; font-weight: 700; letter-spacing: -.02em; color: var(--color-text); font-variant-numeric: tabular-nums; }
.an-stat-cmp { font-size: 13px; }
.an-stat-summary + .dash-chart-lg { margin-top: 8px; }
@media (max-width: 480px) { .an-stat-val { font-size: 24px; line-height: 32px; } .an-perf-strip .dash-kpi { min-height: 104px; } }

/* Analytics: chart-only layout (no tables). Charts size to their rows; nothing scrolls sideways or overlaps. */
.an-chart-cap { margin: 4px 20px 0; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.an-chart-cap[hidden] { display: none; }
.an-rate-chart.dash-chart-sm { height: 190px; }
#view-analytics .dash-card { min-width: 0; }
#view-analytics .dash-chart { min-width: 0; max-width: 100%; overflow: hidden; }

/* Analytics: clean, Shopify-style page. Anything without data is simply not shown. */
.an-nodata { display: none !important; }
.an-tab-empty { grid-column: 1 / -1; padding: 56px 16px; text-align: center; font-size: 14px; color: var(--text-faint); }
.an-tab-empty[hidden] { display: none; }
.dash-kpis.an-perf-strip { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.dash-kpis.an-perf-strip:empty { display: none; }
@media (min-width: 1024px) { .dash-pair.an-pair:has(> .an-nodata) { grid-template-columns: minmax(0, 1fr); } }

/* Compare chip (Shopify-style): "vs 11 \2013 17 Oct". Hidden on phones; the pills carry the comparison on hover / focus. */
.an-compare { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface); font-size: 12.5px; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.an-compare-k { color: var(--text-faint); font-weight: 400; }
.an-compare:empty { display: none; }
@media (max-width: 639px) { .an-compare { display: none; } }
.dash-pill[title] { cursor: help; }

/* "No cost price" prompt under Top products: one quiet line */
.an-cost-prompt { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 20px 16px; padding: 10px 12px; background: var(--color-bg); border-radius: 8px; font-size: 13px; color: var(--text-muted); }
.an-cost-prompt[hidden] { display: none; }
.an-cost-prompt .tg-link { white-space: nowrap; font-weight: 600; }


/* ==========================================================================
   SIDEBAR-COLLAPSE-1 — collapsible desktop icon rail (>=861px).
   Expanded 245px (labels, groups) <-> collapsed 66px (centred icons + tooltips).
   <=860px is untouched: the existing drawer / "More" sheet keeps full labels and
   none of the collapsed rules below apply there. State lives on <html class="sb-collapsed">
   (restored by a tiny inline script in <head>, saved by js/sidebar-collapse.js).
   Colours are the existing shell tokens (blue #168A4E / active #E3F4EB) - nothing re-themed.
   Icon x-positions are identical in both modes (22px from the rail edge) so icons stay
   put while the width animates; only labels appear/disappear.
   ========================================================================== */
.sidebar-brand { padding: 0 13px; }                       /* 40px logo centres in the 66px rail */
.sidebar-nav { padding: 4px 12px 18px; overflow-x: hidden; }
.nav-link { padding: 10px; }                              /* 10 + 22px icon + 10 = 42px: the collapsed square */
.nav-link i { width: 22px; height: 22px; }
.nav-link i svg.i-svg { width: 22px; height: 22px; }
.nav-link .nav-label { min-width: 0; font-size: 14px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { padding: 12px; }
.sidebar-user { padding: 3px; gap: 10px; }
.sidebar-collapse-toggle { display: none; }

/* Tooltip (single element, positioned by js/sidebar-collapse.js; never clipped by the scrolling nav) */
.sb-tip {
  position: fixed; z-index: 60; pointer-events: none; max-width: 260px;
  background: #0F172A; color: #fff; font-size: 12.5px; font-weight: 500; line-height: 1.3;
  padding: 6px 10px; border-radius: var(--radius-control); box-shadow: var(--shadow-md);
  white-space: nowrap; opacity: 0; transform: translateX(-4px);
  transition: opacity .12s ease, transform .12s ease;
}
.sb-tip.show { opacity: 1; transform: none; pointer-events: auto; }
.sb-tip::before { content: ""; position: absolute; left: -22px; top: 0; bottom: 0; width: 22px; }   /* hover bridge from the icon */

@media (min-width: 861px) {
  .sidebar { transition: width .22s ease, transform .25s ease; overflow: visible; }
  .main { transition: margin-left .22s ease; }

  .sidebar-collapse-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: absolute; z-index: 3; top: calc(var(--header-h) / 2 - 14px); right: -14px;
    width: 28px; height: 28px; padding: 0; border-radius: 50%; cursor: pointer;
    background: #fff; color: var(--color-primary); border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    transition: background .15s ease, box-shadow .15s ease;
  }
  .sidebar-collapse-toggle:hover { background: var(--color-primary-soft); box-shadow: var(--shadow-md); }
  .sidebar-collapse-toggle:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
  .sidebar-collapse-toggle i { width: 16px; height: 16px; font-size: 16px; display: inline-flex; transition: transform .22s ease; }
  .sidebar-collapse-toggle i svg.i-svg { width: 16px; height: 16px; }

  /* ---- collapsed rail ---- */
  html.sb-collapsed { --sidebar-w: var(--sidebar-w-collapsed); }
  html.sb-collapsed .sidebar-collapse-toggle i { transform: rotate(180deg); }
  html.sb-collapsed .sidebar-brand { gap: 0; }
  html.sb-collapsed .sidebar-nav { scrollbar-width: none; }
  html.sb-collapsed .sidebar-nav::-webkit-scrollbar { display: none; }
  html.sb-collapsed .nav-link { gap: 0; }

  /* Text stays in the DOM (accessible names) but leaves the layout. */
  html.sb-collapsed .nav-link .nav-label,
  html.sb-collapsed .sidebar-brand .txt,
  html.sb-collapsed .sidebar-user .who {
    position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  /* Group headings become thin separators so the groups stay legible. */
  html.sb-collapsed .nav-section-label {
    height: 0; margin: 10px 10px 8px; padding: 0; overflow: hidden; font-size: 0; line-height: 0;
    border-top: 1px solid var(--shell-sidebar-line);
  }
  html.sb-collapsed .nav-divider { margin: 10px 10px; }
}

@media (min-width: 861px) and (prefers-reduced-motion: reduce) {
  .sidebar, .main, .sidebar-collapse-toggle, .sidebar-collapse-toggle i, .sb-tip { transition: none !important; }
}
@media (prefers-reduced-motion: reduce) { .sb-tip { transition: none; transform: none; } }

/* ---- Analytics: Shopify-style single page (no tabs) ---- */
.an-tabs-wrap { display: none; }
.an-toolbar { justify-content: flex-start; align-items: center; }
@media (min-width: 768px) { .dash-kpis.an-perf-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .dash-pair.an-trio { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.dash-pair.an-trio > .dash-card { justify-content: flex-start; }
@media (min-width: 1024px) { .dash-pair:has(> .an-nodata) > .dash-stats-card { grid-column: 1 / -1; } }

/* TOPBAR-ICONS-1 (phones): drop the store-name pill and its chevron; the header keeps the store logo on the left and
   the icon buttons on the right. The logo still opens the More sheet. */
@media (max-width: 860px) {
  .topbar .topbar-store { flex: 0 0 44px; width: 44px; }
  .topbar .topbar-store b, .topbar .topbar-store i.ai { display: none; }
}
