/* ───────────────────────────────────────────────────────────────────────────
   fonio-forecast — v2 primitive components (consolidated CSS)
   ───────────────────────────────────────────────────────────────────────────
   All primitives namespaced .v2-* to avoid collision with legacy classes.
   Token-driven (no raw hex outside tokens.css/theme.css; no raw px outside
   the spacing scale).

   Order:
     1. AppShell + Sidebar + Topbar (layout)
     2. Button
     3. Badge
     4. Card
     5. KPI tile / strip
     6. Tab (segmented)
     7. Input / Select
     8. Tooltip + InfoIcon
     9. Modal + backdrop
    10. DataTable
    11. ChartFrame + PacingChart
    12. EmptyState + Skeleton + ErrorState + Banner
    13. DateRangePicker
   ─────────────────────────────────────────────────────────────────────────── */

/* ─── 1. APP SHELL + SIDEBAR + TOPBAR ───────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text-primary, var(--ink-1));
  font-family: var(--font-sans);
}
.app-shell__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.app-shell__topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--surface);
  border-bottom: 1px solid var(--border, var(--line));
}
.app-shell__content {
  padding: var(--space-6);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

.v2-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border, var(--line));
  background: var(--surface);
  flex-shrink: 0;
  transition: width var(--duration-base) var(--ease-standard);
}
.v2-sidebar--expanded { width: var(--sidebar-w-expanded); }
.v2-sidebar--collapsed { width: var(--sidebar-w-collapsed); }
.v2-sidebar__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border, var(--line));
  min-height: var(--topbar-h);
}
.v2-sidebar__toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary, var(--ink-2));
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
}
.v2-sidebar__toggle:hover { background: var(--surface-hover); }
.v2-sidebar__brand {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body);
  color: var(--text-primary, var(--ink-1));
  white-space: nowrap;
  overflow: hidden;
}
.v2-sidebar__list {
  list-style: none;
  padding: var(--space-2);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-0-5);
}
.v2-sidebar__list-item { margin: 0; }
.v2-sidebar__item {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary, var(--ink-2));
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.v2-sidebar--collapsed .v2-sidebar__item { justify-content: center; padding: 0; }
.v2-sidebar__item:hover {
  background: var(--surface-hover);
  color: var(--text-primary, var(--ink-1));
}
.v2-sidebar__item--active {
  background: var(--accent-soft, var(--lilac-200));
  color: var(--accent, var(--lilac-700));
  font-weight: var(--fw-medium);
}
.v2-sidebar__item--active:hover {
  background: var(--accent-soft, var(--lilac-200));
  color: var(--accent, var(--lilac-700));
}
.v2-sidebar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  flex-shrink: 0;
}
.v2-sidebar__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-h);
  padding: 0 var(--space-4);
}
.v2-topbar__left,
.v2-topbar__center,
.v2-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.v2-topbar__left { flex: 0 0 auto; font-weight: var(--fw-semibold); color: var(--text-primary, var(--ink-1)); }
.v2-topbar__center { flex: 1 1 auto; justify-content: center; min-width: 0; }
.v2-topbar__right { flex: 0 0 auto; }

/* ─── 2. BUTTON ─────────────────────────────────────────────────────────── */

.v2-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-weight: var(--fw-medium);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
  white-space: nowrap;
  user-select: none;
  outline: none;
}
.v2-btn:focus-visible {
  box-shadow: var(--shadow-focus);
}
.v2-btn--sm { height: 28px; padding: 0 var(--space-2); font-size: var(--fs-body-xs); }
.v2-btn--md { height: 32px; padding: 0 var(--space-3); font-size: var(--fs-body); }
.v2-btn--lg { height: 36px; padding: 0 var(--space-4); font-size: var(--fs-body-lg); }
.v2-btn--icon.v2-btn--sm { width: 28px; padding: 0; }
.v2-btn--icon.v2-btn--md { width: 32px; padding: 0; }
.v2-btn--icon.v2-btn--lg { width: 36px; padding: 0; }
.v2-btn--primary {
  background: var(--accent, var(--lilac-700));
  color: var(--accent-fg);
}
.v2-btn--primary:hover { background: var(--accent-hover, var(--lilac-700)); }
.v2-btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong, var(--line-2));
  color: var(--text-primary, var(--ink-1));
}
.v2-btn--secondary:hover { background: var(--surface-hover); }
.v2-btn--ghost {
  background: transparent;
  color: var(--text-secondary, var(--ink-2));
}
.v2-btn--ghost:hover { background: var(--surface-hover); color: var(--text-primary, var(--ink-1)); }
.v2-btn--ghost.v2-btn--active {
  background: var(--accent-soft, var(--lilac-200));
  color: var(--accent, var(--lilac-700));
}
.v2-btn--danger {
  background: var(--danger, var(--warn));
  color: var(--text-on-fill);
}
.v2-btn--danger:hover { background: var(--warn-700, var(--warn)); }
.v2-btn--tone-warn { color: var(--warning, var(--ae-500)); }
.v2-btn--tone-success { color: var(--success, var(--good)); }
.v2-btn[disabled],
.v2-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}
.v2-btn--loading { cursor: wait; opacity: 0.85; }
.v2-btn__spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: v2-spin var(--duration-slow) linear infinite;
}
@keyframes v2-spin { to { transform: rotate(360deg); } }
.v2-btn__content { display: inline-flex; align-items: center; gap: var(--space-2); }

