/* ═══ Card date picker (card-daterange.js) ═══════════════════════
   The top bar's picker, anchored under a card's own trigger. */
.cd { position: relative; display: inline-block; }
.cd-trigger { cursor: pointer; padding: 7px 12px; border-radius: 999px; }
.cd-trigger svg:first-child { color: var(--text-muted); flex-shrink: 0; }
.cd-trigger.is-open { border-color: var(--primary); }
.cd-trigger.is-open .daterange-chevron { transform: rotate(180deg); }
.cd-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 300;
  display: none;
  width: 260px;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  box-shadow: 0 22px 48px -18px rgba(43, 20, 12, 0.38), 0 2px 8px rgba(0, 0, 0, 0.06);
}
.cd-panel.show { display: block; animation: cd-in 0.16s ease-out; }
.cd-panel.is-calendar { width: 560px; }
@keyframes cd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cd-panel .daterange-preset-btn.is-current { background: var(--primary-light); color: var(--primary); }
.cd-cal-label { display: inline-flex; align-items: center; gap: 10px; }
.cd-cal-label svg { color: var(--text-secondary); }
@media (prefers-reduced-motion: reduce) { .cd-panel.show { animation: none; } }

/* Start / end of the picked range stay solid (the later in-range tint
   otherwise washes them out) — here and in the top bar's picker. */
.daterange-day.range-start.in-range,
.daterange-day.range-end.in-range { background: var(--brand-grad); color: #fff; }

/* ═══ Campaign chart sheet (campaign-chart.js) ═══════════════════
   Built on the KPI sheet (kpi-sheet.css): same band and panels. */
/* Wide sheet: most of the window, so the chart, insights and explorer sit
   side by side with little scrolling. */
.data-modal-card.kpi-sheet.is-wide { width: min(1560px, calc(100vw - 48px)); max-height: calc(100vh - 24px); }
/* Top: the chart (most of the width) and the row explorer, which takes the
   chart panel's height and scrolls inside. Below: the two insight panels
   side by side. */
.cc-body { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); align-items: stretch; }
.cc-explorer { display: flex; flex-direction: column; height: 0; min-height: 100%; box-sizing: border-box; }
.cc-explorer .cc-tree { flex: 1; min-height: 0; max-height: none; }
.cc-ins-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cc-add-rows { padding: 3px 10px; border: 1px dashed var(--border); border-radius: 999px; background: none; color: var(--primary); font: 700 11.5px var(--font-body); cursor: pointer; }
.cc-add-rows:hover { border-color: var(--primary); background: var(--primary-light); }
.cc-band { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.cc-band .ks-facts { margin-top: 0; padding-top: 0; padding-right: 40px; }
.cc-who { overflow: hidden; max-width: 70ch; text-overflow: ellipsis; white-space: nowrap; }


/* Chart */
.cc-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.cc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  padding: 3px 4px 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-surface-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-chip i { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; }
.cc-chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cc-chip-key { padding-right: 10px; }
.cc-chip i.cc-key-line { width: 14px; height: 3px; border-radius: 2px; }
.cc-chip button {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.cc-chip button:hover { background: var(--primary-light); color: var(--primary); }
.cc-chip-other { padding-right: 10px; color: var(--text-secondary); }
.cc-canvas-wrap { position: relative; height: 380px; }

/* Insights */
.cc-insights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cc-insight {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  color: inherit;
  font: inherit;
  text-align: left;
}
button.cc-insight { cursor: pointer; transition: border-color var(--ease-fast), transform var(--ease-fast); }
button.cc-insight:hover { border-color: var(--primary); transform: translateY(-1px); }
button.cc-insight:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cc-insight > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cc-insight strong { font-size: 12.5px; font-weight: 800; color: var(--text-primary); }
.cc-insight small { font-size: 11.5px; line-height: 1.45; color: var(--text-secondary); }
.cc-insight-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  color: var(--info);
  background: var(--info-bg);
}
.cc-insight.good .cc-insight-icon { color: var(--success); background: var(--success-bg); }
.cc-insight.bad .cc-insight-icon { color: var(--danger); background: var(--danger-bg); }

/* Explorer */
.cc-explorer { position: static; }
.cc-master { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.cc-dims { flex-wrap: wrap; }
.cc-search { position: relative; display: flex; align-items: center; min-width: 0; }
.cc-search svg { position: absolute; left: 10px; color: var(--text-muted); pointer-events: none; }
.cc-search input {
  width: 100%;
  height: 30px;
  padding: 0 10px 0 30px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font: 600 12px var(--font-body);
}
.cc-search-lg input { height: 36px; font-size: 13px; }
.cc-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.cc-tree { max-height: 560px; overflow: auto; margin: 0 -6px; padding: 0 6px; overscroll-behavior: contain; }

.cc-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 8px;
}
.cc-row:hover { background: var(--bg-hover); }
.cc-row.is-picked .cc-label { color: var(--text-primary); font-weight: 800; }
.cc-twisty,
.cc-twisty-pad { width: 18px; height: 18px; }
.cc-twisty {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.cc-twisty svg { transition: transform var(--ease-fast); }
.cc-twisty.is-open svg { transform: rotate(90deg); }
.cc-twisty:hover { color: var(--primary); background: var(--primary-light); }
.cc-pick { display: flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }
.cc-pick input { flex-shrink: 0; margin: 0; accent-color: var(--primary); cursor: pointer; }
.cc-swatch { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; }
.cc-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.cc-label small { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; font-weight: 600; color: var(--text-muted); }
.cc-count { padding: 1px 6px; border-radius: 999px; font-size: 10.5px; font-weight: 800; color: var(--text-muted); background: var(--bg-surface-2); }
.cc-val { font-size: 11.5px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }

/* An opened group: its own search + select-all, then its children. */
.cc-group { margin: 0 0 6px 14px; padding-left: 8px; border-left: 1px dashed var(--border); }
.cc-tools { display: flex; align-items: center; gap: 8px; padding: 4px 0 6px; }
.cc-tools .cc-search { flex: 1; }
.cc-all { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--text-secondary); white-space: nowrap; cursor: pointer; }
.cc-all input { margin: 0; accent-color: var(--primary); }
.cc-more { margin: 4px 0 2px 24px; padding: 4px 8px; border: 0; border-radius: 8px; background: none; color: var(--primary); font: 700 11.5px var(--font-body); cursor: pointer; }
.cc-more:hover { background: var(--primary-light); }
.cc-empty { padding: 8px 6px; font-size: 12px; color: var(--text-muted); }
.cc-hits-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 6px 6px; font-size: 11.5px; font-weight: 700; color: var(--text-muted); }

@media (max-width: 1100px) {
  .cc-ins-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .cc-body { grid-template-columns: minmax(0, 1fr); }
  .cc-explorer { height: auto; min-height: 0; }
  .cc-explorer .cc-tree { max-height: 420px; }
  .cc-band { grid-template-columns: minmax(0, 1fr); }
  .cc-band .ks-facts { padding-top: 14px; }
}
@media (max-width: 640px) {
  .cc-insights { grid-template-columns: minmax(0, 1fr); }
  .cd-panel.is-calendar { width: min(560px, calc(100vw - 32px)); }
  .cd-panel.is-calendar .daterange-months { flex-direction: column; }
}
