/* ============================================================
   Trend Line workspace — Actual vs Target tables (T1..T12 + YTD)
   Visual: deep purple header like Google Sheets mockup,
   alternating row tint, red/green deltas, sticky first column.
   ============================================================ */

#workspace-trend-line {
  padding: 0;
  background: #f8fafc;
}

.tl-shell {
  padding: 16px 24px 32px;
  font-family: inherit;
}

/* ── Header ──────────────────────────────────────────────── */
.tl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 100%);
  color: #fff;
  border-radius: 10px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(76, 29, 149, 0.18);
}
.tl-header-left h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.4px;
}
.tl-header-left .tl-subtitle {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.85;
  font-weight: 500;
}
.tl-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tl-year-picker {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tl-year-picker option { color: #1f2937; }
.tl-meta {
  font-size: 11px;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

/* ── Section block (KPI Tổng quan, Ngành hàng, ...) ─────── */
.tl-block {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px 16px;
  margin-bottom: 16px;
}
.tl-block-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 800;
  color: #4c1d95;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tl-block-title .tl-subhint {
  display: inline-block;
  margin-left: 10px;
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Actual vs Target table ─────────────────────────────── */
.tl-table-wrap {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.tl-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.tl-table thead th {
  background: #4c1d95;
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11.5px;
  letter-spacing: 0.4px;
  padding: 9px 10px;
  border-bottom: 2px solid #3b0764;
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: right;
  white-space: nowrap;
}
.tl-table thead th.tl-col-label {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
}
.tl-table thead th.tl-col-ytd {
  background: #5b21b6;
}
.tl-table thead th.tl-col-mom {
  background: #5b21b6;
}

.tl-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  text-align: right;
  white-space: nowrap;
  color: #1f2937;
}
.tl-table tbody td.tl-cell-label {
  text-align: left;
  font-weight: 600;
  color: #1f2937;
  background: #fff;
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: 1px solid #e5e7eb;
}
.tl-table tbody tr:nth-child(odd) td.tl-cell-label {
  background: #faf5ff;
}
.tl-table tbody tr:nth-child(odd) td {
  background: #faf5ff;
}
.tl-table tbody tr:hover td {
  background: #ede9fe !important;
}

.tl-table .tl-ytd {
  font-weight: 700;
  background: #f5f3ff;
}
.tl-table tbody tr:nth-child(odd) .tl-ytd {
  background: #ede9fe;
}

.tl-cell-pos { color: #047857; font-weight: 600; }
.tl-cell-neg { color: #b91c1c; font-weight: 600; }
.tl-cell-neutral { color: #6b7280; }
.tl-cell-mom { font-weight: 700; }

/* Sub-row tint for derived rows (% Đạt, Gap) — slight italic */
.tl-row-derived td.tl-cell-label {
  font-style: italic;
  color: #4b5563;
  font-weight: 500;
}

/* Loading / error states */
.tl-loading,
.tl-error {
  padding: 24px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}
.tl-error {
  color: #b91c1c;
  background: #fee2e2;
  border-radius: 6px;
}

/* ── Chart cards ─────────────────────────────────────────── */
.tl-chart-main {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px 12px;
  margin-bottom: 14px;
}
.tl-chart-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
  flex-wrap: wrap;
}
.tl-chart-main-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.tl-section-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.tl-chart-range {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: #4b5563;
}
.tl-chart-range label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}
.tl-chart-range input[type="month"] {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}
.tl-chart-range input[type="month"]:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

/* ── Channel time-range bar (đẹp hơn .tl-chart-range cũ) ─────────────── */
.tl-ch-rangebar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 2px 0 12px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 100%);
  border: 1px solid #ede9fe;
  border-radius: 10px;
}
.tl-ch-range-ico { font-size: 15px; line-height: 1; }
.tl-ch-range-lbl {
  font-size: 12px;
  font-weight: 700;
  color: #5b21b6;
  letter-spacing: 0.2px;
}
.tl-ch-range-inputs { display: inline-flex; align-items: center; gap: 6px; }
.tl-ch-range-inputs input[type="month"] {
  font-size: 12px;
  padding: 5px 9px;
  border: 1px solid #ddd6fe;
  border-radius: 7px;
  background: #fff;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  cursor: pointer;
}
.tl-ch-range-inputs input[type="month"]:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}
.tl-ch-range-sep { color: #a78bfa; font-weight: 700; }
.tl-ch-presets { display: inline-flex; gap: 6px; margin-left: auto; }
.tl-ch-preset {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #ddd6fe;
  background: #fff;
  color: #6d28d9;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tl-ch-preset:hover { background: #f5f3ff; }
.tl-ch-preset-active {
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  border-color: #6d28d9;
  color: #fff;
  box-shadow: 0 2px 6px rgba(109, 40, 217, 0.25);
}
.tl-net-warn {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11.5px;
  color: #92400e;
  margin-bottom: 10px;
}
.tl-net-warn code {
  background: rgba(146, 64, 14, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
.tl-chart-sub-hint {
  font-size: 11px;
  color: #6b7280;
  font-style: italic;
}
.tl-netgross-info {
  font-size: 11px;
  color: #4b5563;
  margin: -2px 0 6px;
  padding: 4px 8px;
  background: #f3f4f6;
  border-left: 3px solid #9ca3af;
  border-radius: 3px;
}
.tl-chart-main-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #4c1d95;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tl-kpi-strip {
  display: flex;
  gap: 14px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.tl-kpi-strip-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}
.tl-kpi-strip-label {
  font-size: 10px;
  text-transform: uppercase;
  color: #6b7280;
  letter-spacing: 0.3px;
}
.tl-kpi-strip-value {
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
}
.tl-kpi-strip-value.tl-cell-pos { color: #047857; }
.tl-kpi-strip-value.tl-cell-neg { color: #b91c1c; }

.tl-chart-main-wrap {
  position: relative;
  height: 340px;
}
.tl-chart-main-wrap--split {
  height: 300px;
}

.tl-chart-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}
@media (max-width: 1100px) {
  .tl-chart-split { grid-template-columns: 1fr; }
}
.tl-chart-split-col {
  min-width: 0;
}
.tl-chart-sub-title {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 6px;
}

.tl-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) {
  .tl-mini-grid { grid-template-columns: 1fr; }
}
.tl-mini-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px 10px;
}
.tl-mini-title {
  margin: 0 0 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: #4c1d95;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tl-mini-sub {
  margin: 0 0 8px;
  font-size: 11px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}
.tl-mini-wrap {
  position: relative;
  height: 180px;
}

/* ── Category section ────────────────────────────────────── */
.tl-cat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: #faf5ff;
  border-radius: 8px;
  border: 1px solid #ede9fe;
}
.tl-cat-pill {
  padding: 6px 14px;
  border: 1.5px solid #d4d4d8;
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.tl-cat-pill::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tl-pill-color, #9ca3af);
}
.tl-cat-pill.tl-cat-pill-all::before {
  background: linear-gradient(135deg, #6d28d9 0%, #ec4899 50%, #f97316 100%);
}
.tl-cat-pill:hover {
  border-color: var(--tl-pill-color, #c084fc);
  background: #fef9ff;
  transform: translateY(-1px);
}
.tl-cat-pill-active {
  background: var(--tl-pill-color, #4c1d95);
  border-color: var(--tl-pill-color, #4c1d95);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.tl-cat-pill-active::before {
  background: #fff;
}
.tl-cat-pill-all.tl-cat-pill-active {
  background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 100%);
  border-color: #4c1d95;
}

.tl-cat-chart-wrap {
  position: relative;
  height: 380px;
  margin-bottom: 14px;
}

.tl-cat-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.tl-cat-stat {
  border: 1px solid #e5e7eb;
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.tl-cat-stat:hover {
  background: #faf5ff;
  transform: translateY(-1px);
}
.tl-cat-stat-muted {
  opacity: 0.4;
}
.tl-cat-stat-active {
  background: #faf5ff;
  box-shadow: 0 0 0 2px #c084fc;
}
.tl-cat-stat-name {
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.tl-cat-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.tl-cat-stat-row-label {
  color: #6b7280;
}
.tl-cat-stat-row-value {
  font-weight: 600;
  color: #1f2937;
}
.tl-cat-stat-pct {
  font-size: 14px;
  font-weight: 800;
}
.tl-cat-stat-share {
  font-size: 10.5px;
  color: #6b7280;
}

/* Footer help text */
.tl-footer-note {
  margin-top: 8px;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.5;
}
.tl-footer-note code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: #4c1d95;
}

/* ── ⑤ Team & Saleman ────────────────────────────────────── */
/* Bộ lọc thời gian dùng lại thanh range của Channel (.tl-ch-rangebar) */
/* % đạt target color states */
.tl-pct-good { color: #047857; }
.tl-pct-warn { color: #b45309; }
.tl-pct-bad  { color: #b91c1c; }

/* Overview — team KPI card */
.tl-team-hint {
  font-size: 11.5px;
  color: #6d28d9;
  background: #faf5ff;
  border: 1px dashed #ddd6fe;
  border-radius: 8px;
  padding: 7px 12px;
  margin-bottom: 12px;
  font-weight: 600;
}
.tl-team-card { position: relative; }
.tl-team-pct {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.05;
  margin: 2px 0 6px;
  font-variant-numeric: tabular-nums;
}
.tl-team-pct-lbl {
  font-size: 10.5px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: none;
  letter-spacing: 0;
}
.tl-team-cta {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #6d28d9;
  opacity: 0.75;
  transition: opacity 0.15s, transform 0.15s;
}
.tl-team-card:hover .tl-team-cta { opacity: 1; transform: translateX(2px); }

/* Drill — split layout */
.tl-sm-back {
  border: 1.5px solid #d4d4d8;
  background: #fff;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  color: #4c1d95;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.15s;
}
.tl-sm-back:hover { background: #faf5ff; border-color: #c084fc; transform: translateX(-2px); }

.tl-sm-split {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(220px, 0.9fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .tl-sm-split { grid-template-columns: 1fr; }
  .tl-sm-side { order: -1; }
}

.tl-sm-detail-head {
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.tl-sm-detail-count { font-size: 11px; font-weight: 600; color: #94a3b8; }
.tl-sm-detail-chart { height: 320px; }

/* Right team selector panel */
.tl-sm-side {
  background: #faf5ff;
  border: 1px solid #ede9fe;
  border-radius: 10px;
  padding: 12px;
  position: sticky;
  top: 8px;
}
.tl-sm-side-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #6d28d9;
  margin-bottom: 8px;
}
.tl-sm-team-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.tl-sm-team-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s;
}
.tl-sm-team-btn:hover { border-color: var(--tl-pill-color, #c084fc); background: #fff; transform: translateX(2px); }
.tl-sm-team-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tl-pill-color, #9ca3af); flex: none; }
.tl-sm-team-btn-active {
  border-color: var(--tl-pill-color, #4c1d95);
  background: var(--tl-pill-color, #4c1d95);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.tl-sm-team-btn-active .tl-sm-team-dot { background: #fff; }

.tl-sm-team-summary {
  border-top: 1px solid #ede9fe;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.tl-sm-summary-title {
  font-size: 12px;
  font-weight: 800;
  color: #1f2937;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.tl-sm-team-summary .tl-team-pct { font-size: 22px; margin: 0 0 4px; }
