/* ==========================================================================
   Adidas US Sales Performance — Executive Sales Intelligence Dashboard
   Design system: black / white / neutral gray, one accent (blue), status
   colors reserved for semantic use only. See dataviz skill palette.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Chrome */
  --page: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #f1f1ee;
  --surface-hover: #eeeeec;
  --sidebar-bg: #0a0a0a;
  --sidebar-bg-2: #171717;
  --sidebar-ink: #f5f5f4;
  --sidebar-ink-muted: #97968f;
  --sidebar-ink-faint: #6c6b66;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-hover: rgba(255, 255, 255, 0.055);

  /* Ink */
  --ink: #0b0b0a;
  --ink-secondary: #52514e;
  --ink-muted: #8b8a84;
  --ink-faint: #b2b1ab;
  --ink-on-accent: #ffffff;

  /* Borders / shadow */
  --border: rgba(11, 11, 11, 0.085);
  --border-strong: rgba(11, 11, 11, 0.15);
  --shadow-xs: 0 1px 1px rgba(11, 11, 11, 0.035);
  --shadow-sm: 0 1px 2px rgba(11, 11, 11, 0.04), 0 1px 1px rgba(11, 11, 11, 0.03);
  --shadow-md: 0 10px 26px rgba(11, 11, 11, 0.09), 0 2px 8px rgba(11, 11, 11, 0.045);
  --shadow-lg: 0 20px 48px rgba(11, 11, 11, 0.16), 0 6px 16px rgba(11, 11, 11, 0.07);

  /* Accent — single primary color for the whole system */
  --accent: #2a78d6;
  --accent-strong: #184f95;
  --accent-soft: #4a8ce0;
  --accent-wash: #eaf1fb;
  --accent-wash-strong: #d9e8fa;

  /* Status (reserved — never reused for series identity) */
  --good: #0ca30c;
  --good-ink: #0a7d0a;
  --good-wash: #e7f7e7;
  --warning: #eda100;
  --warning-ink: #9c6d00;
  --warning-wash: #fdf3e0;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-ink: #a92626;
  --critical-wash: #fbe8e8;

  /* Categorical series (fixed order — never cycled/reassigned by rank) */
  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-8: #e34948; /* red */

  --gridline: #ececE6;
  --baseline: #c9c8c1;

  /* Radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Spacing rhythm */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 48px;

  /* Type scale */
  --fs-display: 24px;
  --fs-section: 16px;
  --fs-card-title: 13.5px;
  --fs-kpi-value: 29px;
  --fs-kpi-value-sm: 21px;
  --fs-body: 13px;
  --fs-meta: 11.5px;
  --fs-axis: 11px;

  /* Motion */
  --ease: cubic-bezier(0.22, 0.8, 0.28, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 280ms;

  --sidebar-w: 264px;
  --header-h: 73px;

  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: var(--fs-body);
  line-height: 1.45;
}

