:root {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #1d4ed8;
  --primary-light: #dbeafe;
  --emerald: #047857;
  --emerald-light: #d1fae5;
  --amber: #b45309;
  --amber-light: #fef3c7;
  --purple: #6d28d9;
  --purple-light: #ede9fe;
  --rose: #be123c;
  --rose-light: #ffe4e6;
  --shadow-card: 0 6px 20px -4px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --radius-xl: 20px;
  --radius-lg: 14px;
  --font-vi: "Be Vietnam Pro", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-vi);
  background-color: var(--bg-page);
  color: var(--text-main);
  font-size: 16px;
  line-height: 1.5;
  font-feature-settings: "kern" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 48px;
  overflow-x: hidden;
}

/* Thanh tiến trình cuộn trên cùng */
.scroll-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5px;
  background: rgba(226, 232, 240, 0.65);
  z-index: 100;
}

.scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1d4ed8 0%, #0ea5e9 50%, #10b981 100%);
  transition: width 0.08s linear;
}

.app-shell {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Header Kính Mờ Tự Thu Gọn Khi Cuộn (Shrinking Glass Header) */
.top-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 16px 16px 14px;
  transition: padding 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}

.top-header.is-scrolled {
  padding: 10px 16px 10px;
  box-shadow: 0 10px 25px -6px rgba(15, 23, 42, 0.08);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.38;
  color: var(--text-main);
  transition: font-size 0.25s ease;
}

.top-header.is-scrolled .brand-title {
  font-size: 17.5px;
}

.date-pill {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 6px 12px;
  border-radius: 999px;
  line-height: 1.38;
  white-space: nowrap;
}

/* 2 Tab Chiến Dịch Chữ Lớn, Không Icon */
.campaign-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #e2e8f0;
  padding: 5px;
  border-radius: 14px;
  margin-bottom: 10px;
}

.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  min-height: 46px;
  padding: 8px 10px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.38;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.1);
}

/* Bộ Lọc Thời Gian 4 Nút + Chọn Ngày */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.period-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  min-height: 40px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.38;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.period-btn.active {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}

.custom-date-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  gap: 10px;
}

.custom-date-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.42;
  color: var(--text-secondary);
  white-space: nowrap;
}

.custom-date-input {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  border-radius: 8px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  outline: none;
}

/* Nội dung chính */
.main-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.state-box {
  text-align: center;
  padding: 42px 20px;
}

/* Hiệu ứng Motion khi cuộn trên Mobile */
@media (prefers-reduced-motion: no-preference) {
  .reveal-on-scroll {
    opacity: 0;
    transform: translateY(24px) scale(0.985);
    transition: opacity 0.52s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.52s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
  }

  .reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes scrollCardEntry {
      from {
        opacity: 0.15;
        transform: translateY(22px) scale(0.985);
      }
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    .reveal-on-scroll {
      animation: scrollCardEntry linear both;
      animation-timeline: view();
      animation-range: entry 5% cover 22%;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal-on-scroll {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* Banner Tên Chiến Dịch Đang Xem */
.campaign-header-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.campaign-overline {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.campaign-name {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.38;
  color: var(--text-main);
}

.campaign-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 600;
  line-height: 1.45;
}

.status-badge {
  background: var(--emerald-light);
  color: var(--emerald);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.38;
}

/* Thẻ Hero Ngân Sách Đã Tiêu (Navy Gradient Cao Cấp) */
.hero-spend-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #1d4ed8 100%);
  border-radius: var(--radius-xl);
  padding: 24px 22px;
  color: #ffffff;
  box-shadow: 0 14px 30px -8px rgba(29, 78, 216, 0.35);
  position: relative;
  overflow: hidden;
}

.hero-spend-label {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.45;
  color: #93c5fd;
  margin-bottom: 8px;
}

.hero-spend-value {
  font-size: clamp(2.1rem, 1.75rem + 2.2vw, 2.85rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.24;
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}

.hero-spend-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 14px;
  color: #e2e8f0;
  font-weight: 500;
  line-height: 1.45;
}

/* Lưới 4 Chỉ Số KPI Chữ To */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 18px 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: clamp(1.45rem, 1.25rem + 1vw, 1.85rem);
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.28;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

.kpi-value.emerald {
  color: var(--emerald);
}

.kpi-value.amber {
  color: var(--amber);
}

.kpi-foot {
  font-size: 13.5px;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.42;
}

/* Dải Tóm Tắt Điểm Nhấn Khách Hàng (Executive Highlights) */
.highlight-strip {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.highlight-strip-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.45;
  color: var(--primary);
  margin-bottom: 12px;
}

.highlight-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.highlight-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-subtle);
  padding: 12px 14px;
  border-radius: 12px;
  border-left: 4px solid var(--primary);
  gap: 10px;
}

.highlight-item-label {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-secondary);
}

.highlight-item-val {
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.45;
  color: var(--text-main);
  text-align: right;
}

/* Khối Phân Tích & Biểu Đồ Chung */
.section-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 22px 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.42;
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 3px;
  line-height: 1.45;
}

