/*
 * K6 OS — design tokens (2026-04-22).
 *
 * Extracted from _BASE_CSS in shared/dashboard.py so the ~100-line
 * colour + shadow + radius block ships once per session (served by
 * nginx with long-immutable cache headers), not inline in every
 * rendered HTML response. Every route and sibling tool reads from
 * here; the sibling SmartScout app injects its K6 OS sidebar via
 * /sidebar-fragment which links this file the same way.
 *
 * Source of truth: /tmp/k6_design/v1/design_handoff_k6_os/README.md
 * §Color Tokens. Change tokens here — the rest of the app picks
 * them up through var(--name).
 */

:root {
  /* Surface + foreground scale (light) */
  --bg:             oklch(99% 0.002 260);
  --panel:          oklch(100% 0 0);
  --panel-2:        oklch(98% 0.003 260);
  --border:         oklch(92% 0.005 260);
  --border-strong:  oklch(85% 0.008 260);
  --fg:             oklch(18% 0.012 260);
  --fg-2:           oklch(38% 0.01 260);
  --fg-3:           oklch(55% 0.008 260);
  --fg-4:           oklch(72% 0.006 260);

  /* Semantic colour family (each with a -soft surface bg) */
  --accent:         oklch(52% 0.19 290);
  --accent-soft:    oklch(96% 0.03 290);
  --accent-fg:      #ffffff;
  --pos:            oklch(55% 0.14 150);
  --pos-soft:       oklch(96% 0.03 150);
  --neg:            oklch(58% 0.19 25);
  --neg-soft:       oklch(96% 0.04 25);
  --warn:           oklch(70% 0.14 75);
  --warn-soft:      oklch(97% 0.04 85);

  /* Geometry + shadow */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.03);
  --shadow-md: 0 2px 6px rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.04);
  --radius-lg:      18px;
  --radius-md:      14px;
  --radius-sm:      10px;
  --radius-card:    10px;
  --radius-pill:    20px;

  /* Marketplace accent colours — dots, bars, top-borders */
  --mp-amazon:   oklch(72% 0.17 55);
  --mp-bol:      oklch(60% 0.17 250);
  --mp-allegro:  oklch(60% 0.18 25);
  --mp-kaufland: oklch(62% 0.17 15);
  --mp-neutral:  oklch(60% 0.01 260);

  /* ── Legacy aliases (pre-Phase-N inner-route CSS reads these) ── */
  --surface:        var(--panel);
  --border-soft:    var(--border);
  --text-1:         var(--fg);
  --text-2:         var(--fg-2);
  --text-3:         var(--fg-3);
  --positive:       var(--pos);
  --positive-bg:    var(--pos-soft);
  --negative:       var(--neg);
  --negative-bg:    var(--neg-soft);
  --warning:        var(--warn);
  --warning-bg:     var(--warn-soft);

  /* Per-tab accents (legacy nav used these; sidebar picks them up
     to tint the active pill's icon). Kept stable so inner-route
     code that reads --tab-<id> still works. */
  --tab-marketplace:    oklch(52% 0.19 290);
  --tab-agency:         oklch(55% 0.14 150);
  --tab-cashflow:       oklch(52% 0.19 260);
  --tab-payables:       oklch(58% 0.19 25);
  --tab-supplier-split: oklch(62% 0.16 75);
  --tab-brand-ops:      oklch(62% 0.13 200);
  --tab-walker-health:  oklch(55% 0.17 305);
  --tab-smartscout:     oklch(60% 0.19 340);
  --tab-users:          oklch(50% 0.01 260);
  --tab-audit:          oklch(40% 0.012 260);
}

/*
 * ─── Unified Variant A component layer (2026-04-23) ───────────────
 *
 * Promoted from templates/dashboard.html so every native page (agency,
 * cashflow, payables, supplier-split, walker-health, brand-ops, users,
 * audit) can opt into the same card / table / tile / page-header
 * pattern with one class instead of re-rolling per-page CSS. Names are
 * `.k6-` prefixed to namespace alongside the existing `.k6-shell`
 * sidebar layer; `.k6-card` etc. is content, `.k6-shell` etc. is chrome.
 *
 * Tokens only — no hex values. Change the look in tokens.css; every
 * page picks it up. Pages that still ship their own oversized titles
 * or chunky cards override locally and should be migrated onto these
 * classes whenever they're touched.
 */