::selection {
  background: var(--accent);
  color: #fff;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Subtle first-paint settle — fast, not a spinner */
.content, .kpi-grid {
  animation: dash-settle 0.36s var(--ease) both;
}
@keyframes dash-settle {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .content, .kpi-grid { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------------- */
/* App shell                                                              */
/* ---------------------------------------------------------------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* ---------------------------------------------------------------------- */
/* Sidebar                                                                */
/* ---------------------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(175deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-ink);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform var(--dur-slow) var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 21px 20px 19px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand .mark {
  width: 33px;
  height: 33px;
  border-radius: 9.5px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 2px 6px rgba(0, 0, 0, 0.35);
}

.sidebar-brand .mark svg {
  width: 18px;
  height: 18px;
  stroke: #0b0b0b;
}

.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.sidebar-brand .brand-text strong {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.005em;
  white-space: nowrap;
  color: #fff;
}

.sidebar-brand .brand-text span {
  font-size: 11px;
  color: var(--sidebar-ink-muted);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-nav .nav-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--sidebar-ink-faint);
  padding: 16px 12px 7px;
}

.sidebar-nav .nav-label:first-child {
  padding-top: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8.5px 12px;
  border-radius: 9px;
  color: var(--sidebar-ink-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  position: relative;
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity var(--dur-base) var(--ease);
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-link:hover svg {
  opacity: 1;
}

.nav-link.active {
  background: #fff;
  color: #0b0b0b;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.nav-link.active svg {
  opacity: 1;
}

.sidebar-footer {
  margin: 4px 12px 16px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--sidebar-border);
  font-size: 11px;
  color: var(--sidebar-ink-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-footer strong {
  color: var(--sidebar-ink);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sidebar-collapse-btn {
  display: none;
}

/* ---------------------------------------------------------------------- */
/* Main column                                                            */
/* ---------------------------------------------------------------------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(246, 246, 244, 0.82);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  padding: 15px 32px;
}

.topbar-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.topbar-titles {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mobile-menu-btn {
  display: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur-base) var(--ease);
}

.mobile-menu-btn:hover { background: var(--surface-hover); }
.mobile-menu-btn svg { width: 18px; height: 18px; }

.topbar h1 {
  font-size: var(--fs-display);
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0;
  line-height: 1.15;
}

.topbar .subtitle {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin-top: 3px;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill-wrap {
  position: relative;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0 11px 0 13px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}

.status-pill:hover { background: var(--surface-hover); }

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px var(--good-wash);
  flex-shrink: 0;
}

.status-pill-chevron {
  width: 11px;
  height: 11px;
  color: var(--ink-muted);
  transition: transform var(--dur-base) var(--ease);
}

.status-pill[aria-expanded="true"] .status-pill-chevron { transform: rotate(180deg); }

/* Data Context popover */

.data-context-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  padding: 16px 17px 15px;
  display: none;
  animation: panel-in var(--dur-base) var(--ease);
}

.data-context-panel.open { display: block; }

.dcp-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.dcp-header strong { font-size: 13px; font-weight: 700; }
.dcp-sub { font-size: 11px; color: var(--ink-muted); }

.dcp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-secondary);
  padding: 4px 0;
}

.dcp-row b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.dcp-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}

.dcp-quality-note {
  font-size: 11.5px;
  color: var(--ink-secondary);
  line-height: 1.55;
  margin: 0 0 9px;
}

.dcp-toggle {
  border: none;
  background: var(--accent-wash);
  color: var(--accent-strong);
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease);
}
.dcp-toggle:hover { background: var(--accent-wash-strong); }

.dcp-detail {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px dashed var(--border-strong);
}

.dcp-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--ink-secondary);
  padding: 3px 0;
}
.dcp-detail-row b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.dcp-detail-foot {
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.5;
  margin: 8px 0 0;
}

/* Executive Summary strip */

.exec-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 13px 32px;
  background: linear-gradient(180deg, rgba(42, 120, 214, 0.05), rgba(42, 120, 214, 0.02));
  border-bottom: 1px solid var(--border);
}

.exec-summary-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.exec-trend-badge {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--ink-muted);
}

.exec-trend-badge svg { width: 15px; height: 15px; transition: transform var(--dur-base) var(--ease); }

.exec-trend-badge.trend-up { background: var(--good-wash); color: var(--good-ink); }
.exec-trend-badge.trend-down { background: var(--critical-wash); color: var(--critical-ink); }
.exec-trend-badge.trend-down svg { transform: scaleY(-1); }
.exec-trend-badge.trend-flat { background: var(--surface-2); color: var(--ink-muted); }

