.modal-backdrop:has(.chart-modal) {
  padding: 24px;
  background: rgba(15, 23, 42, .34);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal.chart-modal {
  display: flex;
  flex-direction: column;
  width: min(1360px, 100%);
  height: 92dvh;
  max-height: calc(100dvh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid #eef0f4;
  border-radius: 28px;
  color: #111827;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .2);
}

.chart-modal > .modal-header {
  flex: 0 0 auto;
  align-items: center;
  gap: 24px;
  margin: 0;
  padding: 28px 32px;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
}

.chart-modal-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.chart-modal .modal-header h2 {
  margin: 0;
  color: #111827;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -1.1px;
  text-transform: none;
}

.chart-modal .chart-modal-subtitle {
  margin: 5px 0 0;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.5;
}

.chart-modal-actions {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.chart-modal-actions:empty { display: none; }

.chart-modal .modal-header > .icon-button {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid #edf0f3;
  border-radius: 17px;
  background: #fff;
  color: #475569;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.chart-modal .modal-header > .icon-button:hover {
  background: #f8fafc;
  color: #111827;
}

.chart-modal > .modal-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  min-height: 0;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.chart-modal .expanded-chart,
.dash-detail-section {
  flex: 0 0 auto;
  min-width: 0;
  border: 1px solid #f0f2f5;
  border-radius: 18px;
  background: #fff;
}

.chart-modal .expanded-chart { overflow: hidden; }
.chart-modal .expanded-chart-revenue .dash-chart-body { padding: 28px 18px 16px; }
.chart-modal .expanded-chart-revenue .dash-revenue-svg { min-height: 330px; max-height: 460px; }
.chart-modal .expanded-chart-revenue .dash-chart-summary { padding: 20px 24px; }
.chart-modal .expanded-chart-revenue .dash-chart-summary strong { font-size: 19px; }
.chart-modal .expanded-chart-composition .dash-composition-legend { padding: 22px 28px 8px; }
.chart-modal .expanded-chart-composition .dash-waterfall { height: 310px; }
.chart-modal .expanded-chart-composition .dash-composition-footer { padding: 24px 28px; }
.chart-modal .expanded-chart-integrations { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 24px; padding: 24px; }
.chart-modal .expanded-chart-integrations .dash-donut-wrap { width: min(360px, 100%); height: auto; aspect-ratio: 1; margin: 0 auto; }
.chart-modal .expanded-chart-integrations .dash-donut-center strong { font-size: 42px; }
.chart-modal .expanded-chart-integrations .dash-donut-center span { font-size: 12px; }
.chart-modal .expanded-chart-integrations .dash-integration-list { padding: 20px 12px; gap: 18px; }
.chart-modal .expanded-chart-integrations .dash-integration-list > div { gap: 12px; font-size: 12px; }
.chart-modal .expanded-chart-integrations .dash-integration-list > div > span:nth-child(2) { white-space: normal; }
.chart-modal .expanded-chart-integrations .dash-integration-list strong { font-size: 12px; }
.chart-modal .expanded-chart-hours { border: 0; overflow: visible; }

.dash-detail-section {
  padding: 26px 30px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .02);
}

.dash-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.dash-detail-head > div { min-width: 0; }
.dash-detail-head .dash-detail-title { margin: 0; color: #111827; font-size: 17px; font-weight: 750; line-height: 1.4; letter-spacing: -.4px; }
.dash-detail-head .dash-detail-subtitle { margin: 4px 0 0; color: #94a3b8; font-size: 12px; line-height: 1.5; }
.dash-detail-head .dash-detail-kicker { display: block; margin: 0 0 7px; color: #94a3b8; font-size: 10px; font-weight: 750; line-height: 1.3; letter-spacing: .04em; text-transform: uppercase; }
.dash-detail-count { flex: 0 0 auto; padding: 4px 12px; border: 1px solid #e9edf2; border-radius: 999px; color: #475569; font-size: 11px; font-weight: 550; line-height: 1.5; white-space: nowrap; background: #fff; }
.dash-detail-table-scroll { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; }
.dash-detail-table { width: 100%; border-collapse: collapse; color: #334155; font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.dash-detail-table thead th { padding: 12px; border-bottom: 1px solid #e2e8f0; background: #f6f6f7; color: #64748b; font-size: 11px; font-weight: 650; text-align: right; white-space: nowrap; }
.dash-detail-table tbody th,
.dash-detail-table td { padding: 12px; border-bottom: 1px solid #eef2f6; background: transparent; text-align: right; vertical-align: middle; white-space: nowrap; }
.dash-detail-table tbody th { color: #111827; font-size: inherit; font-weight: 650; }
.dash-detail-table th:first-child,
.dash-detail-table td:first-child { text-align: left; }
.dash-detail-table td:first-child { color: #111827; font-weight: 650; }
.dash-detail-table tbody tr:last-child th,
.dash-detail-table tbody tr:last-child td { border-bottom: 0; }
.dash-detail-table tbody tr:hover { background: #fafbfd; }
.dash-detail-table .dash-detail-cell-main { color: #111827; font-weight: 600; }
.dash-detail-cell-sub { display: inline-block; margin-left: 8px; color: #94a3b8; font-size: 10px; font-weight: 500; vertical-align: middle; }
.dash-detail-badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 4px; color: #64748b; background: #f8fafc; font-size: 10px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.dash-detail-table .dash-detail-positive { color: #059669; }
.dash-detail-table .dash-detail-negative { color: #e11d48; }
.dash-detail-table .dash-detail-neutral { color: #64748b; }
.dash-detail-badge.dash-detail-positive { color: #047857; background: #ecfdf5; }
.dash-detail-badge.dash-detail-negative { color: #be123c; background: #fff1f2; }
.dash-detail-badge.dash-detail-neutral { color: #64748b; background: #f1f5f9; }
.dash-detail-badge.dash-detail-revenue { color: #4338ca; background: #eef2ff; }
.dash-detail-channel { display: flex; align-items: center; gap: 9px; }
.dash-detail-dot { display: inline-block; flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--detail-color, #94a3b8); }
.dash-detail-marketplace { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; padding: 2px 5px; border-radius: 4px; color: #64748b; background: #f1f5f9; font-size: 9px; font-weight: 750; line-height: 1.4; }
.dash-detail-name { color: #111827; font-weight: 650; }
.dash-detail-empty { padding: 28px 12px !important; color: #94a3b8 !important; text-align: center !important; font-weight: 500 !important; white-space: normal !important; }
.dash-detail-caption { position: absolute; width: 1px; height: 1px; overflow: hidden; padding: 0; margin: -1px; border: 0; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.dash-hour-detail-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.dash-hour-detail-stat { position: relative; isolation: isolate; min-width: 0; overflow: hidden; padding: 22px 24px; border: 1px solid #eef1f5; border-radius: 18px; background: #fff; box-shadow: 0 2px 2px rgba(15, 23, 42, .025); }
.dash-hour-detail-stat::after { content: ''; position: absolute; z-index: -1; width: 80px; height: 80px; top: 0; right: 0; border-bottom-left-radius: 44px; background: #f5f4ff; }
.dash-hour-detail-stat--peak::after { background: #fdf3f8; }
.dash-hour-detail-stat--revenue::after { background: #f1faf6; }
.dash-hour-detail-stat-label { display: flex; align-items: center; gap: 5px; color: #94a3b8; font-size: 11px; line-height: 1.5; }
.dash-hour-detail-stat-label svg { flex: 0 0 auto; color: #6475e8; }
.dash-hour-detail-stat--peak .dash-hour-detail-stat-label svg { color: #c0267d; }
.dash-hour-detail-stat--revenue .dash-hour-detail-stat-label svg { color: #059669; }
.dash-hour-detail-stat-value { display: block; margin-top: 4px; color: #111827; font-size: clamp(25px, 2.5vw, 36px); font-weight: 800; line-height: 1.25; letter-spacing: -1.15px; white-space: nowrap; }
.dash-hour-detail-stat--peak .dash-hour-detail-stat-value { color: #c0267d; }
.chart-modal .dash-hour-detail-stat-note { margin: 14px 0 0; color: #94a3b8; font-size: 11px; line-height: 1.5; }
.dash-hour-detail-stat-note strong,
.dash-hour-detail-stat-note b { color: #334155; font-weight: 650; }
.dash-hour-detail-stat--peak .dash-hour-detail-stat-note,
.dash-hour-detail-stat--peak .dash-hour-detail-stat-note strong { color: #c0267d; }
.dash-hour-detail-chart { min-width: 0; padding: 24px 28px 18px; border: 1px solid #eef1f5; border-radius: 18px; background: #fff; }
.dash-hour-detail-chart-head { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid #f1f5f9; }
.dash-hour-detail-toggle { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid #eeecf0; border-radius: 9px; background: #f4f0f4; }
.dash-hour-detail-toggle button { padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: #8b8590; font: inherit; font-size: 11px; font-weight: 650; cursor: pointer; }
.dash-hour-detail-toggle button.is-active { color: #292329; background: #fff; box-shadow: 0 2px 6px rgba(20, 12, 19, .08); }
.dash-hour-detail-toggle button:focus-visible { outline: 3px solid #c7d2fe; outline-offset: 2px; }
.dash-hour-detail-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; padding: 7px 12px; border: 1px solid #f1f5f9; border-radius: 999px; color: #64748b; background: #fbfcfe; font-size: 10px; font-weight: 600; }
.dash-hour-detail-legend > span { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.dash-hour-detail-legend i { display: inline-block; width: 18px; height: 0; border-top: 3px solid #3154ff; border-radius: 3px; }
.dash-hour-detail-legend .dash-hour-detail-legend-previous i { border-top: 2px dashed #94a3b8; border-radius: 0; }
.dash-hour-detail-range { margin-left: auto; color: #94a3b8; font-size: 10px; white-space: nowrap; }
.dash-hour-detail-plot-scroll { min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; padding-top: 18px; }
.dash-hour-detail-svg { display: block; width: 100%; min-width: 800px; height: auto; max-height: 440px; }
.dash-hour-detail-axis { fill: #94a3b8; font-family: inherit; font-size: 11px; }
.dash-hour-detail-axis text { fill: #94a3b8; }
.dash-hour-detail-zero { stroke: #b8c3d2; }
.chart-modal .dash-hour-detail-empty { margin: 10px 0 0; color: #94a3b8; font-size: 12px; text-align: center; }

@media (max-width: 1100px) {
  .chart-modal > .modal-header { flex-wrap: wrap; gap: 14px; padding: 22px 24px; }
  .chart-modal .modal-header h2 { font-size: 26px; }
  .chart-modal-actions { order: 3; flex: 1 0 100%; justify-content: flex-start; }
  .chart-modal-actions .dash-chart-controls { justify-content: flex-start; }
  .chart-modal > .modal-body { padding: 20px; }
  .dash-detail-section { padding: 24px 20px; }
  .dash-hour-detail-stat { padding: 20px 16px; }
  .dash-hour-detail-stat-value { font-size: 26px; }
  .dash-hour-detail-range { flex-basis: 100%; margin-left: 0; }
}

@media (max-width: 700px) {
  .modal-backdrop:has(.chart-modal) { padding: 10px; }
  .modal.chart-modal { height: calc(100dvh - 20px); max-height: calc(100dvh - 20px); border-radius: 20px; }
  .chart-modal > .modal-header { gap: 12px; padding: 18px; }
  .chart-modal .modal-header h2 { font-size: 22px; letter-spacing: -.7px; }
  .chart-modal .chart-modal-subtitle { font-size: 11px; }
  .chart-modal .modal-header > .icon-button { flex-basis: 36px; width: 36px; height: 36px; border-radius: 12px; }
  .chart-modal > .modal-body { gap: 18px; padding: 14px; }
  .chart-modal-actions .dash-series { font-size: 9px; }
  .chart-modal .expanded-chart-revenue .dash-chart-body { overflow-x: auto; padding: 18px 6px; }
  .chart-modal .expanded-chart-revenue .dash-revenue-svg { min-width: 600px; min-height: 240px; }
  .chart-modal .expanded-chart-revenue .dash-chart-summary { grid-template-columns: 1fr 1fr; padding: 18px; }
  .chart-modal .expanded-chart-revenue .dash-chart-summary strong { font-size: 16px; }
  .chart-modal .expanded-chart-integrations { grid-template-columns: 1fr; gap: 12px; padding: 20px; }
  .chart-modal .expanded-chart-integrations .dash-donut-wrap { width: min(280px, 100%); }
  .chart-modal .expanded-chart-integrations .dash-integration-list { padding: 12px 0; }
  .chart-modal .expanded-chart-composition { overflow-x: auto; }
  .chart-modal .expanded-chart-composition .dash-waterfall { min-width: 700px; height: 250px; }
  .chart-modal .expanded-chart-composition .dash-composition-legend { padding: 18px 16px 6px; }
  .chart-modal .expanded-chart-composition .dash-composition-footer { padding: 18px 16px; }
  .dash-detail-section { padding: 20px 14px; border-radius: 16px; }
  .dash-detail-head { align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
  .dash-detail-head .dash-detail-title { font-size: 15px; }
  .dash-detail-head .dash-detail-subtitle { font-size: 11px; }
  .dash-detail-count { padding: 3px 9px; font-size: 10px; }
  .dash-detail-table { font-size: 11px; }
  .dash-detail-table thead th { font-size: 10px; }
  .dash-detail-table thead th,
  .dash-detail-table tbody th,
  .dash-detail-table td { padding: 11px 9px; }
  .dash-hour-detail-summary { grid-template-columns: 1fr; gap: 12px; margin-bottom: 18px; }
  .dash-hour-detail-stat { padding: 18px 20px; }
  .dash-hour-detail-stat-value { font-size: 29px; }
  .chart-modal .dash-hour-detail-stat-note { margin-top: 9px; }
  .dash-hour-detail-chart { padding: 18px 14px 12px; border-radius: 16px; }
  .dash-hour-detail-chart-head { gap: 12px; }
  .dash-hour-detail-legend { gap: 10px; padding: 6px 8px; font-size: 9px; }
}