.k6-page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: 24px 0 20px;
  margin-bottom: 8px;
}
.k6-page-head .k6-title-block { min-width: 0; }
.k6-page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
  line-height: 1.2;
}
.k6-page-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  color: var(--fg-3);
  font-size: 12px;
}
.k6-page-meta .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg-4);
  display: inline-block;
}
.k6-page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.k6-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 14px;
  overflow: hidden;
}
.k6-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 18px 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.k6-card-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--fg);
  margin: 0;
}
.k6-card-title .sub {
  color: var(--fg-4);
  font-weight: 400;
  margin-left: 4px;
}
.k6-card-meta {
  font-size: 12px;
  color: var(--fg-3);
}
.k6-card-body { padding: 14px 18px 18px; }
.k6-card-body.flush { padding: 0; }

.k6-stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 900px) { .k6-stat-tiles { grid-template-columns: 1fr; } }
.k6-stat-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 20px 16px;
  overflow: hidden;
}
.k6-stat-tile-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  text-transform: uppercase;
}
.k6-stat-tile-value {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.k6-stat-tile-value.pos { color: var(--pos); }
.k6-stat-tile-value.neg { color: var(--neg); }
.k6-stat-tile-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--fg-3);
}

.k6-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.k6-data-table thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: right;
  user-select: none;
  white-space: nowrap;
}
.k6-data-table thead th.text { text-align: left; }
.k6-data-table thead th a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.k6-data-table thead th a:hover { color: var(--fg); }
.k6-data-table tbody tr {
  border-bottom: 1px solid var(--border);
  height: 40px;
}
body[data-density="compact"] .k6-data-table tbody tr { height: 32px; }
.k6-data-table tbody tr:hover td { background: var(--panel-2); }
.k6-data-table tbody tr:last-child { border-bottom: none; }
.k6-data-table td {
  padding: 0 14px;
  vertical-align: middle;
  font-size: 13px;
  color: var(--fg);
}
.k6-data-table td.text { text-align: left; }
.k6-data-table td.num {
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.k6-data-table td.num.sub {
  font-size: 12px;
  color: var(--fg-2);
}
.k6-data-table td.muted { color: var(--fg-3); font-size: 11px; }
.k6-data-table td.pos { color: var(--pos); }
.k6-data-table td.neg { color: var(--neg); }

.k6-empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--fg-3);
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  background: var(--panel);
}

.k6-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-2);
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.k6-pill.pos  { color: var(--pos);  background: var(--pos-soft);  border-color: transparent; }
.k6-pill.neg  { color: var(--neg);  background: var(--neg-soft);  border-color: transparent; }
.k6-pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }

/* Product-row thumbnail (2026-04-23). Used by /dashboard's products
   table and any other per-SKU surface. The img sits on a panel-2
   background so a slow / cancelled / 404'd image still shows a
   neutral 40×40 square instead of the broken-image glyph. The img's
   own onerror handler hides it, falling back to the wrapper square. */
.k6-product-thumb {
  display: inline-block;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  vertical-align: middle;
}
.k6-product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-sm);
}
/* td that hosts a .k6-product-thumb — keeps the column narrow and
   centered so the thumbnail doesn't push other columns around. */
.k6-table td.thumb-cell,
.k6-data-table td.thumb-cell,
table td.thumb-cell {
  width: 56px;
  padding: 4px 8px 4px 14px;
  vertical-align: middle;
}

[data-theme="dark"] {
  --bg:            oklch(15% 0.012 260);
  --panel:         oklch(19% 0.012 260);
  --panel-2:       oklch(22% 0.012 260);
  --border:        oklch(27% 0.012 260);
  --border-strong: oklch(34% 0.012 260);
  --fg:            oklch(97% 0.005 260);
  --fg-2:          oklch(78% 0.008 260);
  --fg-3:          oklch(62% 0.01 260);
  --fg-4:          oklch(45% 0.012 260);
  --accent:        oklch(72% 0.18 290);
  --accent-soft:   oklch(28% 0.08 290);
  --pos:           oklch(75% 0.16 150);
  --pos-soft:      oklch(28% 0.06 150);
  --neg:           oklch(72% 0.18 25);
  --neg-soft:      oklch(28% 0.08 25);
  --warn:          oklch(80% 0.14 85);
  --warn-soft:     oklch(28% 0.08 85);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.40), 0 0 0 1px rgba(0,0,0,0.35);
  --shadow-md: 0 2px 6px rgba(0,0,0,0.45), 0 0 0 1px rgba(0,0,0,0.40);
}