.exec-summary-text {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.exec-summary-meta {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-shrink: 0;
}

.exec-meta-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.exec-meta-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.exec-meta-value {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Print-only filter summary (hidden on screen — see @media print) */

.print-only-summary {
  display: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease), border-color var(--dur-base) var(--ease);
  white-space: nowrap;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn:hover {
  background: var(--surface-hover);
  border-color: rgba(11, 11, 11, 0.22);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background: #262624;
  border-color: #262624;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: var(--surface-hover);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

/* Filter bar */

.filter-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 25;
  background: rgba(246, 246, 244, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 11px 32px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.filter-row .spacer { flex: 1; }

.year-toggle {
  display: inline-flex;
  align-items: stretch;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--surface);
}

.year-toggle button {
  border: none;
  background: transparent;
  padding: 0 13px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

.year-toggle button:last-child { border-right: none; }
.year-toggle button:hover:not(.active) { background: var(--surface-2); color: var(--ink); }

.year-toggle button.active {
  background: var(--ink);
  color: #fff;
}

.date-range-inputs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0 6px 0 13px;
}

.date-range-inputs svg { width: 13px; height: 13px; color: var(--ink-muted); flex-shrink: 0; }

.date-range-inputs input[type="date"] {
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--ink);
  padding: 3px 2px;
  width: 112px;
}

.date-range-inputs input[type="date"]:focus { outline: none; }
.date-range-inputs .sep { color: var(--ink-faint); font-size: 11px; }

/* Multi-select */

.multiselect {
  position: relative;
}

.multiselect-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0 12px;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

.multiselect-btn:hover { background: var(--surface-2); }

.multiselect-btn.has-value {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-wash);
}

.multiselect-btn svg {
  width: 12px;
  height: 12px;
  transition: transform var(--dur-base) var(--ease);
}
.multiselect.open .multiselect-btn svg { transform: rotate(180deg); }

.multiselect-btn .count-badge {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  min-width: 16px;
  text-align: center;
  padding: 1px 5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.multiselect-btn.has-value .count-badge { background: var(--accent); }

.multiselect-panel {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  width: 264px;
  max-height: 340px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: top left;
  animation: panel-in var(--dur-base) var(--ease);
}

/* display:none can't itself transition, but the swap is instant and the
   brief scale/opacity animation below still plays every time the panel
   mounts — kept deliberately short per the "subtle, fast" motion rule.
   (An always-mounted panel was tried and reverted: an absolutely
   positioned element still counts toward document scrollWidth even at
   opacity:0, which produced page-level horizontal overflow on mobile.) */
@keyframes panel-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.multiselect.open .multiselect-panel {
  display: flex;
}

@media (prefers-reduced-motion: reduce) {
  .multiselect-panel { animation: none; }
}

.multiselect-search {
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  flex-shrink: 0;
}

.multiselect-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12.5px;
  font-family: inherit;
  transition: border-color var(--dur-base) var(--ease);
}

.multiselect-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.multiselect-list {
  overflow-y: auto;
  padding: 6px;
}

.multiselect-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.6px;
  transition: background var(--dur-fast) var(--ease);
}

.multiselect-option:hover {
  background: var(--surface-2);
}

.multiselect-option input {
  accent-color: var(--ink);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.multiselect-option .opt-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multiselect-option .opt-count {
  font-size: 11px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.multiselect-footer {
  border-top: 1px solid var(--border);
  padding: 7px 10px;
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

.multiselect-footer button {
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background var(--dur-fast) var(--ease);
}
.multiselect-footer button:hover { background: var(--accent-wash); }

/* Active filter chips */

.active-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 0;
}

.active-filters:empty { display: none; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  background: var(--accent-wash);
  color: var(--accent-strong);
  border: 1px solid rgba(42, 120, 214, 0.22);
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  padding: 0 5px 0 11px;
  animation: chip-in var(--dur-base) var(--ease);
}

@keyframes chip-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.filter-chip button {
  border: none;
  background: rgba(42, 120, 214, 0.12);
  color: var(--accent-strong);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  transition: background var(--dur-fast) var(--ease);
}

.filter-chip button:hover { background: rgba(42, 120, 214, 0.26); }

.clear-all-link {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 2px;
  transition: color var(--dur-base) var(--ease);
}
.clear-all-link:hover { color: var(--critical-ink); text-decoration: underline; }

/* ---------------------------------------------------------------------- */
/* Content                                                                */
/* ---------------------------------------------------------------------- */

.content {
  padding: var(--sp-7) 32px 64px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
}

section.dash-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  scroll-margin-top: calc(var(--header-h) + 70px);
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.section-heading h2 {
  font-size: var(--fs-section);
  font-weight: 800;
  margin: 0 0 3px;
  letter-spacing: -0.01em;
}

.section-heading p {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin: 0;
  font-weight: 450;
}

.section-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 1px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: 11.8px;
  font-weight: 600;
  color: var(--ink-secondary);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

.segmented button:hover:not(.active) { color: var(--ink); }

.segmented button.active {
  background: var(--ink);
  color: #fff;
}

.select-control {
  height: 32px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0 26px 0 13px;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2352514e' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  transition: border-color var(--dur-base) var(--ease);
}
.select-control:hover { border-color: rgba(11, 11, 11, 0.26); }

/* KPI cards */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--sp-3);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.kpi-card {
  padding: 18px 19px 17px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: rgba(11, 11, 11, 0.14);
}

.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 650;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
  line-height: 1.3;
}