/* ─── 3. BADGE ──────────────────────────────────────────────────────────── */

.v2-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5, 6px);
  font-family: var(--font-sans);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.v2-badge--sm { height: 20px; padding: 0 var(--space-2); font-size: var(--fs-body-xs); }
.v2-badge--md { height: 24px; padding: 0 var(--space-3); font-size: var(--fs-body-sm); }
.v2-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
/* Tones × variants */
.v2-badge--soft.v2-badge--neutral { background: var(--surface-hover); color: var(--text-secondary, var(--ink-2)); }
.v2-badge--soft.v2-badge--accent { background: var(--accent-soft, var(--lilac-200)); color: var(--accent, var(--lilac-700)); }
.v2-badge--soft.v2-badge--good { background: var(--success-bg); color: var(--success, var(--good)); }
.v2-badge--soft.v2-badge--warn { background: var(--warning-bg); color: var(--warning, var(--ae-500)); }
.v2-badge--soft.v2-badge--danger { background: var(--danger-bg); color: var(--danger, var(--warn)); }
.v2-badge--soft.v2-badge--info { background: var(--info-bg); color: var(--info, var(--proj)); }
.v2-badge--solid.v2-badge--neutral { background: var(--text-secondary, var(--ink-2)); color: var(--bg); }
.v2-badge--solid.v2-badge--accent { background: var(--accent, var(--lilac-700)); color: var(--accent-fg); }
.v2-badge--solid.v2-badge--good { background: var(--success, var(--good)); color: var(--text-on-fill); }
.v2-badge--solid.v2-badge--warn { background: var(--warning, var(--ae-500)); color: var(--text-on-fill); }
.v2-badge--solid.v2-badge--danger { background: var(--danger, var(--warn)); color: var(--text-on-fill); }
.v2-badge--solid.v2-badge--info { background: var(--info, var(--proj)); color: var(--text-on-fill); }
.v2-badge--outline { background: transparent; }
.v2-badge--outline.v2-badge--neutral { border: 1px solid var(--border-strong, var(--line-2)); color: var(--text-secondary, var(--ink-2)); }
.v2-badge--outline.v2-badge--accent { border: 1px solid var(--accent, var(--lilac-700)); color: var(--accent, var(--lilac-700)); }
.v2-badge--outline.v2-badge--good { border: 1px solid var(--success, var(--good)); color: var(--success, var(--good)); }
.v2-badge--outline.v2-badge--warn { border: 1px solid var(--warning, var(--ae-500)); color: var(--warning, var(--ae-500)); }
.v2-badge--outline.v2-badge--danger { border: 1px solid var(--danger, var(--warn)); color: var(--danger, var(--warn)); }
.v2-badge--outline.v2-badge--info { border: 1px solid var(--info, var(--proj)); color: var(--info, var(--proj)); }
.v2-badge--count {
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-1, 4px);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  justify-content: center;
  border-radius: var(--radius-pill);
}

/* ─── 4. CARD ────────────────────────────────────────────────────────────── */

.v2-card {
  background: var(--surface);
  border: 1px solid var(--border, var(--line));
  border-radius: var(--radius-lg);
}
.v2-card--elev-raised { box-shadow: var(--shadow-sm); }
.v2-card--elev-flat { box-shadow: none; }
.v2-card--pad-none { padding: 0; }
.v2-card--pad-compact { padding: var(--space-3); }
.v2-card--pad-default { padding: var(--space-4); }
.v2-card--pad-comfortable { padding: var(--space-6); }
.v2-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.v2-card__title { font-size: var(--fs-h3); font-weight: var(--fw-semibold); margin: 0; }
.v2-card__subtitle { font-size: var(--fs-body-sm); color: var(--text-muted, var(--ink-3)); margin-top: 2px; }
.v2-card__controls { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.v2-card__body { /* freeform */ }
.v2-card__footer { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border, var(--line)); }

