/* ============================================================================
   Dashboard (Operations overview) — professional multi-widget layout.
   Additive + scoped under #dashboard. Reuses the app's teal-blue palette
   (#075985 / #0ea5e9 / #04375a, borders #dbeafe/#e2e8f0). Desktop shows the
   full tiered grid; on mobile (<=1180px) the KPI band is hidden because the
   existing .rk-home block already renders those headline numbers.
   ========================================================================== */

#dashboard .dash { display:flex; flex-direction:column; gap:22px; margin-top:4px; }

/* Desktop: lift the small Repark wordmark up into the bare topbar band (Back is hidden
   on the dashboard, so the top-left is free). Reset on mobile, where .rk-home shows the
   Dashboard title and the brand/hero are hidden. */
#dashboard .repark-brand { margin-top:-40px; }
@media (max-width:1180px){ #dashboard .repark-brand { margin-top:0; } }

/* The teal hero banner IS the dashboard header: big "Dashboard" title + subtitle, with a
   subtle Live accent on the right. Extends the app's existing .hero-card gradient. */
#dashboard .dash-hero { position:relative; overflow:hidden; }
#dashboard .dash-hero::after {
  content:""; position:absolute; right:-40px; top:-70px; width:240px; height:240px; border-radius:50%;
  background:radial-gradient(circle at center, rgba(255,255,255,.14), rgba(255,255,255,0) 70%); pointer-events:none;
}
#dashboard .dash-hero-txt { position:relative; z-index:1; }
#dashboard .dash-hero-title { margin:0; color:#fff; font-size:32px; font-weight:950; letter-spacing:-.01em; line-height:1; }
#dashboard .dash-hero-sub { margin:8px 0 0; color:rgba(255,255,255,.82); font-size:14px; }
#dashboard .dash-hero-live {
  position:relative; z-index:1; flex:0 0 auto; display:inline-flex; align-items:center; gap:8px;
  color:#fff; font-weight:800; font-size:12px; background:rgba(255,255,255,.14);
  border:1px solid rgba(255,255,255,.22); padding:7px 13px; border-radius:999px;
}
#dashboard .dash-hero-dot { width:8px; height:8px; border-radius:50%; background:#4ade80; box-shadow:0 0 0 4px rgba(74,222,128,.25); }
@media (max-width:720px){ #dashboard .dash-hero-title { font-size:26px; } }

/* Section grouping labels — quiet, uppercase, establish hierarchy */
#dashboard .dash-section-label {
  font-size:12px; font-weight:800; letter-spacing:.08em; text-transform:uppercase;
  color:#64748b; margin:2px 0 -8px;
}

/* ── Tier 1: primary KPI tiles (reuse existing .stat look) ─────────────────── */
#dashboard .dash-kpis { display:grid; grid-template-columns:repeat(4,1fr); gap:18px; }
#dashboard .dash-kpis .stat { padding:18px 20px; }
#dashboard .dash-kpi-ico { display:inline-flex; color:#94a3b8; }
#dashboard .dash-kpi-ico svg { width:20px; height:20px; }
#dashboard .dash-kpi-sub { font-size:11px; color:#64748b; font-weight:700; margin-top:5px; opacity:.85; }

/* ── Tier 2: secondary supporting metrics — visually quieter than the KPIs ─── */
#dashboard .dash-metrics { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
#dashboard .dash-metric {
  background:#fff; border:1px solid #e2e8f0; border-radius:16px; padding:14px 16px;
  box-shadow:0 6px 18px rgba(15,23,42,.05);
}
#dashboard .dash-metric-top { display:flex; align-items:center; gap:7px; margin-bottom:9px; }
#dashboard .dash-metric-ico { display:inline-flex; line-height:1; color:#94a3b8; }
#dashboard .dash-metric-ico svg { width:16px; height:16px; }
#dashboard .dash-metric-label {
  font-size:11px; font-weight:800; letter-spacing:.03em; text-transform:uppercase; color:#64748b;
}
#dashboard .dash-metric-num { font-size:22px; font-weight:900; color:#0f172a; line-height:1.1; }
#dashboard .dash-metric-sub { font-size:11px; color:#94a3b8; font-weight:600; margin-top:4px; }
#dashboard .dash-gbp { color:#075985; font-weight:800; }   /* £ approx — reads as a real figure, still secondary to RMB */

