/* ============================================================
   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-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-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;
}