/* ─── 5. KPI TILE / STRIP ────────────────────────────────────────────────── */

.v2-kpi-strip {
  display: grid;
  gap: var(--space-4);
}
.v2-kpi-strip--cols-1 { grid-template-columns: 1fr; }
.v2-kpi-strip--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.v2-kpi-strip--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.v2-kpi-strip--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.v2-kpi-strip--cols-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
@media (max-width: 1280px) {
  .v2-kpi-strip--cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .v2-kpi-strip--cols-3,
  .v2-kpi-strip--cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v2-kpi-strip--cols-2 { grid-template-columns: 1fr; }
}

.v2-kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border, var(--line));
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 96px;
  box-shadow: var(--shadow-sm);
}
.v2-kpi-tile__label {
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  color: var(--text-muted, var(--ink-3));
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.v2-kpi-tile__value {
  font-family: var(--font-mono);
  font-size: var(--fs-display, 28px);
  font-weight: var(--fw-semibold);
  color: var(--text-primary, var(--ink-1));
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.v2-kpi-tile__value-label {
  font-size: var(--fs-body-sm);
  color: var(--text-secondary, var(--ink-2));
}
.v2-kpi-tile__delta {
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
  font-family: var(--font-mono);
}
.v2-kpi-tile__delta--good { color: var(--success, var(--good)); }
.v2-kpi-tile__delta--warn { color: var(--warning, var(--ae-500)); }
.v2-kpi-tile__delta--bad { color: var(--danger, var(--warn)); }
.v2-kpi-tile__delta--neutral { color: var(--text-muted, var(--ink-3)); }
.v2-kpi-tile__rows {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border, var(--line));
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 4px);
}
.v2-kpi-tile__row {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-body-sm);
}
.v2-kpi-tile__row-label { color: var(--text-muted, var(--ink-3)); }
.v2-kpi-tile__row-value { color: var(--text-primary, var(--ink-1)); }
.v2-kpi-tile__row-value--good { color: var(--success, var(--good)); }
.v2-kpi-tile__row-value--warn { color: var(--warning, var(--ae-500)); }
.v2-kpi-tile__row-value--bad { color: var(--danger, var(--warn)); }
.v2-kpi-tile--sticky {
  position: sticky;
  top: calc(var(--topbar-h) + var(--space-4));
  z-index: var(--z-sticky);
}
.v2-kpi-tile--sticky.v2-kpi-tile--collapsed {
  padding: var(--space-3);
  min-height: 0;
}
.v2-kpi-tile--sticky.v2-kpi-tile--collapsed .v2-kpi-tile__value { font-size: var(--fs-h2); }
.v2-kpi-tile--sticky.v2-kpi-tile--collapsed .v2-kpi-tile__rows { display: none; }

/* ─── 6. TAB (segmented) ─────────────────────────────────────────────────── */