/* ── Tier 3: working widget cards ─────────────────────────────────────────── */
#dashboard .dash-widgets { display:grid; grid-template-columns:repeat(2,1fr); gap:18px; }
#dashboard .dash-activity { grid-column:1 / -1; }            /* recent activity spans full width */
#dashboard .dash-card { padding:18px 20px; }
#dashboard .dash-card-head {
  display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:14px;
}
#dashboard .dash-card-head h3 { margin:0; font-size:15px; color:#0f172a; }
#dashboard .dash-subtle { font-size:12px; color:#64748b; font-weight:700; }
#dashboard .dash-badge {
  font-size:12px; font-weight:800; background:#fee2e2; color:#b91c1c; padding:3px 10px; border-radius:999px;
}
#dashboard .dash-empty { color:#94a3b8; font-size:13px; padding:18px 8px; text-align:center; }
#dashboard .dash-ok {
  background:#ecfdf5; border:1px solid #a7f3d0; color:#065f46; font-weight:800;
  padding:14px; border-radius:12px; text-align:center; font-size:13px;
}

/* Low stock list */
#dashboard .dash-lowlist { display:flex; flex-direction:column; gap:8px; max-height:330px; overflow-y:auto; }
/* Explicit areas: the qty used to be grid-row:1/span 2, which ate BOTH rows of
   column 2 and left "on hand" with no cell — it got auto-placed into a stray
   third row and wrapped to "on"/"hand". Named areas pin all four parts. */
#dashboard .dash-low-row {
  display:grid; grid-template-columns:1fr auto; gap:2px 12px; align-items:center;
  grid-template-areas:"name qty" "meta th";
  padding:10px 13px; border-radius:12px; background:#fef2f2; border:1px solid #fecaca;
}
#dashboard .dash-low-name { grid-area:name; font-weight:800; color:#0f172a; font-size:13px;
  min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#dashboard .dash-low-meta { grid-area:meta; font-size:11px; color:#64748b; }
#dashboard .dash-low-qty { grid-area:qty; font-weight:900; color:#dc2626; font-size:15px;
  text-align:right; align-self:end; line-height:1.1; }
#dashboard .dash-low-th { grid-area:th; font-size:11px; color:#94a3b8;
  text-align:right; white-space:nowrap; }

/* Purchase-order workflow — horizontal bars */
#dashboard .dash-bars { display:flex; flex-direction:column; gap:12px; padding-top:2px; }
#dashboard .dash-bar-row { display:grid; grid-template-columns:130px 1fr 36px; align-items:center; gap:10px; }
#dashboard .dash-bar-label {
  font-size:12px; font-weight:700; color:#475569; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
#dashboard .dash-bar-track { height:12px; background:#eef2f7; border-radius:999px; overflow:hidden; }
#dashboard .dash-bar-fill { height:100%; min-width:3px; border-radius:999px; width:0; transition:width .55s cubic-bezier(.4,0,.2,1); }
#dashboard .dash-bar-count { font-size:13px; font-weight:800; color:#0f172a; text-align:right; }

/* Recent activity feed */
#dashboard .dash-feed { display:flex; flex-direction:column; }
#dashboard .dash-feed-row { display:flex; align-items:center; gap:12px; padding:10px 2px; border-bottom:1px solid #eef2f7; }
#dashboard .dash-feed-row:last-child { border-bottom:none; }
#dashboard .dash-feed-ico {
  width:34px; height:34px; border-radius:10px; display:flex; align-items:center; justify-content:center;
  font-size:15px; flex:0 0 auto;
}
#dashboard .dash-feed-ico.po { background:#e0f2fe; color:#0369a1; }
#dashboard .dash-feed-ico.container { background:#eef2ff; color:#4338ca; }
#dashboard .dash-feed-ico svg { width:17px; height:17px; }
#dashboard .dash-feed-main { flex:1; min-width:0; }
#dashboard .dash-feed-title { font-size:13px; font-weight:800; color:#0f172a; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#dashboard .dash-feed-sub { font-size:11px; color:#64748b; }
#dashboard .dash-feed-time { font-size:11px; color:#94a3b8; white-space:nowrap; flex:0 0 auto; }
#dashboard .dash-pill { display:inline-block; font-size:10px; font-weight:800; padding:2px 8px; border-radius:999px; text-transform:capitalize; }

