/**
 * MGK Merchant UI-1A — Overview bundle (Dashboard F-01 + Reports F-02).
 *
 * Owned by Claude. Loaded AFTER mgk-retail.css and mgk-merchant-shell.css by the
 * centralized loader in functions.php (Codex/UI-0), so rules here refine the
 * overview pages without touching the shared shell geometry or the monolithic
 * mgk-retail.css. Consumes the shell token contract (--mgk-merchant-*); never
 * redefines header/sidebar/nav.
 *
 * Visual reference: MGK-Merchant-Admin.html (Dashboard + Reports screens).
 */

/* ── KPI row: 4 SRS KPIs (Orders / Revenue ex-GST / AOV / New Customers) ── */
.mgk-mdash__kpis {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
	margin-bottom: 16px;
}

.mgk-mdash__kpi {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 18px 18px 16px;
	background: var(--mgk-merchant-surface);
	border: 1px solid var(--mgk-merchant-border);
	border-radius: var(--mgk-merchant-radius-md);
}

.mgk-mdash__kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mgk-mdash__kpi-label { color: var(--mgk-merchant-text-muted); font-size: 12px; font-weight: 600; }
.mgk-mdash__kpi-value { color: var(--mgk-merchant-text); font: 800 26px/1.1 var(--mgk-merchant-font-display); letter-spacing: -0.01em; }
.mgk-mdash__kpi-sub { margin: 0; color: var(--mgk-merchant-text-muted); font-size: 11px; }

