/**
 * Sales Center shell + Overview — Phase 6A.2.1
 * All rules scoped under #dashboardsView.sales-center-modern.
 * Do not restyle later-tab content, #dashboardView, or other modules.
 * No !important.
 */

#dashboardsView.sales-center-modern {
  --sc-gap: 12px;
  --sc-radius: 8px;
  --sc-control: 40px;
  --sc-touch: 44px;
  --sc-ink: var(--ds-color-ink, var(--ink, #24262d));
  --sc-muted: var(--ds-color-muted, var(--muted, #6b7280));
  --sc-line: var(--ds-color-line, var(--line, #e5e7eb));
  --sc-surface: #fff;
  --sc-surface-quiet: #f8f9fa;
  --sc-accent: var(--ds-color-accent, var(--accent, #0f766e));
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sc-gap);
  padding-bottom: 8px;
}

/* —— Header —— */
#dashboardsView.sales-center-modern .sc-header.dashboards-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 0;
}

#dashboardsView.sales-center-modern .sc-header__copy {
  min-width: 0;
  flex: 1 1 220px;
}

#dashboardsView.sales-center-modern .sc-header__eyebrow.eyebrow {
  margin: 0 0 2px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sc-muted);
  line-height: 1.3;
}

#dashboardsView.sales-center-modern .sc-header__title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--sc-ink);
  line-height: 1.25;
}

#dashboardsView.sales-center-modern .sc-header__sub {
  margin: 4px 0 0;
  font-size: 0.875rem;
  line-height: 1.4;
  max-width: 42rem;
}

#dashboardsView.sales-center-modern .sc-header__actions.view-page-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  flex: 0 0 auto;
}

#dashboardsView.sales-center-modern .sc-header__actions #dashboardRefreshButton {
  min-height: var(--sc-control);
  padding: 0 14px;
  border: 1px solid var(--sc-line);
  border-radius: var(--sc-radius);
  background: var(--sc-surface);
  color: var(--sc-ink);
  box-shadow: none;
  font-weight: 550;
}

/* —— Filter toolbar —— */
#dashboardsView.sales-center-modern .sc-filters.dashboard-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--sc-line);
  border-radius: var(--sc-radius);
  background: var(--sc-surface);
  box-shadow: none;
}

#dashboardsView.sales-center-modern .sc-filters__field.field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 140px;
  max-width: 220px;
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--sc-muted);
  line-height: 1.3;
}

#dashboardsView.sales-center-modern .sc-filters__field .input-select {
  min-height: var(--sc-control);
  width: 100%;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--sc-line);
  border-radius: var(--sc-radius);
  background: var(--sc-surface);
  color: var(--sc-ink);
  font-size: 0.875rem;
  box-shadow: none;
  text-overflow: ellipsis;
}

#dashboardsView.sales-center-modern .sc-filters__apply#dashboardApplyFilters {
  flex: 0 0 auto;
  min-height: var(--sc-control);
  padding: 0 16px;
  border: 1px solid var(--sc-accent);
  border-radius: var(--sc-radius);
  background: var(--sc-accent);
  color: #fff;
  box-shadow: none;
  font-weight: 550;
}

/* —— Alerts (existing states only) —— */
#dashboardsView.sales-center-modern .sc-alerts.dashboard-alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

#dashboardsView.sales-center-modern .sc-alerts .dashboard-alert {
  padding: 8px 12px;
  border-radius: var(--sc-radius);
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* —— Tabs —— */
#dashboardsView.sales-center-modern .sc-tabs.dashboard-tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 2px;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--sc-line);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  max-width: 100%;
}

#dashboardsView.sales-center-modern .sc-tabs .line-tab {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--sc-muted);
  font-size: 0.8125rem;
  font-weight: 550;
  white-space: nowrap;
  line-height: 1.2;
}

#dashboardsView.sales-center-modern .sc-tabs .line-tab.active,
#dashboardsView.sales-center-modern .sc-tabs .line-tab[aria-selected="true"] {
  color: var(--sc-ink);
  border-bottom-color: var(--sc-accent);
  font-weight: 650;
  background: transparent;
}

/* —— Overview KPIs only —— */
#dashboardsView.sales-center-modern .sc-overview-panel {
  min-width: 0;
}

#dashboardsView.sales-center-modern #dashboardSalesKpis.sc-overview-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

#dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile {
  position: relative;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--sc-line);
  border-radius: var(--sc-radius);
  background: var(--sc-surface);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  height: auto;
  background: var(--sc-accent);
}

#dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile:nth-child(4)::before,
#dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile:nth-child(5)::before,
#dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile:nth-child(6)::before {
  background: color-mix(in srgb, var(--sc-accent) 55%, #2563eb);
}

#dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile:nth-child(7)::before {
  background: color-mix(in srgb, var(--sc-accent) 40%, #b45309);
}

#dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile strong {
  display: block;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--sc-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

#dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile span {
  color: var(--sc-muted);
  font-size: 0.75rem;
  font-weight: 550;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#dashboardsView.sales-center-modern #dashboardSalesKpis .dashboard-empty {
  margin: 0;
  padding: 16px 14px;
  border: 1px dashed var(--sc-line);
  border-radius: var(--sc-radius);
  background: var(--sc-surface-quiet);
  color: var(--sc-muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

#dashboardsView.sales-center-modern [data-dashboard-panel="overview"].is-loading #dashboardSalesKpis {
  opacity: 0.55;
}

@media screen and (max-width: 1280px) {
  #dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile strong {
    font-size: 1.15rem;
  }
}

@media screen and (max-width: 1024px) {
  #dashboardsView.sales-center-modern #dashboardSalesKpis.sc-overview-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #dashboardsView.sales-center-modern .sc-filters__field.field-label {
    max-width: none;
    flex: 1 1 160px;
  }
}

@media screen and (max-width: 768px) {
  #dashboardsView.sales-center-modern .sc-header__title {
    font-size: 1.25rem;
  }

  #dashboardsView.sales-center-modern .sc-filters.dashboard-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #dashboardsView.sales-center-modern .sc-filters__field.field-label {
    max-width: none;
    flex: none;
  }

  #dashboardsView.sales-center-modern .sc-filters__apply#dashboardApplyFilters {
    grid-column: 1 / -1;
    justify-self: start;
  }

  #dashboardsView.sales-center-modern #dashboardSalesKpis.sc-overview-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media screen and (max-width: 430px) {
  #dashboardsView.sales-center-modern {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px) + 0.75rem);
  }

  #dashboardsView.sales-center-modern .sc-header__actions #dashboardRefreshButton,
  #dashboardsView.sales-center-modern .sc-filters__apply#dashboardApplyFilters,
  #dashboardsView.sales-center-modern .sc-tabs .line-tab,
  #dashboardsView.sales-center-modern .sc-filters__field .input-select {
    min-height: var(--sc-touch);
  }

  #dashboardsView.sales-center-modern .sc-filters.dashboard-filters {
    grid-template-columns: 1fr;
  }

  #dashboardsView.sales-center-modern .sc-header__actions.view-page-actions {
    width: 100%;
  }

  #dashboardsView.sales-center-modern #dashboardSalesKpis .metric-tile strong {
    font-size: 1.05rem;
  }
}
