/* Dashboard widgets (GeoSubscribers, UserMap, DynamicChurnRate). */
/* Same card as .xr-dashboard-card (dashboard.css) -- tokens only, so light and dark both work.
   No margin: the column's own gap spaces the cards. */
.xr-dw-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: var(--sp-4) var(--sp-6); min-width: 0; }
.xr-dw-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.xr-dw-title { margin: 0; font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-secondary); }
.xr-dw-link { font-size: var(--fs-label); text-transform: uppercase; color: var(--accent); text-decoration: none; }
.xr-dw-link:hover { color: var(--accent-hover); text-decoration: underline; }
.xr-dw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.xr-dw-cell-link { display: block; }
.xr-dw-cell-val { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.xr-dw-states { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 16px; max-height: 260px; overflow: auto; }
.xr-dw-state { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.xr-dw-state-code { width: 24px; font-weight: 600; }
.xr-dw-state-bar { flex: 1; height: 6px; background: var(--border-default); border-radius: 3px; overflow: hidden; }
.xr-dw-state-bar i { display: block; height: 100%; background: var(--accent); }
.xr-dw-state-val { width: 52px; text-align: right; }
.xr-dw-note { margin-top: var(--sp-2); font-size: var(--fs-label); color: var(--text-secondary); }

/* US map view of the UserMap widget (geo_map.rs). Colour = mix of --map-lo..--map-hi by --v (0..1). */
:root { --map-lo: #cfe6f3; --map-hi: #00466b; --map-nodata: var(--bg-surface-sunken, #eee); --map-stroke: var(--bg-surface, #fff); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --map-lo: #0d3a55; --map-hi: #5cc0f2; }
}
:root[data-theme="dark"] { --map-lo: #0d3a55; --map-hi: #5cc0f2; }
.xr-dw-toggle { display: inline-flex; margin-left: auto; margin-right: var(--sp-3); border: 1px solid var(--border-default); border-radius: 6px; overflow: hidden; }
.xr-dw-toggle-btn { font: inherit; font-size: 12px; padding: 2px 10px; border: 0; background: transparent; color: var(--text-secondary, inherit); cursor: pointer; }
.xr-dw-toggle-btn.is-on { background: var(--accent-soft-bg, #ddd); color: var(--accent-soft-fg, inherit); font-weight: 600; }
.xr-dw-toggle-btn:focus-visible { outline: 2px solid var(--ring, #6c63ff); outline-offset: -2px; }
.xr-dw-map { position: relative; width: 100%; max-width: 100%; }
.xr-dw-map-svg { display: block; width: 100%; height: auto; max-width: 100%; }
.xr-dw-map-msg { padding: 24px 0; font-size: 12px; color: var(--text-secondary, inherit); text-align: center; }
.xr-dw-mp { fill: color-mix(in srgb, var(--map-hi) calc(var(--v, 0) * 100%), var(--map-lo)); stroke: var(--map-stroke); stroke-width: 0.75; vector-effect: non-scaling-stroke; stroke-linejoin: round; transition: filter 0.12s; cursor: pointer; }
.xr-dw-mp.is-empty { fill: var(--map-nodata); cursor: default; }
.xr-dw-mp:hover, .xr-dw-mp:focus { filter: brightness(1.12); outline: none; }
/* Hover / focus outline: one overlay path above all states, constant screen-pixel width. */
.xr-dw-mp-hi { fill: none; stroke: var(--text-primary, #000); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; pointer-events: none; }
.xr-dw-mp-hi.is-focus { stroke: var(--ring, #6c63ff); stroke-width: 2.5; }
.xr-dw-map-tip { position: absolute; z-index: 5; pointer-events: none; transform: translate(12px, 12px); display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; font-size: 12px; white-space: nowrap; background: var(--bg-surface, #fff); color: var(--text-primary, #000); border: 1px solid var(--border-strong, #888); border-radius: 6px; box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,.2)); }
.xr-dw-map-tip.is-flip { transform: translate(calc(-100% - 12px), 12px); }
.xr-dw-map-legend { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--text-secondary, inherit); }
.xr-dw-map-grad { flex: 0 1 200px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--map-lo), var(--map-hi)); background: linear-gradient(90deg in srgb, var(--map-lo), var(--map-hi)); }
@media (prefers-reduced-motion: reduce) { .xr-dw-mp { transition: none; } }

/* Big numbers never wrap ("1 480 220" used to break onto two lines in narrow cards). */
.xr-dashboard-stat-value, .xr-dashboard-stat-pct, .xr-dwidget-kpi-value, .xr-dw-cell-val, .xr-dwidget-bar-value, .xr-kpi-value {
  white-space: nowrap;
}
.xr-dwidget-kpi-value { overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-variant-numeric: tabular-nums; }

/* Live / Reconnecting / Polling indicator of a widget (framework::dashboard::live). Text + dot: never colour alone. */
.xr-live { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-label); color: var(--text-secondary); white-space: nowrap; }
.xr-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-secondary); flex: none; }
.xr-live-live .xr-live-dot { background: var(--chart-3); animation: xr-live-pulse 2s ease-in-out infinite; }
.xr-live-reconnecting .xr-live-dot { background: var(--chart-4); }
.xr-live-polling .xr-live-dot { background: var(--chart-6); border-radius: 2px; }
@keyframes xr-live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .xr-live-live .xr-live-dot { animation: none; } }
.xr-dwidget-live { display: flex; justify-content: flex-end; margin-bottom: var(--sp-1); }

/* A freshly pushed number: short highlight (off for reduced motion). */
.xr-dwidget-kpi-value.is-bump { animation: xr-live-bump .6s ease-out; }
@keyframes xr-live-bump { from { color: var(--chart-1); } to { color: var(--text-primary); } }
@media (prefers-reduced-motion: reduce) { .xr-dwidget-kpi-value.is-bump { animation: none; } }
.xr-dgrid-empty { grid-column: 1 / -1; padding: var(--sp-6); text-align: center; }

/* ---------- report chart widget (dashboard v2) ---------- */
.xr-rchart { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.xr-rchart-meta { font-size: var(--fs-label); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xr-rchart-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: var(--sp-3) var(--sp-4); }
.xr-rchart-tile { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-left: var(--sp-2); border-left: 3px solid var(--tile, var(--accent)); }
.xr-rchart-tile-label { font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xr-rchart-tile-value { font-size: clamp(16px, 5.5cqi, 24px); font-weight: 700; line-height: 1.15; color: var(--text-primary); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* "Chart added to your dashboard" notice of a report page (framework::dashboard::pin). */
.xr-pin-notices { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 60; display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-end; max-width: min(420px, calc(100vw - 2 * var(--sp-4))); pointer-events: none; }
.xr-pin-notice { pointer-events: auto; display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-body); color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border-strong); border-left: 4px solid var(--accent); border-radius: var(--radius-md); box-shadow: var(--shadow-md); animation: xr-pin-in 0.2s ease-out both; }
.xr-pin-notice.xr-pin-error { border-left-color: var(--negative); }
.xr-pin-link { font-weight: 600; color: var(--accent); white-space: nowrap; }
.xr-pin-link:hover { color: var(--accent-hover); }
@keyframes xr-pin-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .xr-pin-notice { animation: none; } }
