/* ==========================================================================
   DYNAMIC ADMIN ANALYTICS - CHARTS, HOURLY BREAKDOWN & 4 KPI PILLARS + CTV %
   ========================================================================== */

.admin-overview-analytics {
  display: grid;
  gap: 16px;
  width: 100%;
  min-width: 0;
  padding: 22px 24px;
  border: 1px solid var(--ddr-border, #e4e4e7);
  border-radius: 18px;
  background: var(--ddr-surface, #ffffff);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
  transition: opacity .2s ease;
}

.admin-overview-analytics.is-loading {
  opacity: 0.65;
}

.admin-overview-analytics.is-loading .admin-analytics-controls {
  opacity: 1;
  pointer-events: auto;
}

/* Header & Controls */
.admin-analytics-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.admin-analytics-badge {
  display: inline-block;
  color: #ef334f;
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.admin-analytics-title-group h2 {
  margin: 0;
  color: var(--ddr-ink, #151519);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
}

.admin-analytics-title-group p {
  margin: 4px 0 0;
  color: var(--ddr-muted, #73737d);
  font-size: 12px;
}

.admin-analytics-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
}

/* Platform Dropdown Selector */
.admin-platform-selector {
  position: relative;
}

.admin-platform-dropdown {
  padding: 6px 12px;
  border-radius: 9px;
  border: 1.5px solid var(--ddr-border, #e4e4e7);
  background: var(--ddr-surface, #ffffff);
  color: var(--ddr-ink, #151519);
  font-size: 11.5px;
  font-weight: 750;
  cursor: pointer;
  outline: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.admin-platform-dropdown:hover,
.admin-platform-dropdown:focus {
  border-color: #ef334f;
  box-shadow: 0 2px 10px rgba(239, 51, 79, 0.12);
}

/* Range Selector Buttons */
.admin-range-selector {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--ddr-surface-2, #f4f4f6);
  border: 1px solid var(--ddr-border, #e4e4e7);
}

.range-btn {
  padding: 5px 11px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ddr-muted, #73737d);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s ease;
}

.range-btn:hover {
  color: var(--ddr-ink, #151519);
}

.range-btn.active {
  background: var(--ddr-surface, #ffffff);
  color: #ef334f;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.admin-date-badge {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--ddr-surface-2, #f4f4f6);
  color: var(--ddr-muted, #73737d);
  font-size: 11px;
  font-weight: 750;
}

/* 4 KPI Summary Cards (Traffic -> Orders -> Ads -> Profit) */
.admin-summary-4cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 106px;
  padding: 16px 18px;
  border: 1px solid var(--ddr-border, #e4e4e7);
  border-radius: 14px;
  background: var(--ddr-surface-2, #f8f8fa);
  transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
}

.stat-card.ads {
  border-color: rgba(245, 158, 11, 0.35);
  background: linear-gradient(145deg, var(--ddr-surface, #ffffff) 0%, rgba(245, 158, 11, 0.06) 100%);
}

.stat-card.profit {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(145deg, var(--ddr-surface, #ffffff) 0%, rgba(16, 185, 129, 0.08) 100%);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ddr-muted, #73737d);
  font-size: 11px;
  font-weight: 750;
}

.stat-card.profit .stat-header {
  align-items: flex-start;
}

.stat-title-profit {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.stat-card.profit .stat-tag {
  flex-shrink: 0;
}

.stat-tag {
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
}

.tag-blue { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.tag-purple { background: rgba(139, 92, 246, 0.14); color: #7c3aed; }
.tag-orange { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.tag-green { background: rgba(16, 185, 129, 0.15); color: #059669; }

.stat-card strong {
  margin: 6px 0 4px;
  color: var(--ddr-ink, #151519);
  font-size: 23px;
  font-weight: 850;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card strong .unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--ddr-muted, #73737d);
}

.stat-card.ads strong {
  color: #d97706;
}

.stat-card.profit strong {
  color: #059669;
}

.stat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
  color: var(--ddr-muted, #73737d);
}

.stat-footer b {
  font-weight: 700;
  color: var(--ddr-ink, #151519);
}

.stat-footer.cost-breakdown {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: space-between;
  gap: 5px;
  white-space: nowrap;
}

/* Analytics Grid Layout */
.admin-analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  gap: 16px;
  min-width: 0;
}

.admin-growth-chart,
.admin-platform-chart {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--ddr-border, #e4e4e7);
  border-radius: 16px;
  background: var(--ddr-surface, #ffffff);
}

.growth-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.growth-chart-header h3,
.admin-platform-chart h3 {
  margin: 0;
  color: var(--ddr-ink, #151519);
  font-size: 14px;
  font-weight: 800;
}

.growth-chart-header p,
.admin-platform-chart p {
  margin: 3px 0 0;
  color: var(--ddr-muted, #73737d);
  font-size: 11px;
}

/* Legend Series Toggles */
.admin-chart-legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.legend-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--ddr-border, #e4e4e7);
  border-radius: 8px;
  background: var(--ddr-surface-2, #f8f8fa);
  color: var(--ddr-muted, #73737d);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.55;
  transition: all .2s ease;
}

.legend-btn:hover {
  opacity: 0.85;
}

.legend-btn.active {
  opacity: 1;
  background: var(--ddr-surface, #ffffff);
  border-color: var(--ddr-ink, #151519);
  color: var(--ddr-ink, #151519);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.legend-btn i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-blue { background: #2563eb; }
.dot-purple { background: #8b5cf6; }
.dot-red { background: #ef4444; }
.dot-green { background: #10b981; }
.dot-orange { background: #f59e0b; }

/* Chart Stage & SVG */
.admin-chart-stage {
  position: relative;
  width: 100%;
  min-height: 230px;
  user-select: none;
}

.admin-dynamic-chart-svg {
  display: block;
  width: 100%;
  height: 230px;
  overflow: visible;
  cursor: crosshair;
}

.grid-line {
  stroke: var(--ddr-border, #e4e4e7);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.zero-line {
  stroke: #ef4444;
  stroke-width: 1.2;
  stroke-dasharray: 5 4;
  opacity: 0.45;
}

.line-traffic {
  fill: none;
  stroke: #2563eb;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-orders {
  fill: none;
  stroke: #8b5cf6;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.line-spend {
  fill: none;
  stroke: #ef4444;
  stroke-width: 2.2;
  stroke-dasharray: 4 3;
  stroke-linecap: round;
}

.line-profit {
  fill: none;
  stroke: #10b981;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-commission {
  fill: none;
  stroke: #f59e0b;
  stroke-width: 2.2;
  stroke-dasharray: 4 3;
  stroke-linecap: round;
}

.chart-crosshair {
  stroke: var(--ddr-ink, #151519);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  opacity: 0.5;
  pointer-events: none;
}

.chart-dot {
  stroke-width: 2.5;
  stroke: #ffffff;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.chart-dot--traffic { fill: #2563eb; }
.chart-dot--orders { fill: #8b5cf6; }
.chart-dot--spend { fill: #ef4444; }
.chart-dot--profit { fill: #10b981; }
.chart-dot--commission { fill: #f59e0b; }

.chart-axis-label {
  fill: var(--ddr-muted, #73737d);
  font-size: 10px;
  font-weight: 650;
  font-family: inherit;
}

/* Floating Rich Tooltip */
.admin-chart-tooltip {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  min-width: 240px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(21, 21, 25, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  transition: opacity .15s ease, transform .15s ease;
}

.tooltip-header {
  font-size: 11px;
  font-weight: 800;
  color: #ff9ca7;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.tooltip-grid {
  display: grid;
  gap: 5px;
}

.tooltip-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
}

.tooltip-item span {
  color: #d1d2d8;
}

.tooltip-item b {
  color: #ffffff;
  font-weight: 800;
}

.tooltip-item.blue b { color: #60a5fa; }
.tooltip-item.purple b { color: #c084fc; }
.tooltip-item.orange b { color: #fbbf24; }
.tooltip-item.green b { color: #34d399; }

.tooltip-item.sub-ctv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 3px 0;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 10px;
  color: #e5e7eb;
}

.tooltip-item.sub {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  font-size: 9.5px;
  color: #9ca3af;
}

/* Donut Chart & Platforms */
.admin-platform-chart > header {
  margin-bottom: 16px;
}

.admin-platform-share {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.admin-donut-wrapper {
  position: relative;
  width: 136px;
  height: 136px;
  display: grid;
  place-items: center;
}

.admin-donut-svg {
  transform: rotate(-90deg);
}

.donut-slice {
  cursor: pointer;
}

.donut-slice.active {
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.3));
}

.admin-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 0 10px;
}

.donut-center-main {
  color: var(--ddr-ink, #151519);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.1;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.donut-center-sub {
  color: var(--ddr-muted, #73737d);
  font-size: 9px;
  font-weight: 700;
  margin-top: 2px;
}

.admin-platform-list {
  display: grid;
  gap: 8px;
  max-height: 200px;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  list-style: none;
}

.platform-row {
  display: grid;
  grid-template-columns: 8px 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease;
}

.platform-row:hover,
.platform-row.active {
  background: var(--ddr-surface-2, #f4f4f6);
}

.platform-row > i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.platform-row > img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #ffffff;
  object-fit: contain;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.platform-row span b {
  display: block;
  color: var(--ddr-ink, #151519);
  font-size: 11px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-row span small {
  display: block;
  color: var(--ddr-muted, #73737d);
  font-size: 9.5px;
}

.platform-row strong {
  color: var(--ddr-ink, #151519);
  font-size: 11px;
  font-weight: 800;
}

.admin-analytics-loading,
.admin-analytics-error,
.admin-platform-empty {
  padding: 32px;
  color: var(--ddr-muted, #73737d);
  text-align: center;
  font-size: 12px;
}

/* Dark Theme Adjustments */
[data-theme="dark"] .admin-overview-analytics {
  border-color: #27272a;
  background: #141418;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .stat-card {
  border-color: #27272a;
  background: #1a1a20;
}

[data-theme="dark"] .stat-card.ads {
  border-color: rgba(245, 158, 11, 0.3);
  background: linear-gradient(145deg, #1a1a20 0%, rgba(245, 158, 11, 0.08) 100%);
}

[data-theme="dark"] .stat-card.profit {
  border-color: rgba(16, 185, 129, 0.3);
  background: linear-gradient(145deg, #1a1a20 0%, rgba(16, 185, 129, 0.1) 100%);
}

[data-theme="dark"] .admin-growth-chart,
[data-theme="dark"] .admin-platform-chart {
  border-color: #27272a;
  background: #18181e;
}

[data-theme="dark"] .admin-platform-dropdown {
  background: #18181e;
  border-color: #27272a;
  color: #f4f4f5;
}

[data-theme="dark"] .admin-range-selector {
  background: #18181e;
  border-color: #27272a;
}

[data-theme="dark"] .range-btn.active {
  background: #27272a;
  color: #ff5f72;
}

[data-theme="dark"] .admin-date-badge {
  background: #18181e;
}

/* Responsive */
@media (max-width: 1140px) {
  .admin-summary-4cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1040px) {
  .admin-analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .admin-overview-analytics {
    padding: 16px;
    border-radius: 14px;
  }

  .admin-analytics-head {
    flex-direction: column;
    gap: 12px;
  }

  .admin-analytics-controls {
    width: 100%;
    justify-content: space-between;
  }

  .admin-summary-4cards {
    grid-template-columns: 1fr;
  }

  .admin-growth-chart,
  .admin-platform-chart {
    padding: 14px;
  }

  .admin-dynamic-chart-svg {
    height: 190px;
  }

  .admin-platform-share {
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 12px;
  }
}


.zero-line-unified {
  stroke: var(--ddr-border, #e4e4e7);
  stroke-width: 1.5;
  opacity: 0.8;
}


.admin-chart-stage {
  position: relative;
  width: 100%;
  min-height: 230px;
  user-select: none;
  overflow: hidden;
}
.admin-dynamic-chart-svg {
  display: block;
  width: 100%;
  height: 230px;
  overflow: hidden;
  cursor: crosshair;
}


/* Fix Tooltip Clipping & Overflow */
.admin-growth-chart {
  overflow: visible !important;
  position: relative;
}

.admin-chart-stage {
  position: relative !important;
  width: 100%;
  min-height: 230px;
  user-select: none;
  overflow: visible !important;
}

.admin-dynamic-chart-svg {
  display: block;
  width: 100%;
  height: 230px;
  overflow: hidden !important;
  border-radius: 12px;
  cursor: crosshair;
}

.admin-chart-tooltip {
  position: absolute;
  z-index: 9999 !important;
  pointer-events: none;
  min-width: 260px;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(18, 18, 22, 0.96) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  transition: opacity .1s ease, transform .1s ease;
}

.tooltip-header {
  font-size: 11.5px;
  font-weight: 800;
  color: #ff8595;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  padding-bottom: 5px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tooltip-grid {
  display: grid;
  gap: 4px;
}

.tooltip-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  line-height: 1.35;
}

.tooltip-item span {
  color: #cbd5e1;
}

.tooltip-item b {
  color: #ffffff;
  font-weight: 800;
}

.tooltip-item.sub-ctv {
  margin: 2px 0;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 10px;
  color: #e2e8f0;
}


/* Side Tabs (Thiết bị / Sàn thương mại) */
.admin-side-chart-header {
  margin-bottom: 12px;
}
.admin-side-tabs {
  display: flex;
  background: #f4f4f5;
  padding: 3px;
  border-radius: 10px;
  gap: 4px;
}
.side-tab-btn {
  flex: 1;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: #71717a;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.side-tab-btn.active {
  background: #ffffff;
  color: #09090b;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.side-tab-desc {
  font-size: 11.5px;
  color: #71717a;
  margin-bottom: 12px;
}

/* Device Breakdown List */
.admin-device-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.device-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #fcfcfd;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  transition: all 0.2s ease;
}
.device-item-row:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}
.device-info-col {
  display: flex;
  align-items: center;
  gap: 10px;
}
.device-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 16px;
}
.device-text-group b {
  display: block;
  font-size: 12.5px;
  font-weight: 750;
  color: #18181b;
}
.device-text-group small {
  font-size: 11px;
  color: #71717a;
}
.device-metric-col {
  text-align: right;
  min-width: 75px;
}
.device-pct-badge {
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 5px;
}
.device-bar-bg {
  width: 100%;
  height: 5px;
  background: #e4e4e7;
  border-radius: 99px;
  overflow: hidden;
}
.device-bar-val {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}


/* Side Column containing Devices and Platforms */
.admin-side-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Device Breakdown Card */
.admin-device-card {
  border: 1px solid var(--ddr-border, #e4e4e7);
  border-radius: 14px;
  background: var(--ddr-surface, #ffffff);
  padding: 16px 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.02);
}

.device-card-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  color: var(--ddr-ink, #151519);
  display: flex;
  align-items: center;
  gap: 6px;
}

.device-card-header p {
  margin: 2px 0 10px;
  font-size: 11px;
  color: var(--ddr-muted, #73737d);
}

.device-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fcfcfd;
  border: 1px solid #f0f0f2;
  border-radius: 10px;
  transition: all 0.15s ease;
}

.device-item-card:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.device-info-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.device-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1;
}

.device-meta-text {
  display: flex;
  flex-direction: column;
}

.device-title {
  font-size: 12px;
  font-weight: 700;
  color: #18181b;
  line-height: 1.2;
}

.device-sub {
  font-size: 10.5px;
  color: #71717a;
}

.device-info-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 70px;
}

.device-pct-text {
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 3px;
}

.device-bar-track {
  width: 65px;
  height: 4.5px;
  background: #e4e4e7;
  border-radius: 99px;
  overflow: hidden;
}

.device-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
}


.admin-growth-chart {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--ddr-border, #e4e4e7);
  border-radius: 16px;
  background: var(--ddr-surface, #ffffff);
  height: 100%;
}

.admin-chart-stage {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  margin-top: 6px;
}

.admin-dynamic-chart-svg {
  width: 100%;
  height: 100%;
  min-height: 330px;
  overflow: visible;
  display: block;
}


/* ==========================================================================
   RICH PLATFORM/BRAND PICKER & CUSTOM DATE RANGE PICKER
   ========================================================================== */

/* Platform Picker Wrap */
.admin-platform-picker-wrap {
  position: relative;
}

.admin-platform-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--ddr-border, #e4e4e7);
  background: var(--ddr-surface, #ffffff);
  color: var(--ddr-ink, #151519);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  outline: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all .2s ease;
}

.admin-platform-picker-btn:hover,
.admin-platform-picker-btn.has-filter {
  border-color: #ef334f;
  background: #fffafa;
  box-shadow: 0 3px 12px rgba(239, 51, 79, 0.14);
}

.picker-btn-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border-radius: 4px;
}

.picker-btn-icon {
  font-size: 15px;
  line-height: 1;
}

.picker-btn-name {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.picker-btn-caret {
  font-size: 10px;
  color: #71717a;
  margin-left: 2px;
}

/* Platform Popover Menu */
.admin-platform-picker-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  max-height: 420px;
  background: #ffffff;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pickerPop .15s ease-out;
}

@keyframes pickerPop {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.picker-search-box {
  padding: 10px 12px;
  border-bottom: 1px solid #f4f4f5;
  background: #fafafa;
}

.picker-search-box input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e4e4e7;
  font-size: 12px;
  outline: none;
  background: #ffffff;
  box-sizing: border-box;
}

.picker-search-box input:focus {
  border-color: #ef334f;
  box-shadow: 0 0 0 2px rgba(239, 51, 79, 0.12);
}

.picker-menu-scroll {
  overflow-y: auto;
  max-height: 340px;
  padding: 6px;
}

.picker-group-title {
  padding: 8px 10px 4px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a1a1aa;
}

.brand-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
}

.brand-picker-item:hover {
  background: #f4f4f5;
}

.brand-picker-item.selected {
  background: #fef2f2;
}

.brand-item-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
  padding: 2px;
  border: 1px solid #e4e4e7;
  flex-shrink: 0;
}

.brand-item-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.brand-item-text {
  flex: 1;
  min-width: 0;
}

.brand-item-text b {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #18181b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-item-text small {
  display: block;
  font-size: 10.5px;
  color: #71717a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-item-check {
  color: #ef334f;
  font-size: 14px;
  font-weight: 800;
}

/* Date Range Picker Button & Popover */
.admin-date-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid #e4e4e7;
  background: #fafafa;
  color: #27272a;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s ease;
}

.admin-date-badge-btn:hover {
  background: #ffffff;
  border-color: #ef334f;
  color: #ef334f;
  box-shadow: 0 2px 8px rgba(239, 51, 79, 0.12);
}

.admin-date-picker-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, calc(100vw - 32px));
  box-sizing: border-box;
  color-scheme: light;
  background: #ffffff;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  animation: pickerPop .15s ease-out;
}

.date-picker-header strong {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #18181b;
}

.date-picker-header p {
  margin: 3px 0 12px;
  font-size: 11px;
  color: #71717a;
}

.date-picker-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.date-input-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.date-input-group label {
  font-size: 11.5px;
  font-weight: 700;
  color: #52525b;
}

.date-input-group input {
  width: 178px;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: #ffffff !important;
  color: #18181b !important;
  -webkit-text-fill-color: #18181b;
  color-scheme: light;
  font-size: 12px;
  outline: none;
}

.date-input-group input:focus {
  border-color: #ef334f;
}

.date-picker-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.date-picker-cancel-btn {
  padding: 6px 12px;
  border: 1px solid #e4e4e7;
  border-radius: 7px;
  background: #ffffff;
  color: #71717a;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.date-picker-apply-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 7px;
  background: #ef334f;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(239, 51, 79, 0.25);
}

.date-picker-apply-btn:hover {
  background: #d6203c;
}

@media (max-width: 640px) {
  .admin-date-picker-popover {
    position: fixed;
    top: 76px;
    right: 16px;
    left: 16px;
    width: auto;
    max-height: calc(100dvh - 92px);
    overflow-y: auto;
  }

  .date-input-group {
    align-items: stretch;
    flex-direction: column;
  }

  .date-input-group input {
    width: 100%;
    min-height: 42px;
  }
}

/* Two-level overview chart: activity above, money below. */
.admin-chart-stage {
  min-height: 420px;
}

.admin-dynamic-chart-svg {
  height: auto;
  min-height: 420px;
  aspect-ratio: 760 / 420;
}

.chart-panel-bg {
  fill: var(--ddr-surface-2, #f8f8fa);
  stroke: var(--ddr-border, #e4e4e7);
  stroke-width: 0.8;
}

.chart-panel-label {
  fill: var(--ddr-muted, #73737d);
  font-family: inherit;
  font-size: 9px;
  font-weight: 800;
}

.chart-section-divider {
  stroke: var(--ddr-border, #e4e4e7);
  stroke-width: 1;
}

.zero-line-unified {
  stroke: var(--ddr-border, #d4d4d8);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.traffic-bar {
  fill: #2563eb;
  fill-opacity: 0.72;
}

.orders-data-dot {
  fill: #8b5cf6;
  stroke: #ffffff;
  stroke-width: 1.5;
}

.finance-profit-area {
  fill: url(#finance-profit-fill);
  pointer-events: none;
}

.line-profit {
  stroke: url(#finance-profit-stroke);
  stroke-width: 2.6;
}

.line-orders,
.line-commission,
.line-spend {
  stroke-width: 2;
}

.platform-row:hover,
.platform-row.active {
  background: rgba(37, 99, 235, 0.055);
}

.donut-slice.active {
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.16));
}

@media (max-width: 720px) {
  .admin-chart-stage {
    min-height: 360px;
  }

  .admin-dynamic-chart-svg {
    min-height: 360px;
  }
}
