/* Commercial Report workspace — reuses cp-* classes, only workspace-scoped overrides here. */

#workspace-commercial-report-copy {
  padding: 0;
  background: #f8fafc;
}

#workspace-commercial-report-copy .cp-placeholder {
  background: #fff;
  border-radius: 12px;
  margin: 24px 32px;
  padding: 60px 32px;
}

/* Tab 1 — Commercial Overview */
.crc-overview {
  padding: 0;
}

.crc-overview-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.crc-month-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

.crc-month-picker {
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  background: #fff;
}

.crc-overview-meta {
  margin-left: auto;
  font-size: 12px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

/* KPI MoM delta footer */
.crc-kpi-mom {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}
.crc-delta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.crc-delta-up    { color: #059669; }
.crc-delta-down  { color: #dc2626; }
.crc-delta-flat  { color: #6b7280; }
.crc-delta-na    { color: #9ca3af; font-style: italic; }
.crc-mom-vs {
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

/* KPI value unit suffix (L, /L, etc.) */
.cp-kpi-value .crc-unit {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  margin-left: 2px;
}

/* Charts row */
.crc-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
@media (max-width: 1100px) {
  .crc-chart-grid { grid-template-columns: 1fr; }
}

.crc-chart-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.crc-chart-title {
  margin: 0 0 10px;
  font-size: 12px;
  color: #1B2A4A;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.crc-chart-wrap {
  position: relative;
  height: 320px;
  flex: 1;
}

/* ─── Waterfall drill panel ─────────────────────────────── */
.crc-decomp-drill {
  margin-top: 14px;
  border-top: 1px dashed #cbd5e1;
  padding-top: 14px;
}
.crc-decomp-drill[hidden] {
  display: none;
}
.crc-decomp-drill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.crc-decomp-drill-title {
  font-size: 13px;
  color: #1B2A4A;
}
.crc-decomp-drill-close {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  color: #475569;
}
.crc-decomp-drill-close:hover {
  background: #f1f5f9;
  color: #1B2A4A;
}
.crc-decomp-drill-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 1200px) {
  .crc-decomp-drill-grid { grid-template-columns: 1fr; }
}
.crc-decomp-drill-col {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
}
/* Outlet column scrolls internally — visible region shows ~10 bars, scroll for more.
   Column header (h4 + hint) stays sticky at the top so user always sees count/title. */
.crc-decomp-drill-col-outlet {
  max-height: 380px;
  overflow-y: auto;
}
.crc-decomp-drill-col-outlet > h4,
.crc-decomp-drill-col-outlet > .crc-decomp-drill-hint {
  position: sticky;
  background: #f8fafc;
  z-index: 1;
  margin-top: 0;
}
.crc-decomp-drill-col-outlet > h4 { top: 0; }
.crc-decomp-drill-col-outlet > .crc-decomp-drill-hint { top: 28px; }
.crc-decomp-drill-col-outlet .crc-decomp-drill-chart {
  /* let inline-set height from JS take effect (full N × pxPerRow) */
  height: auto;
}
.crc-decomp-drill-col h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #1B2A4A;
}
.crc-decomp-drill-chart {
  position: relative;
  height: 280px;
}

/* ─── Insights & Recommendations card ─────────────────────── */
.crc-insights-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 18px 22px;
  margin-top: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.crc-insights-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}
.crc-insights-title {
  font-size: 13px; font-weight: 700; color: #1B2A4A;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.crc-insights-meta {
  font-size: 10px; color: #94a3b8; font-style: italic;
}
.crc-insights-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
@media (max-width: 900px) {
  .crc-insights-grid { grid-template-columns: 1fr; }
}
.crc-insight-col {
  padding: 12px 14px; border-radius: 8px;
  background: #f8fafc; border-left: 3px solid #94a3b8;
}
.crc-insight-col.findings    { border-left-color: #10b981; background: #f0fdf4; }
.crc-insight-col.issues      { border-left-color: #ef4444; background: #fef2f2; }
.crc-insight-col.recommendations { border-left-color: #3b82f6; background: #eff6ff; }
.crc-insight-h {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 8px; color: #1B2A4A;
}
.crc-insight-list {
  list-style: none; padding: 0; margin: 0;
  font-size: 12px; line-height: 1.55; color: #334155;
}
.crc-insight-list li {
  position: relative; padding: 4px 0 4px 18px;
}
.crc-insight-list li::before {
  content: '•'; position: absolute; left: 4px; color: #94a3b8; font-weight: 700;
}
.crc-insight-col.findings .crc-insight-list li::before { color: #10b981; }
.crc-insight-col.issues .crc-insight-list li::before { color: #ef4444; }
.crc-insight-col.recommendations .crc-insight-list li::before { color: #3b82f6; }
.crc-insight-list li strong { color: #1B2A4A; }
.crc-insight-empty { color: #94a3b8; font-style: italic; font-size: 11px; padding: 4px 0; }

/* Full-width chart card spans both columns */
.crc-chart-card.full {
  grid-column: 1 / -1;
}
.crc-chart-card.full .crc-chart-wrap {
  height: 340px;
}

/* Top products horizontal bar chart — height set dynamically by JS based on row count */
.crc-chart-wrap-top10 {
  height: 460px;
}

/* Waterfall decomposition chart */
.crc-ov-decomp-wrap {
  height: 380px !important;
}

/* Customer health waterfall */
.crc-ov-cflow-wrap {
  height: 380px !important;
}

/* Tab 2 — Channel & Outlet */
.crc-co-top-wrap {
  height: 460px !important;
}

.crc-table-hint {
  font-size: 11px;
  color: #6b7280;
  font-weight: 400;
  margin-left: 6px;
}

.crc-table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.crc-outlet-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.crc-outlet-table thead th.crc-th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  padding: 9px 12px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.crc-outlet-table thead th.crc-th:hover {
  background: #f1f5f9;
}

.crc-outlet-table thead th.crc-th.sorted {
  background: #e0f2fe;
  color: #0369a1;
}

.crc-outlet-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  white-space: nowrap;
}

.crc-outlet-table tbody td .muted {
  color: #cbd5e1;
}

.crc-outlet-table tbody tr:hover { background: #f9fafb; }

.crc-outlet-table tbody td:nth-child(2) {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   Tab 3 — Brand & Product Portfolio
   ============================================================ */
.crc-chart-hint {
  margin: -6px 0 8px;
  font-size: 11px;
  color: #6b7280;
}

.crc-chart-footer {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
  font-size: 12px;
  color: #475569;
}

.crc-bp-brand-wrap {
  height: 320px !important;
}

/* ABC table */
.crc-abc-table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.crc-abc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.crc-abc-table thead th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
}
.crc-abc-table thead th.crc-num,
.crc-abc-table tbody td.crc-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.crc-abc-table thead th.crc-abc-cls,
.crc-abc-table tbody td.crc-abc-cls {
  width: 36px;
  text-align: center;
  padding-right: 4px;
}
.crc-abc-table tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.crc-abc-table tbody tr:hover { background: #f9fafb; }

.crc-abc-badge {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  text-align: center;
}
.crc-abc-badge-A { background: #dc2626; }
.crc-abc-badge-B { background: #f97316; }
.crc-abc-badge-C { background: #94a3b8; }

.crc-abc-row.crc-abc-A td.crc-abc-sku { font-weight: 600; color: #1B2A4A; }
.crc-abc-row.crc-abc-C td { color: #6b7280; }

.crc-abc-sku {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.crc-abc-summary {
  font-size: 12px;
}

/* ============================================================
   Tab 4 — Geography & Sales Team Performance
   ============================================================ */
.crc-gt-heat-wrap {
  height: 540px;
}

.crc-gt-rpo-wrap {
  height: 540px;
}

.crc-gt-conc-wrap {
  height: 380px;
}

.crc-gt-growth-wrap {
  height: 540px;
}

.crc-gt-region-wrap {
  height: 540px;
}

/* Leaderboard table */
.crc-leaderboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.crc-leaderboard-table thead th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  padding: 9px 12px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  white-space: nowrap;
}
.crc-leaderboard-table thead th.crc-num,
.crc-leaderboard-table tbody td.crc-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.crc-leaderboard-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.crc-leaderboard-table tbody tr:hover { background: #f9fafb; }

.crc-leaderboard-table .crc-rank {
  font-weight: 700;
  color: #1B2A4A;
  font-size: 14px;
  width: 50px;
}
.crc-leaderboard-table tbody tr:nth-child(1) .crc-rank { color: #D4A843; }
.crc-leaderboard-table tbody tr:nth-child(2) .crc-rank { color: #94a3b8; }
.crc-leaderboard-table tbody tr:nth-child(3) .crc-rank { color: #b45309; }

.crc-sales-name strong {
  font-size: 13px;
  color: #1B2A4A;
}
.crc-sales-sub {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.crc-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.crc-status-ok   { background: #dcfce7; color: #166534; }
.crc-status-late { background: #fee2e2; color: #991b1b; }
.crc-status-na   { background: #f1f5f9; color: #64748b; }

.crc-leaderboard-table sup {
  color: #f59e0b;
  cursor: help;
  margin-left: 2px;
}

.crc-target-amt {
  color: #6b7280;
  font-weight: 400;
  font-size: 10px;
}

.crc-leaderboard-table tbody td .muted {
  color: #cbd5e1;
  font-style: italic;
}

.crc-th-sub {
  font-weight: 400;
  color: #94a3b8;
  font-size: 10px;
}

/* Toggle button for expandable charts */
.crc-toggle-btn {
  margin-left: 12px;
  padding: 4px 12px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  color: #1B2A4A;
  cursor: pointer;
  vertical-align: middle;
  transition: all .15s ease;
  font-family: inherit;
}
.crc-toggle-btn:hover {
  background: #1B2A4A;
  color: #fff;
  border-color: #1B2A4A;
}
.crc-toggle-btn:active {
  transform: translateY(1px);
}

/* ============================================================
   Tab 5 — Target vs Actual tables
   ============================================================ */
.crc-ta-block {
  margin-bottom: 24px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px 12px;
}
.crc-ta-title {
  margin: 0 0 12px;
  font-size: 15px;
  color: #1B2A4A;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.crc-ta-wrap {
  overflow-x: auto;
}
.crc-ta-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.crc-ta-table thead th {
  background: #1B2A4A;
  color: #fff;
  padding: 10px 14px;
  font-weight: 600;
  text-align: left;
  border-bottom: 2px solid #0f1729;
  white-space: nowrap;
}
.crc-ta-table thead th.crc-num,
.crc-ta-table tbody td.crc-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.crc-ta-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  white-space: nowrap;
}
.crc-ta-table tbody tr:nth-child(odd) td { background: #fafbfc; }
.crc-ta-table tbody tr:hover td { background: #f0f9ff !important; }

.crc-ta-key {
  font-weight: 600;
  color: #1B2A4A;
}
.crc-ta-table .crc-muted {
  color: #6b7280;
}
.crc-ta-table .crc-ta-total td {
  background: #1B2A4A !important;
  color: #fff !important;
  font-weight: 700;
  border-top: 2px solid #0f1729;
}
.crc-ta-table .crc-ta-total td.crc-muted { color: #cbd5e1 !important; }
.crc-ta-table .crc-ta-total td:first-child { letter-spacing: 0.5px; }

/* ============================================================
   Tab 3 YTD pivot — Ngành × Format × Tháng
   ============================================================ */
.crc-bp-pivot-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.crc-bp-pivot {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.crc-bp-pivot thead th {
  background: #1B2A4A;
  color: #fff;
  padding: 6px 10px;
  font-weight: 600;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,0.1);
  border-bottom: 2px solid #0f1729;
  white-space: nowrap;
}
.crc-bp-pivot thead th.crc-pivot-rowlabel {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 160px;
}
.crc-bp-pivot thead th.crc-pivot-sub-h {
  background: #2d3e5f;
  font-size: 11px;
  font-weight: 500;
}
.crc-bp-pivot thead th.crc-pivot-grand-h {
  background: #D4A843;
  color: #1B2A4A;
}
.crc-bp-pivot thead th.crc-pivot-month-h {
  letter-spacing: 0.5px;
}
.crc-bp-pivot tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #f3f4f6;
  border-right: 1px solid #f3f4f6;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.crc-bp-pivot tbody td.crc-pivot-rowlabel {
  text-align: left;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
  font-weight: 500;
  border-right: 1px solid #e5e7eb;
}
.crc-bp-pivot tbody td.crc-num {
  text-align: right;
}
.crc-bp-pivot tbody td.crc-muted {
  color: #6b7280;
  font-size: 11px;
}
.crc-bp-pivot tbody tr:hover td {
  background: #f0f9ff;
}
.crc-bp-pivot tbody tr:hover td.crc-pivot-rowlabel {
  background: #e0f2fe;
}
.crc-bp-pivot tbody tr.crc-pivot-cat td {
  background: #e0f2fe;
  font-weight: 700;
  color: #1B2A4A;
  border-top: 1px solid #93c5fd;
}
.crc-bp-pivot tbody tr.crc-pivot-cat td.crc-pivot-rowlabel {
  background: #bae6fd;
}
.crc-bp-pivot tbody tr.crc-pivot-fmt td.crc-pivot-rowlabel {
  padding-left: 24px;
  font-weight: 500;
  color: #475569;
}
.crc-bp-pivot tbody td.crc-pivot-grand {
  background: #fef9e7 !important;
  font-weight: 600;
}
.crc-bp-pivot tbody tr.crc-pivot-total td {
  background: #1B2A4A !important;
  color: #fff !important;
  font-weight: 700;
  border-top: 2px solid #0f1729;
}
.crc-bp-pivot tbody tr.crc-pivot-total td.crc-pivot-rowlabel {
  background: #1B2A4A !important;
}