.mgk-mdash__kpi-delta {
	padding: 2px 7px;
	font-size: 11px;
	font-weight: 700;
	border-radius: 999px;
}
.mgk-mdash__kpi-delta--up { color: var(--mgk-merchant-success); background: #f6fcf9; border: 1px solid #b8e9d2; }
.mgk-mdash__kpi-delta--flat { color: var(--mgk-merchant-warning); background: #fefbf5; border: 1px solid #f4dcad; }

/* ── Secondary operational stats (Pending Packing / Low-Out of Stock) ── */
.mgk-mdash__stats {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
	margin-bottom: 20px;
}

.mgk-mdash__stat {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 18px;
	color: inherit;
	text-decoration: none;
	background: var(--mgk-merchant-surface);
	border: 1px solid var(--mgk-merchant-border);
	border-radius: var(--mgk-merchant-radius-md);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

a.mgk-mdash__stat:hover {
	border-color: #d7a6f4;
	box-shadow: 0 6px 18px rgba(150, 21, 219, 0.08);
}

.mgk-mdash__stat-value {
	flex: 0 0 auto;
	min-width: 44px;
	color: var(--mgk-merchant-accent-strong);
	font: 800 24px/1 var(--mgk-merchant-font-display);
}
.mgk-mdash__stat-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mgk-mdash__stat-label { color: var(--mgk-merchant-text); font-size: 13px; font-weight: 650; }
.mgk-mdash__stat-sub { color: var(--mgk-merchant-text-muted); font-size: 11px; }

/* ── Reports: report-type tab bar (Sales / Products / Customers / Taxes) ── */
.mgk-mrep__tabs {
	display: flex;
	gap: 4px;
	margin-bottom: 18px;
	padding: 4px;
	background: var(--mgk-merchant-surface-soft);
	border: 1px solid var(--mgk-merchant-border);
	border-radius: var(--mgk-merchant-radius-sm);
	overflow-x: auto;
}

.mgk-mrep__tab {
	flex: 0 0 auto;
	padding: 7px 16px;
	color: var(--mgk-merchant-text-secondary);
	font-size: 12px;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
	border-radius: 6px;
}

.mgk-mrep__tab:hover { color: var(--mgk-merchant-accent); }
.mgk-mrep__tab.is-active {
	color: var(--mgk-merchant-accent);
	background: var(--mgk-merchant-surface);
	box-shadow: 0 1px 3px rgba(17, 17, 26, 0.08);
}

/* ── Responsive: collapse KPI/stat grids on narrow widths ── */
@media (max-width: 1080px) {
	.mgk-mdash__kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ════════════════════════════════════════════════════════════════════════════
 * S-034 MERCHANT REPORTS v3 — matches MGK-Merchant-Admin-v3.html's tabbed
 * Business/Products/Customers layout exactly. Class names below (mgk-report,
 * mgk-rep2, mgk-rep-col, mgk-chart-point, mgk-chart-tooltip, mgk-bar-hit) are
 * the mockup's own, so the design stays a drop-in match — deliberately not
 * layered on top of the mgk-mdash kpi, cat, or top-row rules above, which
 * stay reserved for the Dashboard page. (The old Sales, Products, Customers,
 * Taxes tab report grid, its mgk-mrep tab pills, and the Taxes tab's
 * mgk-mdash stat GST cards were removed from this file along with the v2
 * Reports layout — Dashboard never used them.)
 *
 * NOTE: keep every class name in this comment separated from any trailing
 * slash by at least a comma-space. A previous version of this comment wrote
 * an asterisk-wildcard class name directly against a following slash, which
 * (asterisk immediately followed by slash) is the CSS block-comment END
 * token — it closed this comment early and silently ate the .mgk-report-kpis
 * rule below, leaving every KPI tile touching its neighbor with zero gap.
 * ════════════════════════════════════════════════════════════════════════════ */

/* KPI strip: 3 (Business) or 4 (Products/Customers) equal columns, set inline
 * per tab by the template since the count varies — this class only supplies
 * the shared gap/margin. */
.mgk-report-kpis { gap: 16px; margin-bottom: 16px; }

/* Tooltip: pure-CSS, dark bubble, top-anchored — reused for every KPI tile,
 * bar-chart column, and progress-bar row on this page. */
.mgk-chart-point { position: relative; }
.mgk-chart-tooltip {
	position: absolute; z-index: 20; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px);
	min-width: max-content; max-width: 220px; padding: 7px 9px; border-radius: 7px;
	background: #1B1B1F; color: #fff; box-shadow: 0 12px 32px rgba(17, 17, 20, .10);
	font-family: system-ui, sans-serif; font-weight: 500; font-size: 11px; line-height: 16px;
	opacity: 0; visibility: hidden; pointer-events: none;
	transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}
.mgk-chart-tooltip::after { content: ""; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #1B1B1F; }
.mgk-chart-point:hover > .mgk-chart-tooltip,
.mgk-chart-point:focus-visible > .mgk-chart-tooltip,
.mgk-chart-point:focus-within > .mgk-chart-tooltip { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.mgk-bar-hit { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: stretch; cursor: help; outline: none; }

/* Underline tab bar: Business / Products / Customers */
.mgk-report-tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid #E9E6EF; }
.mgk-report-tab {
	height: 38px; padding: 0 16px; border: none; background: transparent; border-bottom: 2px solid transparent;
	font-family: system-ui, sans-serif; font-weight: 600; font-size: 13.5px; color: #6E6A78; cursor: pointer; text-decoration: none;
	display: inline-flex; align-items: center;
}
.mgk-report-tab.is-active { color: #9615DB; border-bottom-color: #9615DB; }

/* Two-column card area: 8fr/4fr, collapsing to 1 column on narrow screens */
.mgk-rep2 { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 16px; align-items: start; }
.mgk-rep2 > .mgk-rep-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1040px) { .mgk-rep2 { grid-template-columns: 1fr; } }

.mgk-report-card { background: #fff; border: 1px solid #E9E6EF; border-radius: 12px; min-width: 0; }
.mgk-report-card--pad { padding: 18px 20px 20px; }
.mgk-report-card--table { overflow: hidden; }
.mgk-report-card__head { padding: 16px 20px 12px; }
.mgk-report-card__title { font-family: system-ui, sans-serif; font-weight: 650; font-size: 15px; color: #1B1B1F; }
.mgk-report-card__sub { font-family: system-ui, sans-serif; font-size: 11.5px; color: #8A8494; margin-top: 2px; }

/* KPI tile internals */
.mgk-report-kpi-label { font-family: system-ui, sans-serif; font-weight: 500; font-size: 12px; color: #6E6A78; margin-bottom: 8px; }
.mgk-report-kpi-value { font-family: system-ui, sans-serif; font-weight: 700; font-size: 24px; letter-spacing: -0.01em; color: #1B1B1F; line-height: 1; }
.mgk-report-kpi-foot { display: flex; gap: 14px; margin-top: 12px; padding-top: 10px; border-top: 1px solid #F1EFF5; }
.mgk-report-kpi-foot-col { flex: 1; min-width: 0; }
.mgk-report-kpi-foot-label { font-family: system-ui, sans-serif; font-size: 10.5px; color: #9B93AB; }
.mgk-report-kpi-foot-value { font-family: system-ui, sans-serif; font-weight: 600; font-size: 12px; color: #44404C; margin-top: 2px; }

/* Business tab: Gross-margin badge, category/customer row layout helpers */
.mgk-report-badge-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 13px; background: #E7F6EC; color: #0E7C3F; font-family: system-ui, sans-serif; font-weight: 700; font-size: 13px; }
.mgk-report-badge-pill-dot { width: 6px; height: 6px; border-radius: 3px; background: currentColor; }
.mgk-report-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mgk-report-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.mgk-report-row-top-label { font-family: system-ui, sans-serif; font-weight: 600; font-size: 12.5px; color: #1B1B1F; }
.mgk-report-row-top-figs { font-family: system-ui, sans-serif; font-size: 12px; color: #8A8494; }
.mgk-report-row-help { font-family: system-ui, sans-serif; font-size: 11px; color: #9B93AB; margin-top: 4px; }
.mgk-report-simple-row { display: flex; justify-content: space-between; margin-bottom: 5px; font-family: system-ui, sans-serif; font-size: 12px; }
.mgk-report-simple-row-label { color: #44404C; }
.mgk-report-simple-row-figs { color: #8A8494; }

/* Ranked table (products/categories/outlets): header row + data rows */
.mgk-report-thead { display: flex; gap: 10px; padding: 9px 20px; background: #FBFAFD; border-top: 1px solid #F1EFF5; border-bottom: 1px solid #F1EFF5; }
.mgk-report-th { font-family: system-ui, sans-serif; font-weight: 600; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: #8A8494; }
.mgk-report-th--right { text-align: right; }
.mgk-report-row { display: flex; gap: 10px; align-items: center; padding: 11px 20px; border-bottom: 1px solid #F1EFF5; }
.mgk-report-row:last-child { border-bottom: none; }
.mgk-report-rank { width: 24px; height: 24px; border-radius: 6px; background: #F5EBFD; color: #7E10BC; display: flex; align-items: center; justify-content: center; font-family: system-ui, sans-serif; font-weight: 700; font-size: 11px; flex-shrink: 0; }
.mgk-report-cell-name { font-family: system-ui, sans-serif; font-weight: 600; font-size: 12.5px; color: #1B1B1F; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mgk-report-cell-sku { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: #9B93AB; }
.mgk-report-cell { font-family: system-ui, sans-serif; font-size: 12.5px; color: #44404C; text-align: right; }
.mgk-report-cell--strong { font-weight: 600; }
.mgk-report-cell--profit { font-weight: 700; color: #0E7C3F; }

/* Filter pill row (sort-by / best-sellers-slow-movers toggles) */
.mgk-report-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.mgk-report-pill { height: 30px; padding: 0 11px; border: 1px solid #DCD8E4; background: #fff; color: #6E6A78; border-radius: 8px; font-family: system-ui, sans-serif; font-weight: 600; font-size: 11.5px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.mgk-report-pill.is-active { border-color: #DDB3F8; background: #F5EBFD; color: #7C1AB8; }

/* Progress-bar rows: customer mix, sales channel */
.mgk-report-bar-row { margin-bottom: 14px; }
.mgk-report-bar-row:last-child { margin-bottom: 0; }
.mgk-report-bar-track { height: 7px; background: #F1EFF5; border-radius: 999px; overflow: hidden; }
.mgk-report-bar-track--sm { height: 6px; }
.mgk-report-bar-fill { height: 100%; border-radius: 999px; }

/* "Phase 2" placeholder cards (Stock & inventory, Product classification,
 * By outlet, Gross margin, Customers by outlet) */
.mgk-report-phase2-badge { font-family: system-ui, sans-serif; font-size: 10px; font-weight: 700; color: #92610A; background: #FBF2DF; border: 1px solid #F3DFB6; padding: 2px 7px; border-radius: 4px; white-space: nowrap; }
.mgk-report-phase2-row { display: flex; align-items: flex-start; gap: 11px; padding: 12px 13px; border: 1px dashed #DCD8E4; border-radius: 10px; background: #FBFAFD; margin-bottom: 10px; }
.mgk-report-phase2-row:last-child { margin-bottom: 0; }
.mgk-report-phase2-title { font-family: system-ui, sans-serif; font-weight: 600; font-size: 12.5px; color: #44404C; }
.mgk-report-phase2-body { font-family: system-ui, sans-serif; font-size: 11.5px; color: #9B93AB; margin-top: 2px; line-height: 1.5; }

.mgk-report-note { margin-top: 18px; font-family: system-ui, sans-serif; font-size: 11.5px; color: #9B93AB; }

@media (max-width: 640px) {
	.mgk-mdash__kpis,
	.mgk-mdash__stats { grid-template-columns: minmax(0, 1fr); }
}