.v2-tab {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong, var(--line-2));
  border-radius: var(--radius-pill);
  padding: var(--space-0-5);
  gap: var(--space-0-5);
}
.v2-tab__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5, 6px);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-pill) - 2px);
  font-family: var(--font-sans);
  font-weight: var(--fw-medium);
  color: var(--text-secondary, var(--ink-2));
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
  outline: none;
  white-space: nowrap;
}
.v2-tab--sm .v2-tab__item { height: 24px; padding: 0 var(--space-2); font-size: var(--fs-body-xs); }
.v2-tab--md .v2-tab__item { height: 28px; padding: 0 var(--space-3); font-size: var(--fs-body-sm); }
.v2-tab__item:focus-visible { box-shadow: var(--shadow-focus); }
.v2-tab__item:hover { background: var(--surface-hover); color: var(--text-primary, var(--ink-1)); }
.v2-tab__item--on {
  background: var(--accent-soft, var(--lilac-200));
  color: var(--accent, var(--lilac-700));
}
.v2-tab__item--on:hover { background: var(--accent-soft, var(--lilac-200)); }
.v2-tab__item[disabled],
.v2-tab__item[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.v2-tab__item--accent-danger.v2-tab__item--on { background: var(--danger-bg); color: var(--danger, var(--warn)); }
.v2-tab__item--accent-success.v2-tab__item--on { background: var(--success-bg); color: var(--success, var(--good)); }
.v2-tab__item--all { font-weight: var(--fw-semibold); }
.v2-tab__icon { display: inline-flex; align-items: center; }

/* ─── 7. INPUT / SELECT ──────────────────────────────────────────────────── */

.v2-input {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border-strong, var(--line-2));
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  color: var(--text-primary, var(--ink-1));
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.v2-input:focus,
.v2-input:focus-visible {
  outline: none;
  border-color: var(--accent, var(--lilac-700));
  box-shadow: var(--shadow-focus);
}
.v2-input--sm { height: 28px; padding: 0 var(--space-2); font-size: var(--fs-body-xs); }
.v2-input[disabled] {
  background: var(--surface-hover);
  color: var(--text-muted, var(--ink-3));
  cursor: not-allowed;
}
.v2-input--error { border-color: var(--danger, var(--warn)); }
.v2-input--error:focus { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--danger, var(--warn)); }
.v2-input--has-affix { /* see wrap */ }
.v2-input-wrap {
  display: inline-flex;
  align-items: center;
  position: relative;
}
.v2-input-wrap > .v2-input { flex: 1; }
.v2-input__prefix,
.v2-input__suffix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 0 var(--space-2);
  color: var(--text-muted, var(--ink-3));
  font-size: var(--fs-body-sm);
  pointer-events: none;
}
.v2-input__prefix { left: 0; }
.v2-input__suffix { right: 0; }
.v2-input-wrap > .v2-input { padding-left: var(--space-6); }
.v2-input-wrap > .v2-input + .v2-input__suffix ~ .v2-input,
.v2-input-wrap:has(.v2-input__suffix) > .v2-input { padding-right: var(--space-6); }
.v2-input__error {
  display: block;
  margin-top: var(--space-1, 4px);
  font-size: var(--fs-caption);
  color: var(--danger, var(--warn));
}
.v2-input--select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  padding-right: var(--space-6);
}

/* ─── 8. TOOLTIP + INFOICON ──────────────────────────────────────────────── */

.v2-tip-wrap {
  position: relative;
  display: inline-block;
}
.v2-tip {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-elevated, var(--surface));
  color: var(--text-primary, var(--ink-1));
  font-family: var(--font-sans);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border, var(--line));
  box-shadow: var(--shadow-md);
  max-width: 280px;
  width: max-content;
  z-index: var(--z-popover);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-standard);
  white-space: normal;
  text-align: left;
}
.v2-tip-wrap--above .v2-tip { bottom: calc(100% + 6px); }
.v2-tip-wrap--below .v2-tip { top: calc(100% + 6px); }
.v2-tip-wrap--open .v2-tip { opacity: 1; }
.v2-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-body-sm);
  color: var(--text-muted, var(--ink-3));
  cursor: help;
  margin-left: var(--space-1, 4px);
  outline: none;
  border-radius: var(--radius-pill);
}
.v2-info-icon:hover { color: var(--accent, var(--lilac-700)); }
.v2-info-icon:focus-visible { box-shadow: var(--shadow-focus); }

/* ─── 9. MODAL ───────────────────────────────────────────────────────────── */

.v2-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 20, 36, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-4);
}
:root[data-theme="dark"] .v2-modal-backdrop { background: rgba(0, 0, 0, 0.6); }
.v2-modal {
  background: var(--surface-elevated, var(--surface));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-5) var(--space-6);
  width: 100%;
}
.v2-modal--sm { max-width: 420px; }
.v2-modal--md { max-width: 560px; }
.v2-modal--lg { max-width: 720px; }
.v2-modal__title {
  font-size: var(--fs-h3);
  font-weight: var(--fw-semibold);
  margin: 0 0 var(--space-3) 0;
  color: var(--text-primary, var(--ink-1));
}
.v2-modal__message {
  font-size: var(--fs-body);
  color: var(--text-secondary, var(--ink-2));
  margin: 0 0 var(--space-4) 0;
}
.v2-modal__input { width: 100%; }
.v2-modal__error {
  margin-top: var(--space-2);
  font-size: var(--fs-caption);
  color: var(--danger, var(--warn));
}
.v2-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* ─── 10. DATATABLE ──────────────────────────────────────────────────────── */