.section-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.38;
}

/* =========================================================================
   BIỂU ĐỒ 1: ĐƯỜNG & VÙNG (SPLINE AREA LINE CHART) XU HƯỚNG THEO NGÀY
   ========================================================================= */
.chart-mode-pills {
  display: inline-flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 10px;
  gap: 4px;
  flex-shrink: 0;
}

.chart-pill {
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.38;
}

.chart-pill.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.area-chart-wrap {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 10px 10px;
  margin-top: 6px;
}

.area-svg {
  width: 100%;
  height: 195px;
  display: block;
  overflow: visible;
}

.area-point-group {
  cursor: pointer;
}

.chart-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.chart-stat-box {
  text-align: center;
}

.chart-stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.42;
}

.chart-stat-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  line-height: 1.38;
}

/* =========================================================================
   BIỂU ĐỒ 2: VÒNG TRÒN (DONUT CHART) GIỚI TÍNH NAM / NỮ
   ========================================================================= */
.donut-layout {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: center;
}

@media (max-width: 390px) {
  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

.donut-chart-box {
  position: relative;
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-svg {
  width: 150px;
  height: 150px;
  transform: rotate(-90deg);
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-center-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.24;
  font-variant-numeric: tabular-nums;
}

.donut-center-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.38;
}

.gender-legend-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.gender-legend-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.gender-legend-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}

.gender-dot-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.42;
}

.color-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
  flex-shrink: 0;
}

.gender-pct-badge {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.38;
}

.gender-pct-badge.rose {
  color: var(--rose);
}

.gender-legend-metrics {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.45;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
}

/* =========================================================================
   BIỂU ĐỒ 3: CỘT ĐỨNG (VERTICAL COLUMN CHART) ĐỘ TUỔI
   ========================================================================= */
.age-column-chart {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 12px 14px;
  margin-bottom: 14px;
}

.age-columns-grid {
  display: grid;
  gap: 8px;
  align-items: end;
  height: 175px;
  padding-top: 28px;
  border-bottom: 1px solid #cbd5e1;
}

.age-col-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.age-col-val {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  line-height: 1.28;
  margin-bottom: 2px;
}

.age-col-pct {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.24;
}

.age-col-bar {
  width: 100%;
  max-width: 44px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #8b5cf6 0%, #6d28d9 100%);
  transition: height 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  min-height: 8px;
}

.age-col-bar.peak {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.28);
}

.age-labels-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  text-align: center;
}

.age-axis-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.38;
}

/* =========================================================================
   BIỂU ĐỒ 4: THANH PHÂN ĐOẠN & TỶ TRỌNG THIẾT BỊ SỬ DỤNG
   ========================================================================= */
.device-stacked-wrap {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.device-stacked-header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.42;
}

.device-stacked-bar {
  height: 18px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  display: flex;
  gap: 2px;
}

.device-seg-primary {
  background: linear-gradient(90deg, #059669 0%, #10b981 100%);
  height: 100%;
}

.device-seg-secondary {
  background: #f59e0b;
  height: 100%;
}

.device-seg-tertiary {
  background: #6366f1;
  height: 100%;
}

/* =========================================================================
   BIỂU ĐỒ 5: XẾP HẠNG NGANG (HORIZONTAL BAR CHART) TỈNH / THÀNH PHỐ
   ========================================================================= */
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.breakdown-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.breakdown-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 8px;
}

.breakdown-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.42;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.breakdown-primary {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.42;
}

.progress-track {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 100%);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-fill.emerald {
  background: linear-gradient(90deg, #047857 0%, #10b981 100%);
}

.progress-fill.purple {
  background: linear-gradient(90deg, #6d28d9 0%, #8b5cf6 100%);
}

.breakdown-metrics {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14.5px;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.45;
}

.breakdown-metrics strong {
  color: var(--text-main);
  font-weight: 700;
}

.expand-btn {
  margin-top: 14px;
  width: 100%;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: var(--bg-subtle);
  color: var(--text-main);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.42;
  cursor: pointer;
  transition: background 0.18s ease;
}

.expand-btn:hover {
  background: #e2e8f0;
}

/* =========================================================================
   THẺ NGÀY XẾP DỌC (DAILY STACKED CARDS - TUYỆT ĐỐI KHÔNG CUỘN NGANG)
   ========================================================================= */
.daily-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.daily-day-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px 16px;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.daily-day-card.selected-day-card {
  border-color: var(--primary);
  background: #f8fbff;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.12);
}

.daily-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.daily-day-date {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.38;
  font-variant-numeric: tabular-nums;
}

.daily-day-contact-badge {
  display: inline-flex;
  align-items: center;
  background: var(--emerald-light);
  color: var(--emerald);
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1.38;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.daily-day-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.daily-metric-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.daily-metric-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.42;
  margin-bottom: 3px;
}

.daily-metric-val {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.38;
  font-variant-numeric: tabular-nums;
}

.daily-metric-val.primary {
  color: var(--primary);
}

.daily-metric-val.amber {
  color: var(--amber);
}