.kpi-icon {
  width: 29px;
  height: 29px;
  border-radius: 9px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--dur-base) var(--ease);
}

.kpi-card:hover .kpi-icon { background: var(--accent-wash); }
.kpi-card:hover .kpi-icon svg { color: var(--accent-strong); }

.kpi-icon svg { width: 15px; height: 15px; color: var(--ink-secondary); transition: color var(--dur-base) var(--ease); }

.kpi-value-block {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

.kpi-value {
  font-size: var(--fs-kpi-value);
  font-weight: 800;
  letter-spacing: -0.015em;
  font-variant-numeric: proportional-nums;
  line-height: 1.1;
}

.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 16px;
}

.kpi-sub {
  font-size: var(--fs-meta);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.8px;
  font-weight: 700;
  padding: 2px 6px 2px 5px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-delta svg { width: 9px; height: 9px; }

.kpi-delta-up { background: var(--good-wash); color: var(--good-ink); }
.kpi-delta-down { background: var(--critical-wash); color: var(--critical-ink); }
.kpi-delta-flat { background: var(--surface-2); color: var(--ink-muted); }

.kpi-spark-wrap {
  height: 30px;
  margin-top: 2px;
}

.kpi-spark {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* Generic chart card */

.chart-card {
  padding: 21px 22px 19px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* When this card is a CSS Grid item (grid-2 / grid-2-equal / grid-geo),
     the default min-width:auto lets its content's intrinsic size — in
     particular an ECharts SVG's explicit width= attribute from its last
     render — force the grid track wider than the viewport ("grid
     blowout"). min-width:0 opts back into normal shrinking. */
  min-width: 0;
}

.chart-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.chart-card-head h3 {
  font-size: var(--fs-card-title);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.005em;
}

.chart-card-head .chart-desc {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 3px;
  font-weight: 450;
}

.chart-card-head .section-controls,
.chart-card-head > div:last-child:not(:first-child) {
  padding-top: 1px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-secondary);
  font-weight: 600;
}

.chart-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.chart-legend .legend-item.off {
  opacity: 0.35;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2.5px;
  flex-shrink: 0;
}

.legend-swatch.line { border-radius: 2px; height: 3px; width: 13px; }

/* Grid layouts for sections */

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp-4);
  align-items: stretch;
}

.grid-2-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  align-items: stretch;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

.grid-geo {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: var(--sp-4);
  align-items: stretch;
}

/* Ranked list component */

.ranked-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ranked-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8.5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}

.ranked-row:hover {
  background: var(--surface-2);
}

.ranked-row.active {
  background: var(--accent-wash);
}

.ranked-rank {
  font-size: 10.8px;
  font-weight: 700;
  color: var(--ink-faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ranked-row.active .ranked-rank { color: var(--accent-strong); }

.ranked-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ranked-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.4px;
}

.ranked-name {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranked-value {
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.ranked-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
  position: relative;
}

.ranked-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 0.5s var(--ease);
}

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

.badge {
  font-size: 10.3px;
  font-weight: 700;
  padding: 2.5px 7px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge-neutral { background: var(--surface-2); color: var(--ink-secondary); }
.badge-good { background: var(--good-wash); color: var(--good-ink); }
.badge-warning { background: var(--warning-wash); color: var(--warning-ink); }
.badge-critical { background: var(--critical-wash); color: var(--critical-ink); }

/* Donut + stats layout */

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
}

.donut-chart-el {
  width: 168px;
  height: 168px;
  flex-shrink: 0;
}

.donut-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.method-stat-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}