.v2-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  color: var(--text-primary, var(--ink-1));
}
.v2-table thead th {
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  color: var(--text-muted, var(--ink-3));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: 0 var(--space-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border, var(--line));
}
.v2-table tbody td {
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--border, var(--line));
  vertical-align: middle;
}
.v2-table--compact thead th,
.v2-table--compact tbody td { height: 36px; }
.v2-table--comfortable thead th,
.v2-table--comfortable tbody td { height: 48px; }
.v2-table--sticky thead th {
  position: sticky;
  top: var(--v2-table-sticky-top, var(--topbar-h));
  z-index: var(--z-sticky);
}
.v2-table tbody tr:hover td {
  background: var(--surface-hover);
}
.v2-table tbody tr:last-child td { border-bottom: none; }

/* ─── 11. CHARTFRAME + PACINGCHART ───────────────────────────────────────── */

.v2-chart-frame {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border, var(--line));
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.v2-chart-frame__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.v2-chart-frame__title-block { display: flex; flex-direction: column; gap: var(--space-0-5); }
.v2-chart-frame__title {
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-primary, var(--ink-1));
}
.v2-chart-frame__subtitle {
  font-size: var(--fs-body-sm);
  color: var(--text-muted, var(--ink-3));
}
.v2-chart-frame__controls { display: flex; align-items: center; gap: var(--space-2); }
.v2-chart-frame__body { flex: 1; }
.v2-chart-frame__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--fs-body-sm);
  color: var(--text-secondary, var(--ink-2));
}
.v2-chart-frame__legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5, 6px);
}
.v2-chart-frame__legend-item--hidden { opacity: 0.4; }
.v2-chart-frame__swatch {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid;
}
.v2-chart-frame__swatch--dashed {
  background: transparent;
  border-style: dashed;
}

.v2-pacing-chart { width: 100%; }
.v2-pacing-chart__svg { width: 100%; height: auto; display: block; }
.v2-pacing-chart__grid { stroke: var(--border, var(--line)); stroke-width: 1; stroke-dasharray: 2 4; }
.v2-pacing-chart__axis { stroke: var(--border-strong, var(--line-2)); stroke-width: 1; }
.v2-pacing-chart__tick {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  fill: var(--text-muted, var(--ink-3));
  font-variant-numeric: tabular-nums;
}
.v2-pacing-chart__pace {
  stroke: var(--text-muted, var(--ink-3));
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  opacity: 0.6;
}
.v2-pacing-chart__target-line {
  stroke: var(--ch-gtm, var(--lilac-700));
  stroke-width: 1.5;
  opacity: 0.35;
  fill: none;
}
.v2-pacing-chart__real {
  stroke: var(--accent, var(--lilac-700));
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
}
.v2-pacing-chart__projection {
  stroke: var(--accent, var(--lilac-700));
  stroke-width: 2;
  stroke-dasharray: 6 6;
  opacity: 0.6;
  fill: none;
}
.v2-pacing-chart__today {
  stroke: var(--accent, var(--lilac-700));
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.5;
}
.v2-pacing-chart__today-label {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  fill: var(--accent, var(--lilac-700));
  font-weight: var(--fw-medium);
}
.v2-pacing-chart__dot--real {
  fill: var(--accent, var(--lilac-700));
  stroke: var(--surface);
  stroke-width: 2;
}
.v2-pacing-chart__dot--target {
  fill: var(--ch-gtm, var(--lilac-700));
  stroke: var(--surface);
  stroke-width: 2;
}
.v2-pacing-chart__xlabel {
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  fill: var(--text-muted, var(--ink-3));
}
.v2-pacing-chart__xlabel--today { fill: var(--accent, var(--lilac-700)); font-weight: var(--fw-medium); }

/* Hover crosshair + dots */
.v2-pacing-chart { position: relative; }
.v2-pacing-chart__svg { cursor: crosshair; }
.v2-pacing-chart__crosshair {
  stroke: var(--text-muted, var(--ink-3));
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0.6;
  pointer-events: none;
}
.v2-pacing-chart__hover-dot {
  stroke: var(--surface);
  stroke-width: 2;
  pointer-events: none;
}
.v2-pacing-chart__hover-dot--real { fill: var(--accent); }
.v2-pacing-chart__hover-dot--target { fill: var(--ch-gtm, var(--lilac-700)); }