/* Subtle per-widget loading shimmer */
#dashboard .dash-skel { position:relative; color:transparent !important; border-radius:8px;
  background:var(--rms-skel-fill); background-size:400% 100%;
  animation:rms-shimmer var(--t-shimmer) var(--e-in-out) infinite; }

/* ── Responsive: <=1180px = mobile app-shell skin (rk-home owns the KPI band) ─ */
@media (max-width:1180px){
  #dashboard .dash-ov-label, #dashboard .dash-kpis { display:none; }
  #dashboard .dash-metrics { grid-template-columns:repeat(2,1fr); gap:10px; }
  #dashboard .dash-widgets { grid-template-columns:1fr; gap:12px; }
  #dashboard .dash { gap:16px; }
  #dashboard .dash-metric-num { font-size:20px; }
}
@media (max-width:520px){
  #dashboard .dash-bar-row { grid-template-columns:92px 1fr 30px; }
  #dashboard .dash-metric { padding:12px 13px; }
}

/* ── Dark mode (html[data-theme="dark"]) ──────────────────────────────────── */
html[data-theme="dark"] #dashboard .dash-metric { background:#0f1e2e; border-color:rgba(255,255,255,.08); box-shadow:none; }
html[data-theme="dark"] #dashboard .dash-metric-num { color:#e2e8f0; }
html[data-theme="dark"] #dashboard .dash-gbp { color:#7dd3fc; }
html[data-theme="dark"] #dashboard .dash-metric-label,
html[data-theme="dark"] #dashboard .dash-section-label { color:#94a3b8; }
html[data-theme="dark"] #dashboard .dash-card-head h3 { color:#e2e8f0; }
html[data-theme="dark"] #dashboard .dash-bar-track { background:rgba(255,255,255,.09); }
html[data-theme="dark"] #dashboard .dash-bar-count,
html[data-theme="dark"] #dashboard .dash-feed-title { color:#e2e8f0; }
html[data-theme="dark"] #dashboard .dash-feed-row { border-color:rgba(255,255,255,.06); }
html[data-theme="dark"] #dashboard .dash-feed-ico.po { background:rgba(14,165,233,.18); }
html[data-theme="dark"] #dashboard .dash-feed-ico.container { background:rgba(99,102,241,.18); }
html[data-theme="dark"] #dashboard .dash-low-row { background:rgba(220,38,38,.12); border-color:rgba(248,113,113,.28); }
html[data-theme="dark"] #dashboard .dash-low-name { color:#fecaca; }
html[data-theme="dark"] #dashboard .dash-empty { color:#64748b; }

/* ── Channels & orders: line chart + donut + revenue bars + channel health ──── */
#dashboard .dash-orders-grid { display:grid; grid-template-columns:1.7fr 1fr; gap:18px; }
#dashboard .dash-orders-grid .dash-card { min-width:0; }
#dashboard .dash-chart-svg { width:100%; display:block; }
#dashboard .dash-ord-line .dash-chart-svg { height:210px; }
#dashboard .dash-ord-bar .dash-chart-svg { height:190px; }
#dashboard .dash-chart-empty { padding:40px 8px; }

#dashboard .dash-ord-kpi { text-align:right; line-height:1; flex:0 0 auto; }
#dashboard .dash-ord-num { font-size:26px; font-weight:900; color:#0f172a; font-variant-numeric:tabular-nums; }
#dashboard .dash-ord-lbl { display:block; font-size:11px; font-weight:700; color:#94a3b8; margin-top:4px; }
#dashboard .dash-delta { font-size:11px; font-weight:800; padding:2px 7px; border-radius:999px; white-space:nowrap; }
#dashboard .dash-delta--up { color:#16a34a; background:#e7f7ec; }
#dashboard .dash-delta--down { color:#dc2626; background:#fdecec; }

