/* ────────────── DASHBOARD ────────────── */
.dashboard-view {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-8);
}

/* ── Toolbar ── */
.dash-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.dash-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.dash-range-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
  align-items: center;
}
.dash-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--bg-surface);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) ease;
  font-family: var(--font-body);
}
.dash-chip:hover {
  border-color: rgba(var(--brand-primary-rgb), 0.3);
  color: var(--text-primary);
}
.dash-chip.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}
.dash-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: var(--space-2);
  background: var(--bg-surface);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 50%;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) ease;
}
.dash-refresh:hover {
  border-color: rgba(var(--brand-primary-rgb), 0.3);
  color: var(--brand-primary);
  transform: rotate(90deg);
}

/* ── Card primitive ── */
.dash-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  border: 1px solid rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dash-card h3 {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 var(--space-4);
}
.dash-card.span-2 { grid-column: span 2; }

/* ── KPI grid ── */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.dash-kpi {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-5);
  border: 1px solid rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}
.dash-kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--brand-primary), var(--brand-accent));
  opacity: 0.85;
}
.dash-kpi-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}
.dash-kpi-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.dash-kpi-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ── Chart + lists grids ── */
.dash-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.dash-lists-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}
.dash-card canvas {
  flex: 1;
  min-height: 220px;
  max-height: 280px;
}

/* ── Funnel ── */
.dash-funnel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}
.dash-funnel-row {
  display: grid;
  grid-template-columns: 80px 1fr 60px;
  align-items: center;
  gap: var(--space-3);
}
.dash-funnel-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.dash-funnel-bar-wrap {
  background: rgba(15,23,42,0.04);
  border-radius: 6px;
  height: 22px;
  position: relative;
  overflow: hidden;
}
.dash-funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
  border-radius: 6px;
  transition: width var(--dur-slow) var(--ease-out);
  min-width: 4px;
}
.dash-funnel-count {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* ── List rows (top products, expiring, stale, activity) ── */
.dash-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 calc(-1 * var(--space-2));
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.dash-card-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-2);
  margin-top: var(--space-2);
  border-top: 1px solid rgba(15, 23, 42, 0.05);
}
.dash-see-all {
  background: none;
  border: none;
  color: var(--brand-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  transition: background var(--dur-fast) ease;
}
.dash-see-all:hover { background: rgba(var(--brand-primary-rgb), 0.08); }
.dash-drill-drawer .drawer-body .dash-list { max-height: none; }
.dash-list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) ease;
}
.dash-list-row:hover { background: var(--bg-elevated); }
.dash-list-rank {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
}
.dash-list-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.dash-list-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-list-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-list-value {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-primary);
  flex-shrink: 0;
  white-space: nowrap;
}
.dash-list-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(var(--brand-primary-rgb), 0.1);
  color: var(--brand-primary);
  margin-left: 6px;
}
.dash-list-badge.warn   { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.dash-list-badge.danger { background: rgba(239, 68, 68, 0.15); color: #b91c1c; }

/* ── Insights tile ── */
.dash-insight-row {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.dash-insight-row:last-child { border-bottom: none; }
.dash-insight-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 3px;
}
.dash-insight-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
}

/* ── Empty state ── */
.dash-card-empty {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: var(--space-6) var(--space-3);
}
.dash-empty {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-12) var(--space-6);
  text-align: center;
}
.dash-empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-3);
}
.dash-empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.dash-empty-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-5);
}
.dash-empty .btn-primary {
  display: inline-block;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(var(--brand-primary-rgb), 0.35);
  transition: transform var(--dur-fast) ease;
}
.dash-empty .btn-primary:hover { transform: translateY(-1px); }

/* ── Contact insights card ── */
.dash-customers-card {
  margin-bottom: var(--space-5);
}
.dash-customers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.dash-customers-header h3 {
  margin: 0;
}
.dash-customer-stats {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
}
.dash-cust-stat b {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-primary);
  margin-right: 4px;
}
.dash-cust-row {
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) ease;
}
.dash-cust-row.open {
  background: var(--bg-elevated);
}
.dash-cust-head {
  cursor: pointer;
}
.dash-cust-row .dash-list-row:hover {
  background: var(--bg-elevated);
}
.dash-cust-chev {
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform var(--dur-fast) ease, color var(--dur-fast) ease;
}
.dash-cust-row.open .dash-cust-chev {
  transform: rotate(90deg);
  color: var(--brand-primary);
}
.dash-cust-detail {
  padding: var(--space-3) var(--space-5) var(--space-4) 44px;
  border-top: 1px dashed rgba(15, 23, 42, 0.08);
  margin: 0 var(--space-2);
}
.dash-cust-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.dash-cust-meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}
.dash-cust-meta-value {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.dash-cust-subhead {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin: 0 0 var(--space-2);
}
.dash-cust-prod {
  display: grid;
  grid-template-columns: 1fr 110px 70px 80px;
  align-items: center;
  gap: var(--space-3);
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(15, 23, 42, 0.04);
}
.dash-cust-prod:last-child {
  border-bottom: none;
}
.dash-cust-prod-name {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-cust-prod-sku {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 11px;
  color: var(--text-tertiary);
}
.dash-cust-prod-qty {
  text-align: right;
}
.dash-cust-prod-val {
  text-align: right;
  font-weight: 600;
  color: var(--brand-primary);
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .dash-chart-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-lists-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .dashboard-view { padding: var(--space-4); }
  .dash-chart-grid,
  .dash-lists-grid { grid-template-columns: 1fr; }
  .dash-card.span-2 { grid-column: span 1; }
  .dash-range-chips { margin-left: 0; width: 100%; }
  .dash-cust-meta { grid-template-columns: 1fr; gap: var(--space-2); }
  .dash-cust-prod { grid-template-columns: 1fr auto; row-gap: 2px; }
  .dash-cust-prod-sku,
  .dash-cust-prod-qty { display: none; }
  .dash-cust-detail { padding-left: 16px; padding-right: var(--space-3); }
}
