/* Commercial Report workspace — reuses cp-* classes, only workspace-scoped overrides here. */

#workspace-commercial-report {
  padding: 0;
  background: #f8fafc;
}

#workspace-commercial-report .cp-placeholder {
  background: #fff;
  border-radius: 12px;
  margin: 24px 32px;
  padding: 60px 32px;
}

/* Tab 1 — Commercial Overview */
.cr-overview {
  padding: 0;
}

.cr-overview-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.cr-month-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

.cr-month-picker {
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  background: #fff;
}

.cr-overview-meta {
  margin-left: auto;
  font-size: 12px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

/* KPI MoM delta footer */
.cr-kpi-mom {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}
.cr-delta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cr-delta-up    { color: #059669; }
.cr-delta-down  { color: #dc2626; }
.cr-delta-flat  { color: #6b7280; }
.cr-delta-na    { color: #9ca3af; font-style: italic; }
.cr-mom-vs {
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

/* KPI value unit suffix (L, /L, etc.) */
.cp-kpi-value .cr-unit {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  margin-left: 2px;
}

/* Charts row */
.cr-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
@media (max-width: 1100px) {
  .cr-chart-grid { grid-template-columns: 1fr; }
}

.cr-chart-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cr-chart-title {
  margin: 0 0 10px;
  font-size: 12px;
  color: #1B2A4A;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.cr-chart-wrap {
  position: relative;
  height: 320px;
  flex: 1;
}

/* ─── Insights & Recommendations card ─────────────────────── */
.cr-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);
}
.cr-insights-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}
.cr-insights-title {
  font-size: 13px; font-weight: 700; color: #1B2A4A;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.cr-insights-meta {
  font-size: 10px; color: #94a3b8; font-style: italic;
}
.cr-insights-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
@media (max-width: 900px) {
  .cr-insights-grid { grid-template-columns: 1fr; }
}
.cr-insight-col {
  padding: 12px 14px; border-radius: 8px;
  background: #f8fafc; border-left: 3px solid #94a3b8;
}
.cr-insight-col.findings    { border-left-color: #10b981; background: #f0fdf4; }
.cr-insight-col.issues      { border-left-color: #ef4444; background: #fef2f2; }
.cr-insight-col.recommendations { border-left-color: #3b82f6; background: #eff6ff; }
.cr-insight-h {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 8px; color: #1B2A4A;
}
.cr-insight-list {
  list-style: none; padding: 0; margin: 0;
  font-size: 12px; line-height: 1.55; color: #334155;
}
.cr-insight-list li {
  position: relative; padding: 4px 0 4px 18px;
}
.cr-insight-list li::before {
  content: '•'; position: absolute; left: 4px; color: #94a3b8; font-weight: 700;
}
.cr-insight-col.findings .cr-insight-list li::before { color: #10b981; }
.cr-insight-col.issues .cr-insight-list li::before { color: #ef4444; }
.cr-insight-col.recommendations .cr-insight-list li::before { color: #3b82f6; }
.cr-insight-list li strong { color: #1B2A4A; }
.cr-insight-empty { color: #94a3b8; font-style: italic; font-size: 11px; padding: 4px 0; }

/* Full-width chart card spans both columns */
.cr-chart-card.full {
  grid-column: 1 / -1;
}
.cr-chart-card.full .cr-chart-wrap {
  height: 340px;
}

/* Top products horizontal bar chart — height set dynamically by JS based on row count */
.cr-chart-wrap-top10 {
  height: 460px;
}

/* Waterfall decomposition chart */
.cr-ov-decomp-wrap {
  height: 380px !important;
}

/* Customer health waterfall */
.cr-ov-cflow-wrap {
  height: 380px !important;
}

/* Tab 2 — Channel & Outlet */
.cr-co-top-wrap {
  height: 460px !important;
}

.cr-table-hint {
  font-size: 11px;
  color: #6b7280;
  font-weight: 400;
  margin-left: 6px;
}

.cr-table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.cr-outlet-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.cr-outlet-table thead th.cr-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;
}

.cr-outlet-table thead th.cr-th:hover {
  background: #f1f5f9;
}

.cr-outlet-table thead th.cr-th.sorted {
  background: #e0f2fe;
  color: #0369a1;
}

.cr-outlet-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  white-space: nowrap;
}

.cr-outlet-table tbody td .muted {
  color: #cbd5e1;
}

.cr-outlet-table tbody tr:hover { background: #f9fafb; }

.cr-outlet-table tbody td:nth-child(2) {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   Tab 3 — Brand & Product Portfolio
   ============================================================ */
.cr-chart-hint {
  margin: -6px 0 8px;
  font-size: 11px;
  color: #6b7280;
}

.cr-chart-footer {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
  font-size: 12px;
  color: #475569;
}

.cr-bp-brand-wrap {
  height: 320px !important;
}

/* ABC table */
.cr-abc-table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.cr-abc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.cr-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;
}
.cr-abc-table thead th.cr-num,
.cr-abc-table tbody td.cr-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cr-abc-table thead th.cr-abc-cls,
.cr-abc-table tbody td.cr-abc-cls {
  width: 36px;
  text-align: center;
  padding-right: 4px;
}
.cr-abc-table tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.cr-abc-table tbody tr:hover { background: #f9fafb; }

.cr-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;
}
.cr-abc-badge-A { background: #dc2626; }
.cr-abc-badge-B { background: #f97316; }
.cr-abc-badge-C { background: #94a3b8; }

.cr-abc-row.cr-abc-A td.cr-abc-sku { font-weight: 600; color: #1B2A4A; }
.cr-abc-row.cr-abc-C td { color: #6b7280; }

.cr-abc-sku {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.cr-abc-summary {
  font-size: 12px;
}

/* ============================================================
   Tab 4 — Geography & Sales Team Performance
   ============================================================ */
.cr-gt-heat-wrap {
  height: 540px;
}

.cr-gt-rpo-wrap {
  height: 540px;
}

.cr-gt-conc-wrap {
  height: 380px;
}

.cr-gt-growth-wrap {
  height: 540px;
}

.cr-gt-region-wrap {
  height: 540px;
}

/* Leaderboard table */
.cr-leaderboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.cr-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;
}
.cr-leaderboard-table thead th.cr-num,
.cr-leaderboard-table tbody td.cr-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cr-leaderboard-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.cr-leaderboard-table tbody tr:hover { background: #f9fafb; }

.cr-leaderboard-table .cr-rank {
  font-weight: 700;
  color: #1B2A4A;
  font-size: 14px;
  width: 50px;
}
.cr-leaderboard-table tbody tr:nth-child(1) .cr-rank { color: #D4A843; }
.cr-leaderboard-table tbody tr:nth-child(2) .cr-rank { color: #94a3b8; }
.cr-leaderboard-table tbody tr:nth-child(3) .cr-rank { color: #b45309; }

.cr-sales-name strong {
  font-size: 13px;
  color: #1B2A4A;
}
.cr-sales-sub {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.cr-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.cr-status-ok   { background: #dcfce7; color: #166534; }
.cr-status-late { background: #fee2e2; color: #991b1b; }
.cr-status-na   { background: #f1f5f9; color: #64748b; }

.cr-leaderboard-table sup {
  color: #f59e0b;
  cursor: help;
  margin-left: 2px;
}

.cr-target-amt {
  color: #6b7280;
  font-weight: 400;
  font-size: 10px;
}

.cr-leaderboard-table tbody td .muted {
  color: #cbd5e1;
  font-style: italic;
}

.cr-th-sub {
  font-weight: 400;
  color: #94a3b8;
  font-size: 10px;
}

/* Toggle button for expandable charts */
.cr-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;
}
.cr-toggle-btn:hover {
  background: #1B2A4A;
  color: #fff;
  border-color: #1B2A4A;
}
.cr-toggle-btn:active {
  transform: translateY(1px);
}

/* ============================================================
   Tab 5 — Target vs Actual tables
   ============================================================ */
.cr-ta-block {
  margin-bottom: 24px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px 12px;
}
.cr-ta-title {
  margin: 0 0 12px;
  font-size: 15px;
  color: #1B2A4A;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.cr-ta-wrap {
  overflow-x: auto;
}
.cr-ta-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.cr-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;
}
.cr-ta-table thead th.cr-num,
.cr-ta-table tbody td.cr-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cr-ta-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  white-space: nowrap;
}
.cr-ta-table tbody tr:nth-child(odd) td { background: #fafbfc; }
.cr-ta-table tbody tr:hover td { background: #f0f9ff !important; }

.cr-ta-key {
  font-weight: 600;
  color: #1B2A4A;
}
.cr-ta-table .cr-muted {
  color: #6b7280;
}
.cr-ta-table .cr-ta-total td {
  background: #1B2A4A !important;
  color: #fff !important;
  font-weight: 700;
  border-top: 2px solid #0f1729;
}
.cr-ta-table .cr-ta-total td.cr-muted { color: #cbd5e1 !important; }
.cr-ta-table .cr-ta-total td:first-child { letter-spacing: 0.5px; }

/* ============================================================
   Tab 3 YTD pivot — Ngành × Format × Tháng
   ============================================================ */
.cr-bp-pivot-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.cr-bp-pivot {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.cr-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;
}
.cr-bp-pivot thead th.cr-pivot-rowlabel {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 160px;
}
.cr-bp-pivot thead th.cr-pivot-sub-h {
  background: #2d3e5f;
  font-size: 11px;
  font-weight: 500;
}
.cr-bp-pivot thead th.cr-pivot-grand-h {
  background: #D4A843;
  color: #1B2A4A;
}
.cr-bp-pivot thead th.cr-pivot-month-h {
  letter-spacing: 0.5px;
}
.cr-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;
}
.cr-bp-pivot tbody td.cr-pivot-rowlabel {
  text-align: left;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
  font-weight: 500;
  border-right: 1px solid #e5e7eb;
}
.cr-bp-pivot tbody td.cr-num {
  text-align: right;
}
.cr-bp-pivot tbody td.cr-muted {
  color: #6b7280;
  font-size: 11px;
}
.cr-bp-pivot tbody tr:hover td {
  background: #f0f9ff;
}
.cr-bp-pivot tbody tr:hover td.cr-pivot-rowlabel {
  background: #e0f2fe;
}
.cr-bp-pivot tbody tr.cr-pivot-cat td {
  background: #e0f2fe;
  font-weight: 700;
  color: #1B2A4A;
  border-top: 1px solid #93c5fd;
}
.cr-bp-pivot tbody tr.cr-pivot-cat td.cr-pivot-rowlabel {
  background: #bae6fd;
}
.cr-bp-pivot tbody tr.cr-pivot-fmt td.cr-pivot-rowlabel {
  padding-left: 24px;
  font-weight: 500;
  color: #475569;
}
.cr-bp-pivot tbody td.cr-pivot-grand {
  background: #fef9e7 !important;
  font-weight: 600;
}
.cr-bp-pivot tbody tr.cr-pivot-total td {
  background: #1B2A4A !important;
  color: #fff !important;
  font-weight: 700;
  border-top: 2px solid #0f1729;
}
.cr-bp-pivot tbody tr.cr-pivot-total td.cr-pivot-rowlabel {
  background: #1B2A4A !important;
}