/* Tooltip overlay (HTML, easier to style than SVG foreignObject) */
.v2-pacing-chart__tooltip {
  position: absolute;
  background: var(--surface-elevated, var(--surface));
  border: 1px solid var(--border, var(--line));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-2) var(--space-3);
  min-width: 140px;
  font-size: var(--fs-body-sm);
  color: var(--text-primary, var(--ink-1));
  pointer-events: none;
  z-index: var(--z-popover);
}
.v2-pacing-chart__tooltip-month {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body);
  color: var(--text-primary, var(--ink-1));
  margin-bottom: var(--space-1);
  text-transform: capitalize;
}
.v2-pacing-chart__tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 2px 0;
}
.v2-pacing-chart__tooltip-label {
  color: var(--text-muted, var(--ink-3));
  font-size: var(--fs-body-sm);
}
.v2-pacing-chart__tooltip-value {
  font-family: var(--font-mono);
  font-weight: var(--fw-medium);
  color: var(--text-primary, var(--ink-1));
}
.v2-pacing-chart__tooltip-value--good { color: var(--success, var(--good)); }
.v2-pacing-chart__tooltip-value--bad { color: var(--danger, var(--warn)); }
.v2-pacing-chart__tooltip-row--delta {
  border-top: 1px solid var(--border, var(--line));
  margin-top: var(--space-1);
  padding-top: var(--space-1);
}

/* ─── 12. EMPTYSTATE / SKELETON / ERRORSTATE / BANNER ────────────────────── */

.v2-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  color: var(--text-muted, var(--ink-3));
  text-align: center;
}
.v2-empty--inline { padding: var(--space-2); flex-direction: row; gap: var(--space-2); }
.v2-empty--compact { padding: var(--space-6); }
.v2-empty--large { padding: var(--space-12); }
.v2-empty__icon { font-size: var(--fs-h2); }
.v2-empty__title { font-size: var(--fs-body-lg); font-weight: var(--fw-medium); color: var(--text-primary, var(--ink-1)); }
.v2-empty__message { font-size: var(--fs-body); max-width: 360px; }
.v2-empty__action { margin-top: var(--space-2); }

.v2-skeleton {
  display: inline-block;
  background: var(--surface-hover);
  background-image: linear-gradient(90deg, var(--surface-hover) 0%, var(--surface) 50%, var(--surface-hover) 100%);
  background-size: 200% 100%;
  animation: v2-skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.v2-skeleton--text { height: 1em; min-width: 80px; }
.v2-skeleton--block { width: 100%; height: 80px; }
.v2-skeleton--circle { border-radius: 50%; width: 32px; height: 32px; }
@keyframes v2-skeleton-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .v2-skeleton { animation: none; } }

.v2-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted, var(--ink-3));
  background: var(--danger-bg);
  border-radius: var(--radius-lg);
}
.v2-error-state__icon {
  font-size: var(--fs-h2);
  color: var(--danger, var(--warn));
}
.v2-error-state__title {
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-primary, var(--ink-1));
}
.v2-error-state__message { font-size: var(--fs-body); max-width: 360px; }
.v2-error-state__action { margin-top: var(--space-2); }

.v2-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid;
  margin-bottom: var(--space-4);
}
.v2-banner--info {
  background: var(--info-bg);
  border-color: var(--info, var(--proj));
  color: var(--info, var(--proj));
}
.v2-banner--warning {
  background: var(--warning-bg);
  border-color: var(--warning, var(--ae-500));
  color: var(--warning, var(--ae-500));
}
.v2-banner--danger {
  background: var(--danger-bg);
  border-color: var(--danger, var(--warn));
  color: var(--danger, var(--warn));
}
.v2-banner--success {
  background: var(--success-bg);
  border-color: var(--success, var(--good));
  color: var(--success, var(--good));
}
.v2-banner__icon { font-size: var(--fs-h3); flex-shrink: 0; }
.v2-banner__body { flex: 1; color: var(--text-primary, var(--ink-1)); }
.v2-banner__title { font-size: var(--fs-body); font-weight: var(--fw-semibold); }
.v2-banner__message { font-size: var(--fs-body-sm); margin-top: 2px; }
.v2-banner__action { flex-shrink: 0; }
.v2-banner__dismiss {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: var(--fs-body);
  color: inherit;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.v2-banner__dismiss:hover { background: rgba(0,0,0,0.05); }

/* ─── 13. DATERANGEPICKER ────────────────────────────────────────────────── */

.v2-date-range {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.v2-date-range__field {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5, 6px);
  font-size: var(--fs-body-sm);
  color: var(--text-muted, var(--ink-3));
}
.v2-date-range__sep {
  color: var(--text-muted, var(--ink-3));
  font-family: var(--font-mono);
}