.method-stat-row:hover { background: var(--surface-2); }
.method-stat-row.active { border-color: var(--accent); background: var(--accent-wash); }

.method-stat-row .dot { width: 8px; height: 8px; border-radius: 2.5px; flex-shrink: 0; }

.method-stat-row .info { flex: 1; min-width: 0; }
.method-stat-row .info .name { font-size: 12.5px; font-weight: 700; }
.method-stat-row .info .detail { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
.method-stat-row .num { text-align: right; }
.method-stat-row .num .val { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.method-stat-row .num .pct { font-size: 10.5px; color: var(--ink-muted); font-variant-numeric: tabular-nums; margin-top: 1px; }

/* Chart canvases (ECharts mount points) */

.echart {
  width: 100%;
  min-width: 0;
}

.echart-trend { height: 296px; }
/* Scatter and Matrix sit side by side in the Profitability section — flex
   sizing (rather than a fixed px height) lets Grid's row-stretch and each
   card's own header height (Matrix carries an extra quadrant-legend row)
   resolve to the same final chart height instead of leaving dead space. */
.echart-scatter, .echart-matrix { flex: 1; min-height: 340px; }

/* Insights */

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-3);
}

.insight-card {
  padding: 15px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}

.insight-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: rgba(11, 11, 11, 0.14);
}

.insight-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.insight-icon svg { width: 16px; height: 16px; }

.insight-icon.tone-good { background: var(--good-wash); color: var(--good-ink); }
.insight-icon.tone-accent { background: var(--accent-wash); color: var(--accent-strong); }
.insight-icon.tone-warning { background: var(--warning-wash); color: var(--warning-ink); }
.insight-icon.tone-critical { background: var(--critical-wash); color: var(--critical-ink); }
.insight-icon.tone-neutral { background: var(--surface-2); color: var(--ink-secondary); }

.insight-body { min-width: 0; }
.insight-title {
  font-size: 12.3px;
  font-weight: 700;
  margin-bottom: 3px;
  letter-spacing: -0.003em;
}
.insight-text { font-size: 12px; color: var(--ink-secondary); line-height: 1.55; }
.insight-text strong { font-weight: 700; color: var(--ink); }

.insight-card.tone-good .insight-text strong { color: var(--good-ink); }
.insight-card.tone-accent .insight-text strong { color: var(--accent-strong); }
.insight-card.tone-warning .insight-text strong { color: var(--warning-ink); }
.insight-card.tone-critical .insight-text strong { color: var(--critical-ink); }

/* Empty state */

.empty-state {
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state .empty-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state svg { width: 20px; height: 20px; opacity: 0.6; }
.empty-state .empty-title { font-size: 12.8px; font-weight: 700; color: var(--ink-secondary); }
.empty-state .empty-sub { font-size: 11.8px; max-width: 320px; }

/* ---------------------------------------------------------------------- */
/* Table                                                                  */
/* ---------------------------------------------------------------------- */

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.table-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 13px;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  transition: border-color var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}

.table-search:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}

.table-search svg { width: 14px; height: 14px; color: var(--ink-muted); flex-shrink: 0; }

.table-search input {
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-family: inherit;
  width: 100%;
}

.table-search input:focus { outline: none; }

.table-meta {
  font-size: 11.8px;
  color: var(--ink-muted);
  white-space: nowrap;
  font-weight: 500;
}

.table-scroll {
  overflow: auto;
  max-height: 560px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.2px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border-strong);
  text-align: left;
  padding: 10px 16px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  color: var(--ink-muted);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: color var(--dur-base) var(--ease);
}

.data-table thead th:hover { color: var(--ink); }

.data-table thead th .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.28;
  font-size: 8.5px;
}

.data-table thead th.sorted { color: var(--ink); }
.data-table thead th.sorted .sort-arrow { opacity: 1; color: var(--accent); }

.data-table tbody td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
  color: var(--ink-secondary);
  font-weight: 500;
}

