/* Reporting period picker (17 Nov). Trigger + date-range popover; bottom sheet at phone width.
   DS tokens only. One elevation (the popover), no pills, flat white. Motion: transform + opacity only. */

/* The native select stays as the source of truth, out of sight. */
.period.period--src { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; pointer-events: none; }

/* ── Trigger ── */
.pt { flex: none; display: inline-flex; align-items: center; gap: var(--space-2); height: 36px; padding: 0 var(--space-2) 0 var(--space-3); border: 1px solid var(--color-border-default); border-radius: var(--radius-sm); background: var(--color-bg-canvas); color: var(--color-text-primary); font-family: var(--font-family-body); font-size: var(--font-size-13); font-weight: var(--font-weight-medium); line-height: 1; white-space: nowrap; cursor: pointer; transition: transform var(--motion-duration-press) var(--motion-easing-out), background-color var(--motion-duration-fast) var(--motion-easing-standard); }
.pt svg { width: 16px; height: 16px; color: var(--color-text-secondary); }
.pt__t { display: inline-flex; align-items: baseline; gap: var(--space-2); }
.pt__lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pt__name { color: var(--color-text-tertiary); font-weight: var(--font-weight-regular); }
.pt__range { font-feature-settings: var(--font-feature-tabular); font-variant-numeric: tabular-nums; }
.pt__chev { transition: transform var(--motion-duration-fast) var(--motion-easing-out); }
.pt[aria-expanded="true"] { background: var(--color-bg-surface); }
.pt[aria-expanded="true"] .pt__chev { transform: rotate(180deg); }
.pt:active { transform: scale(0.97); }

/* ── Popover: one month, lilac range, no footer (17 Nov, mini pass) ── */
.pp { position: fixed; z-index: 55; display: flex; flex-direction: column; width: max-content; padding: var(--space-3) var(--space-4) var(--space-4); background: var(--color-bg-canvas); border: 1px solid var(--color-border-subtle); border-radius: var(--radius-md); box-shadow: var(--elevation-overlay); color: var(--color-text-primary); font-family: var(--font-family-body); font-size: var(--font-size-13); line-height: 1.4;
  opacity: 0; transform: scale(0.97); transform-origin: top right;
  transition: opacity 100ms var(--motion-easing-exit), transform 100ms var(--motion-easing-exit); }
.pp.is-open { opacity: 1; transform: none; transition-duration: 150ms; transition-timing-function: var(--motion-easing-out); }
.pp.is-instant, .pp-scrim.is-instant { transition: none; }
.pp:focus { outline: none; }
.pp__head { display: none; }
:where(.pp) :where(button) { font: inherit; color: inherit; border: 0; background: none; padding: 0; }
:where(.pp) :where(button:not(:disabled)) { cursor: pointer; }
.pp svg { width: 16px; height: 16px; }