#dashboard .dash-legend { display:flex; gap:16px; flex-wrap:wrap; margin:-6px 0 8px; }
#dashboard .dash-leg { display:flex; align-items:center; gap:7px; font-size:12px; font-weight:650; color:#64748b; }
#dashboard .dash-leg b { color:#0f172a; font-weight:800; font-variant-numeric:tabular-nums; }
#dashboard .dash-leg-sw { width:20px; height:4px; border-radius:2px; background:#0e7ab0; display:inline-block; }
#dashboard .dash-leg-sw--prev { background:repeating-linear-gradient(90deg,#c3ccd8 0 5px,transparent 5px 9px); }

#dashboard .dash-donut-track { stroke:#eef2f7; }
#dashboard .dash-donut-wrap { display:flex; align-items:center; gap:16px; }
#dashboard .dash-donut { position:relative; width:148px; height:148px; flex:0 0 auto; }
#dashboard .dash-donut svg { width:100%; height:100%; }
#dashboard .dash-donut-center { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
#dashboard .dash-donut-center b { font-size:23px; font-weight:900; color:#0f172a; line-height:1; }
#dashboard .dash-donut-center span { font-size:11px; color:#94a3b8; font-weight:650; margin-top:2px; }
#dashboard .dash-dlegend { display:flex; flex-direction:column; gap:8px; flex:1; min-width:0; }
#dashboard .dash-drow { display:flex; align-items:center; gap:8px; font-size:12.5px; }
#dashboard .dash-cd { width:9px; height:9px; border-radius:3px; flex:0 0 auto; }
#dashboard .dash-dnm { flex:1; font-weight:650; color:#0f172a; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#dashboard .dash-dpc { font-weight:800; color:#64748b; font-variant-numeric:tabular-nums; }

#dashboard .dash-chanlist { display:flex; flex-direction:column; }
#dashboard .dash-chan { display:flex; align-items:center; gap:11px; padding:9px 0; border-top:1px solid #eef2f7; }
#dashboard .dash-chan:first-child { border-top:none; }
#dashboard .dash-chan-badge { width:29px; height:29px; border-radius:9px; flex:0 0 auto; display:flex; align-items:center; justify-content:center; color:#fff; font-size:10px; font-weight:800; }
#dashboard .dash-chan-meta { flex:1; min-width:0; }
#dashboard .dash-chan-nm { font-size:13px; font-weight:750; color:#0f172a; }
#dashboard .dash-chan-or { font-size:11px; color:#94a3b8; font-weight:600; }
#dashboard .dash-chan-cnt { font-size:15px; font-weight:800; color:#0f172a; font-variant-numeric:tabular-nums; }
#dashboard .dash-csp { width:60px; height:24px; flex:0 0 auto; }

@media (max-width:1180px){ #dashboard .dash-orders-grid { grid-template-columns:1fr; gap:12px; } }
@media (max-width:520px){ #dashboard .dash-donut-wrap { flex-direction:column; align-items:flex-start; } }

html[data-theme="dark"] #dashboard .dash-donut-track { stroke:rgba(255,255,255,.09); }
html[data-theme="dark"] #dashboard .dash-ord-num,
html[data-theme="dark"] #dashboard .dash-donut-center b,
html[data-theme="dark"] #dashboard .dash-dnm,
html[data-theme="dark"] #dashboard .dash-chan-nm,
html[data-theme="dark"] #dashboard .dash-chan-cnt,
html[data-theme="dark"] #dashboard .dash-leg b { color:#e2e8f0; }
html[data-theme="dark"] #dashboard .dash-chan { border-color:rgba(255,255,255,.06); }
html[data-theme="dark"] #dashboard .dash-delta--up { background:rgba(22,163,74,.18); }
html[data-theme="dark"] #dashboard .dash-delta--down { background:rgba(220,38,38,.18); }