.data-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 600;
}

.data-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.data-table tbody tr:hover td { background: var(--surface-2); }

.data-table tbody td.cell-high-sales { background: var(--accent-wash); color: var(--accent-strong); font-weight: 700; box-shadow: inset 2px 0 0 var(--accent); }
.data-table tbody td.cell-high-margin { background: var(--good-wash); color: var(--good-ink); font-weight: 700; box-shadow: inset 2px 0 0 var(--good); }
.data-table tbody td.cell-low-margin { background: var(--critical-wash); color: var(--critical-ink); font-weight: 700; box-shadow: inset 2px 0 0 var(--critical); }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 18px;
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 3px;
}

.pagination button {
  border: 1px solid transparent;
  background: transparent;
  width: 27px;
  height: 27px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.pagination button:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.pagination button:disabled { opacity: 0.32; cursor: default; }
.pagination button.active { background: var(--ink); color: #fff; }
.pagination svg { width: 13px; height: 13px; }

.page-size-select { display: flex; align-items: center; gap: 7px; font-size: 11.8px; color: var(--ink-muted); font-weight: 500; }

.legend-note {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 11px;
  color: var(--ink-muted);
  flex-wrap: wrap;
  font-weight: 500;
}

.legend-note .swatch { width: 8px; height: 8px; border-radius: 2.5px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* Tooltip (shared, for HTML components) */

.hover-tooltip {
  position: fixed;
  background: #17171a;
  color: #fff;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 11.6px;
  line-height: 1.55;
  pointer-events: none;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  max-width: 240px;
  opacity: 0;
  transform: translateY(3px) scale(0.98);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.hover-tooltip.visible { opacity: 1; transform: translateY(0) scale(1); }
.hover-tooltip .tt-title { font-weight: 700; margin-bottom: 5px; font-size: 12px; }
.hover-tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: rgba(255,255,255,0.68); }
.hover-tooltip .tt-row b { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Footer */

.app-footer {
  text-align: center;
  padding: 20px 0 28px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.app-footer-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.app-footer-line {
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* ---------------------------------------------------------------------- */
/* Responsive                                                             */
/* ---------------------------------------------------------------------- */

@media (max-width: 1440px) {
  .kpi-grid { grid-template-columns: repeat(6, 1fr); gap: 10px; }
}

@media (max-width: 1400px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-2, .grid-2-equal, .grid-geo { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1280px) {
  .content { padding: var(--sp-6) 24px 56px; }
  .topbar { padding: 13px 24px; }
  .filter-bar { padding: 10px 24px; }
  .exec-summary { padding: 11px 24px; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 48px; }
  .topbar { padding: 12px 16px; }
  .filter-bar { padding: 9px 16px; }
  .exec-summary { padding: 10px 16px; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.44);
    z-index: 39;
    animation: fade-in var(--dur-base) var(--ease);
  }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
  .mobile-menu-btn { display: flex; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: var(--fs-kpi-value-sm); }
  .donut-wrap { flex-direction: column; }
  .topbar-actions .btn span.btn-label { display: none; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .table-search { max-width: none; }
  .exec-summary { flex-direction: column; align-items: flex-start; gap: 10px; }
  .exec-summary-meta { gap: 16px; }
}

/* Print */

@media print {
  .sidebar, .filter-bar, .table-toolbar, .table-footer, .topbar-actions, .mobile-menu-btn, .hover-tooltip, .data-context-panel {
    display: none !important;
  }
  .main { width: 100%; }
  .content { padding: 0 12px; animation: none; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; }

  .exec-summary {
    background: none;
    padding: 8px 12px;
    border-bottom: 1px solid #ccc;
  }
  .exec-summary-text { -webkit-line-clamp: unset; }

  .print-only-summary {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #444;
    padding: 6px 12px 12px;
    border-bottom: 1px solid #ccc;
    margin-bottom: 12px;
  }

  .kpi-spark-wrap, .echart, .donut-chart-el, .insight-card { break-inside: avoid; }
  .app-footer { break-inside: avoid; border-top: 1px solid #ccc; }
}