/* Presets: a quiet 12px text row; the active one in primary with a lilac underline. */
.pp__presets { display: flex; gap: var(--space-3); }
.pp__pre { position: relative; height: 24px; font-size: var(--font-size-12); color: var(--color-text-secondary); white-space: nowrap; transition: transform var(--motion-duration-press) var(--motion-easing-out), color var(--motion-duration-fast) var(--motion-easing-standard); }
.pp__pre[aria-pressed="true"] { color: var(--color-text-primary); font-weight: var(--font-weight-medium); }
.pp__pre[aria-pressed="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 2px; background: var(--color-lilac-600); }
/* The selection in words: "13 Nov – pick an end day", then the range and day count. */
.pp__sum { margin: var(--space-2) 0 0; font-size: var(--font-size-12); line-height: 16px; color: var(--color-text-tertiary); white-space: nowrap; font-feature-settings: var(--font-feature-tabular); font-variant-numeric: tabular-nums; }

/* Header: month label left (opens the month list), arrows right in one bordered control. */
.pp__nav { display: flex; align-items: center; justify-content: space-between; margin: var(--space-2) 0 var(--space-1); }
.pp__mb { display: inline-flex; align-items: center; gap: var(--space-1); height: 24px; padding: 0 var(--space-2) !important; margin-left: calc(var(--space-2) * -1); border-radius: var(--radius-xs); font-family: var(--font-family-display); font-size: var(--font-size-13); font-weight: var(--font-weight-medium); transition: transform var(--motion-duration-press) var(--motion-easing-out), background-color var(--motion-duration-fast) var(--motion-easing-standard); }
.pp__mchev { color: var(--color-text-tertiary); transition: transform var(--motion-duration-fast) var(--motion-easing-out); }
.pp__mb[aria-expanded="true"] .pp__mchev { transform: rotate(180deg); }
.pp__arws { display: flex; border: 1px solid var(--color-border-default); border-radius: var(--radius-xs); overflow: hidden; }
.pp__arw { width: 24px; height: 22px; display: grid; place-items: center; color: var(--color-text-secondary); transition: transform var(--motion-duration-press) var(--motion-easing-out), background-color var(--motion-duration-fast) var(--motion-easing-standard); }
.pp__arw + .pp__arw { border-left: 1px solid var(--color-border-default) !important; }
.pp__arw:disabled { color: var(--color-text-disabled); opacity: 0.45; }

/* Month list (replaces the grid while open). */
.pp__body { position: relative; }
.pp.is-ml .pp__grid { visibility: hidden; }
.pp__ml { position: absolute; inset: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.pp__ml button { height: 32px; padding: 0 var(--space-3) !important; border-radius: var(--radius-sm); text-align: left; font-size: var(--font-size-13); }
.pp__ml button[aria-current="true"] { background: var(--color-bg-brand); color: var(--color-lilac-700); font-weight: var(--font-weight-semibold); }

/* Grid: 36px days on ~44px rows, lots of air. */
.pp__grid { border-collapse: separate; border-spacing: 0 var(--space-1); margin: calc(var(--space-1) * -1) 0; table-layout: fixed; font-feature-settings: var(--font-feature-tabular); font-variant-numeric: tabular-nums; }
.pp__grid th { width: 32px; height: 24px; padding: 0; font-size: var(--font-size-11); font-weight: var(--font-weight-regular); color: var(--color-neutral-500); text-align: center; }
.pp__grid td { position: relative; width: 32px; height: 28px; padding: 0; text-align: center; }
.pp__grid td[data-d] { cursor: pointer; }
.pp__grid td:focus { outline: none; }
.pp__grid td:focus-visible .pp__n { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; }

/* Range: one soft lilac band behind the row, rounded at the row ends, tucked behind the end circles. */
.pp__grid td::before { content: ""; position: absolute; inset: 0; background: transparent; }
.pp__grid td.is-mid::before { background: var(--color-lilac-100); }
.pp__grid td.is-start:not(.is-single)::before { left: 50%; background: var(--color-lilac-100); }
.pp__grid td.is-end:not(.is-single)::before { right: 50%; background: var(--color-lilac-100); }
.pp__grid td.is-preview::before { background: var(--color-lilac-50); }
.pp__grid td.is-mid:first-child::before, .pp__grid td.is-end:first-child::before { border-radius: var(--radius-pill) 0 0 var(--radius-pill); }
.pp__grid td.is-mid:last-child::before, .pp__grid td.is-start:last-child::before { border-radius: 0 var(--radius-pill) var(--radius-pill) 0; }
.pp__grid td.is-start:last-child::before { left: 0; right: 0; background: transparent; }
.pp__grid td.is-end:first-child::before { left: 0; right: 0; background: transparent; }

.pp__n { position: relative; z-index: 1; display: grid; place-items: center; width: 28px; height: 28px; margin: 0 auto; border-radius: 50%; font-size: var(--font-size-13); font-weight: var(--font-weight-regular); color: var(--color-neutral-700); transition: transform var(--motion-duration-press) var(--motion-easing-out); }
.pp__grid td.is-start .pp__n, .pp__grid td.is-end .pp__n { background: var(--color-lilac-600); color: var(--color-neutral-0); font-weight: var(--font-weight-medium); }
.pp__grid td.is-hov .pp__n { background: var(--color-bg-canvas); color: var(--color-lilac-700); box-shadow: inset 0 0 0 1.5px var(--color-lilac-600); }
.pp__grid td.is-future { cursor: default; }
.pp__grid td.is-future .pp__n { color: var(--color-neutral-400); }
.pp__grid td.is-future.is-mid::before, .pp__grid td.is-future.is-end::before { background: var(--color-lilac-50); }
.pp__grid td.is-future.is-start .pp__n, .pp__grid td.is-future.is-end .pp__n { background: var(--color-lilac-200); color: var(--color-lilac-900); }
.pp__grid td[data-d]:not(.is-future):active .pp__n { transform: scale(0.97); }

/* Today: a tiny lilac dot under the number. */
.pp__grid td.is-today .pp__n::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: var(--color-lilac-600); }
.pp__grid td.is-today.is-start .pp__n::after, .pp__grid td.is-today.is-end .pp__n::after { background: var(--color-neutral-0); }

.pp__pre:active, .pp__arw:active:not(:disabled), .pp__mb:active { transform: scale(0.97); }

/* Hover only where a real pointer can hover. */
@media (hover: hover) and (pointer: fine) {
  .pt:hover { background: var(--color-bg-surface); }
  .pp__pre:not([aria-pressed="true"]):hover { color: var(--color-text-primary); }
  .pp__mb:hover, .pp__ml button:not([aria-current="true"]):hover { background: var(--color-bg-surface); }
  .pp__arw:hover:not(:disabled) { background: var(--color-bg-surface); color: var(--color-text-primary); }
  .pp__grid td[data-d]:not(.is-future):not(.is-start):not(.is-end):not(.is-mid):hover .pp__n { background: var(--color-bg-surface); }
}

/* ── AD-12 Campaigns (19 Nov): a quiet rail beside the month (left of it on desktop, under it on a phone).
   Two-line rows: name, then the dates in tertiary. Picked = the calendar's lilac (the picker is a calendar). ── */
.pp__cols { display: flex; flex-direction: row-reverse; align-items: stretch; gap: var(--space-4); }
.pp__main { display: flex; flex-direction: column; min-width: 0; }
.pp__cg { display: flex; flex-direction: column; width: 184px; padding-right: var(--space-4); border-right: 1px solid var(--color-border-subtle); }
.pp__cgt { margin: 0; height: 24px; display: flex; align-items: center; font-size: var(--font-size-12); font-weight: var(--font-weight-medium); color: var(--color-text-secondary); }
.pp__cl { display: grid; gap: 2px; margin-top: var(--space-2); }
.pp__c { display: grid; gap: 1px; padding: 6px var(--space-2) !important; margin: 0 calc(var(--space-2) * -1); border-radius: var(--radius-sm); text-align: left; transition: transform var(--motion-duration-press) var(--motion-easing-out), background-color var(--motion-duration-fast) var(--motion-easing-standard); }
.pp__cn { font-size: var(--font-size-13); line-height: 18px; color: var(--color-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp__cd { font-size: var(--font-size-12); line-height: 16px; color: var(--color-text-tertiary); white-space: nowrap; font-feature-settings: var(--font-feature-tabular); font-variant-numeric: tabular-nums; }
.pp__c[aria-pressed="true"] { background: var(--color-lilac-50); box-shadow: inset 2px 0 0 var(--color-lilac-600); }
.pp__c[aria-pressed="true"] .pp__cn { font-weight: var(--font-weight-medium); }
.pp__c:focus { outline: none; }
.pp__c:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: -2px; }
.pp__c:active { transform: scale(0.98); }
.pp__fn { margin: auto 0 0; padding-top: var(--space-3); font-size: var(--font-size-11); line-height: 15px; color: var(--color-text-tertiary); }
@media (hover: hover) and (pointer: fine) { .pp__c:not([aria-pressed="true"]):hover { background: var(--color-bg-surface); } }
/* Trigger with a campaign: its name in primary, a quiet dot, the dates */
.pt__camp { color: var(--color-text-primary); }
.pt__dot { color: var(--color-text-tertiary); font-weight: var(--font-weight-regular); }
.pt--camp .pt__t { gap: 6px; }

/* ── Scrim (sheet only) ── */
.pp-scrim { display: none; }

/* ── Phone: bottom sheet, same anatomy ── */
@media (max-width: 760px) {
  .pt { width: 36px; padding: 0; justify-content: center; }
  .pt__t, .pt__chev { display: none; }
  .pt svg { color: var(--color-text-primary); }

  .pp-scrim.is-sheet { display: block; position: fixed; inset: 0; z-index: 54; background: var(--color-scrim-soft); opacity: 0; transition: opacity 200ms var(--motion-easing-exit); }
  .pp-scrim.is-sheet.is-open { opacity: 1; transition: opacity var(--motion-duration-sheet) var(--motion-easing-out-ios); }
  .pp-scrim.is-instant { transition: none; }

  .pp.pp--sheet { left: 0; right: 0; bottom: 0; top: auto; width: auto; padding: var(--space-2) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 0; max-height: calc(100dvh - var(--space-8)); overflow-y: auto;
    opacity: 1; transform: translateY(100%); transform-origin: bottom center;
    transition: transform 200ms var(--motion-easing-exit); }
  .pp.pp--sheet.is-open { transform: none; transition: transform var(--motion-duration-sheet) var(--motion-easing-out-ios); }
  .pp.pp--sheet.is-instant { transition: none; }
  .pp--sheet .pp__head { display: grid; justify-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
  .pp--sheet .pp__grab { width: 36px; height: 4px; border-radius: 2px; background: var(--color-border-default); }
  .pp--sheet .pp__title { justify-self: start; margin: 0; font-family: var(--font-family-display); font-size: var(--font-size-16); font-weight: var(--font-weight-semibold); }
  .pp--sheet .pp__presets { justify-content: space-between; }
  .pp--sheet .pp__pre { height: 40px; font-size: var(--font-size-13); }
  .pp--sheet .pp__sum { font-size: var(--font-size-13); }
  .pp--sheet .pp__nav { margin-top: var(--space-4); }
  .pp--sheet .pp__mb { height: 32px; font-size: var(--font-size-14); }
  .pp--sheet .pp__arw { width: 32px; height: 30px; }
  .pp--sheet .pp__grid { width: 100%; }
  .pp--sheet .pp__grid th, .pp--sheet .pp__grid td { width: auto; }
  .pp--sheet .pp__grid td { height: 36px; }
  .pp--sheet .pp__n { width: 36px; height: 36px; font-size: var(--font-size-14); }
  .pp.pp--sheet { scrollbar-width: none; }
  .pp.pp--sheet::-webkit-scrollbar { display: none; }
  .pp--sheet .pp__cols { flex-direction: column; gap: var(--space-4); }
  .pp--sheet .pp__cg { width: auto; padding: var(--space-4) 0 0; border-right: 0; border-top: 1px solid var(--color-border-subtle); }
  .pp--sheet .pp__cl { grid-template-columns: 1fr 1fr; column-gap: var(--space-4); }
  .pp--sheet .pp__c { padding: 8px var(--space-2) !important; }
  .pp--sheet .pp__cn { font-size: var(--font-size-14); }
}

@media (prefers-reduced-motion: reduce) {
  .pp, .pp.is-open, .pp.pp--sheet, .pp.pp--sheet.is-open, .pp-scrim { transition: none; }
  .pp__c:active, .pt:active, .pp__pre:active, .pp__arw:active:not(:disabled), .pp__mb:active, .pp__grid td[data-d]:active .pp__n { transform: none; }
}

/* 19 Nov · AD-12: on a phone a campaign shows its name only, so Export CSV keeps its row (dates stay in the sheet and the label) */
@media (max-width: 560px) { .pt--camp .pt__dot, .pt--camp .pt__range { display: none; } }
