:root {
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
    --space-12: 48px; --space-16: 64px;

    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-border: #eaecef;
    --color-border-strong: #d4d7dc;
    --color-text: #0f172a;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;

    --color-primary: #111827;
    --color-primary-hover: #0b0f19;
    --color-primary-soft: #f1f5f9;
    --color-primary-ring: rgba(17,24,39,.10);
    /* Alias kept during migration — some partials still reference --color-primary-light */
    --color-primary-light: var(--color-primary-soft);

    --color-success: #15803d;
    --color-success-soft: #ecfdf5;
    /* Alias for legacy --color-success-light references */
    --color-success-light: var(--color-success-soft);
    --color-warning: #b45309;
    --color-warning-soft: #fffbeb;
    --color-danger: #b91c1c;
    --color-danger-soft: #fef2f2;
    /* Alias for legacy --color-danger-light references */
    --color-danger-light: var(--color-danger-soft);

    --shadow-xs: 0 1px 0 rgba(15,23,42,.04);
    --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.03);
    --shadow-md: 0 4px 12px rgba(15,23,42,.06);
    --shadow-lg: 0 12px 32px rgba(15,23,42,.12);
    --shadow-focus: 0 0 0 3px var(--color-primary-ring);

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;

    --text-xs: 0.6875rem;
    --text-sm: 0.75rem;
    --text-base: 0.8125rem;
    --text-md: 0.875rem;
    --text-lg: 1rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    --transition-fast: 120ms ease;
    --transition-base: 160ms ease;

    --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, monospace;

    /* Badge primitives — consumed by .badge-{success,warning,danger,neutral} */
    --badge-success-bg:     #e6f4ea;
    --badge-success-fg:     #1e4a2b;
    --badge-success-border: #b7dfc3;
    --badge-warning-bg:     #fff3e0;
    --badge-warning-fg:     #a8530c;
    --badge-warning-border: #f0c78a;
    --badge-danger-bg:      #fdeaea;
    --badge-danger-fg:      #8a1f1f;
    --badge-danger-border:  #f2b8b8;
    --badge-neutral-bg:     var(--color-surface-alt, #f5f5f5);
    --badge-neutral-fg:     var(--color-text);
    --badge-neutral-border: var(--color-border, #ddd);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--text-md);
    line-height: 1.5;
    letter-spacing: -0.003em;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    border-right: 1px solid var(--color-border);
}
.sidebar-brand {
    padding: var(--space-6);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
}
.sidebar-brand img {
    height: 28px;
    width: auto;
    display: block;
}
.sidebar-nav {
    padding: var(--space-5) var(--space-3);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    overflow-y: auto;
}
.sidebar-nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-nav-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    font-weight: 600;
    padding: 0 var(--space-4);
    margin-bottom: var(--space-2);
}
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: var(--text-base);
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-nav-item:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}
.sidebar-nav-item.active {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-border);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.sidebar-footer-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 4px;
}
.sidebar-footer-text { color: var(--color-text-secondary); }
.sidebar-footer-text.is-success { color: var(--color-success); }
.sidebar-footer-text.is-warning { color: var(--color-warning); }
.sidebar-footer-text.is-idle    { color: var(--color-text-muted); }
.sidebar-footer-text a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.sidebar-footer-rate { color: var(--color-text-muted); }
.sidebar-footer-shop {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    font-weight: 600;
    margin-bottom: var(--space-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: var(--space-8) var(--space-10);
    max-width: 1280px;
}

/* Standalone pages (DPA acceptance, embedded shell) render without the
   admin sidebar, so they need to drop the sidebar offset. */
.main-content--standalone {
    margin-left: 0;
    padding: 0;
    max-width: none;
    width: 100%;
}

.page-header {
    margin-bottom: var(--space-8);
}
.page-header h1 {
    font-size: var(--text-2xl);
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.02em;
}
.page-header-subtitle {
    margin-top: var(--space-2);
    font-size: var(--text-md);
    color: var(--color-text-secondary);
}
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}
.page-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* === Card === */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}
.card-header {
    font-size: var(--text-md);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: var(--space-5);
    color: var(--color-text);
}
.card-subheader {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-top: calc(var(--space-1) * -1);
    margin-bottom: var(--space-5);
}
.card--dashed {
    border-style: dashed;
    background: var(--color-surface);
    box-shadow: none;
}

/* === Stat cards === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-6);
    position: relative;
    overflow: hidden;
}
.stat-card--success {}
.stat-card--warning {}
.stat-card--danger  {}
.stat-card--accent  {}
.stat-label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    margin-top: var(--space-2);
    color: var(--color-text);
}
.stat-sub {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
}
.mini-stat { padding: 0; }
.mini-stat .stat-label { font-size: var(--text-xs); }
.mini-stat .stat-value { font-size: var(--text-xl); margin-top: var(--space-1); }
.mini-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-5);
}

/* === Tables === */
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--text-base);
}
th {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border-strong);
}
td {
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: var(--color-bg); }
tbody tr:last-child td { border-bottom: none; }
.table--sticky thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: -0.005em;
    white-space: nowrap;
}
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-info    { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-neutral { background: var(--color-bg); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.badge-consent { background: var(--color-warning-soft); color: var(--color-warning); border: 1px dashed var(--color-warning); }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 32px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    font-weight: 500;
    font-family: var(--font-sans);
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--color-bg); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: #fff; }
.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}
.btn-secondary:hover { background: var(--color-bg); }
.btn-danger {
    background: var(--color-surface);
    color: var(--color-danger);
    border-color: var(--color-danger);
}
.btn-danger:hover { background: var(--color-danger-soft); color: var(--color-danger); }
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-text-secondary);
}
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); }
.btn-sm { height: 26px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn-lg { height: 40px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn-block { display: flex; width: 100%; }

/* === Forms === */
.form-group { margin-bottom: var(--space-4); }
.form-label {
    display: block;
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--space-2);
}
.form-hint {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-textarea {
    height: auto;
    min-height: 88px;
    padding: var(--space-2) var(--space-3);
    resize: vertical;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.5;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--color-text-muted); }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4);
}
.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.checkbox-row:hover { background: var(--color-bg); border-color: var(--color-border-strong); }
.checkbox-row input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--color-primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.checkbox-row-body { flex: 1; }
.checkbox-row-title { font-weight: 500; color: var(--color-text); font-size: var(--text-base); }
.checkbox-row-hint { font-size: var(--text-sm); color: var(--color-text-secondary); margin-top: 2px; }

/* Compact inline variant — no card chrome, just a clickable label */
.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-base);
    color: var(--color-text);
    padding: var(--space-1) 0;
}
.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    margin: 0;
    flex-shrink: 0;
}
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3) var(--space-4);
}
@media (max-width: 700px) {
    .checkbox-grid { grid-template-columns: 1fr; }
}

/* === Empty state === */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--color-text-secondary);
}
.empty-state-icon {
    font-size: 32px;
    line-height: 1;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}
.empty-state-title {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-2);
}
.empty-state-hint {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

/* === Banners / inline alerts === */
.banner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-left: 3px solid var(--color-text-muted);
    margin-bottom: var(--space-4);
    font-size: var(--text-base);
    color: var(--color-text);
}
.banner--info    { border-left: 1px solid var(--color-border); background: var(--color-surface); }
.banner--success { border-left: 3px solid var(--color-success); background: var(--color-success-soft); }
.banner--warning { border-left: 3px solid var(--color-warning); background: var(--color-warning-soft); }
.banner--danger  { border-left: 3px solid var(--color-danger);  background: var(--color-danger-soft); }
.banner-icon { flex-shrink: 0; color: var(--color-text-muted); margin-top: 2px; }
.banner--info .banner-icon    { color: var(--color-primary); }
.banner--success .banner-icon { color: var(--color-success); }
.banner--warning .banner-icon { color: var(--color-warning); }
.banner--danger .banner-icon  { color: var(--color-danger); }
.banner-body { flex: 1; min-width: 0; }
.banner-title { font-weight: 600; margin-bottom: var(--space-1); letter-spacing: -0.005em; }
.banner-hint  { font-size: var(--text-sm); color: var(--color-text-secondary); line-height: 1.45; }
.banner-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text);
    font-weight: 500;
}
.banner-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.banner-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex-shrink: 0;
    align-items: stretch;
}

/* === Status dot (used in sidebar + live indicator) === */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted);
    flex-shrink: 0;
}
.status-dot--success { background: var(--color-success); animation: live-pulse 2s infinite; }
.status-dot--warning { background: var(--color-warning); }
.status-dot--idle    { background: var(--color-text-muted); }

/* === Progress bar === */
.progress {
    width: 100%;
    height: 6px;
    background: var(--color-bg);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-pill);
    transition: width var(--transition-base);
}
.progress-bar--success { background: var(--color-success); }
.progress-bar--warning { background: var(--color-warning); }
.progress-bar--danger  { background: var(--color-danger); }

/* === Stacked bar (recovery conversion chart) === */
.stack-bar {
    display: flex;
    width: 100%;
    height: 28px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
}
.stack-bar-segment {
    height: 100%;
    width: var(--segment-w, 0%);
    transition: width var(--transition-base);
}
.stack-bar-segment--success { background: var(--color-success); }
.stack-bar-segment--accent  { background: var(--color-primary); }
.stack-bar-segment--muted   { background: var(--color-text-muted); }

/* === Legend === */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-top: var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
.legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--color-text-muted);
    flex-shrink: 0;
}
.legend-swatch--success { background: var(--color-success); }
.legend-swatch--accent  { background: var(--color-primary); }
.legend-swatch--warning { background: var(--color-warning); }
.legend-swatch--danger  { background: var(--color-danger); }

/* === Score tooltip === */
.score-tip-wrap { position: relative; cursor: help; display: inline-block; }
.score-tip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--color-text);
    color: var(--color-surface);
    font-size: 0.6875rem;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    z-index: 10;
    line-height: 1.3;
    min-width: 160px;
}
.score-tip-wrap:hover .score-tip { display: flex; flex-direction: column; gap: 2px; }
.score-tip-row { white-space: nowrap; }
/* === Payload click-to-open popover (event detail delivery table) === */
.payload-tip-wrap { position: relative; display: inline-block; vertical-align: middle; margin-left: var(--space-2); }
.payload-tip-icon {
    font-family: monospace;
    font-size: 0.6875rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    user-select: none;
}
.payload-tip-icon:hover { color: var(--color-primary); border-color: var(--color-primary); }
.payload-tip-wrap.is-open .payload-tip-icon { color: var(--color-primary); border-color: var(--color-primary); }
.payload-tip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: #1a1a2e;
    color: #e2e8f0;
    padding: var(--space-4);
    border-radius: var(--radius-sm);
    z-index: 20;
    max-height: 400px;
    max-width: 520px;
    min-width: 360px;
    overflow: auto;
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.payload-tip-wrap.is-open .payload-tip { display: block; }

/* === Step badges (numbered onboarding/getting-started steps) === */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: var(--text-sm);
    font-weight: 600;
    flex-shrink: 0;
}
.step-badge--muted { background: var(--color-text-muted); }
.step-badge--success { background: var(--color-success); }

/* === Chip (key/value pairs, e.g. event cookies) === */
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--color-text);
}

/* === Modal === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    padding-bottom: 40px;
    overflow-y: auto;
}
.modal-content {
    background: var(--color-surface);
    max-width: 960px;
    width: 90%;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
}
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}
.toast {
    min-width: 260px;
    max-width: 420px;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    color: var(--color-text);
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    animation: toast-in 160ms ease-out;
}
.toast--success {
    border-left: 3px solid var(--color-success);
    background: var(--color-success-soft);
    color: var(--color-success);
}
.toast--error {
    border-left: 3px solid var(--color-danger);
    background: var(--color-danger-soft);
    color: var(--color-danger);
}
.toast.is-leaving { animation: toast-out 160ms ease-in forwards; }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-8px); }
}
.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.modal-title {
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--color-text);
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: var(--text-xl);
    line-height: 1;
    padding: var(--space-1);
}
.modal-close:hover { color: var(--color-text); }

/* === Grouped bar chart (received + per-destination bars side by side) === */
.grouped-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 160px;
    padding-top: var(--space-2);
    width: 100%;
}
.grouped-bars-col {
    flex: 1;
    height: 100%;
    position: relative;
    display: flex;
    align-items: flex-end;
}
.grouped-bars-group {
    width: 100%;
    height: 100%;
    display: flex;
    gap: 1px;
    align-items: flex-end;
}
.grouped-bar {
    flex: 1;
    border-radius: 2px 2px 0 0;
    transition: height var(--transition-base), opacity var(--transition-fast);
    opacity: 0.85;
}
.grouped-bar--received {
    background: var(--color-text);
}
.grouped-bars-col:hover .grouped-bar {
    opacity: 1;
}

/* Subtle alternating background shading for visual grouping across time.
   Stripe interval is set per time range in the template. */
.grouped-bars-col.is-striped::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.025);
    pointer-events: none;
    z-index: 0;
}
.grouped-bars-col.is-striped .grouped-bars-group,
.grouped-bars-col.is-striped .combo-tip {
    position: relative;
    z-index: 1;
}

/* Faint gridline at labeled column positions to anchor bars to times. */
.grouped-bars-col.is-label-anchor::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 1px;
    background: rgba(15, 23, 42, 0.06);
    pointer-events: none;
    z-index: 0;
}

/* Hover tooltip */
.combo-tip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: var(--color-surface);
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    z-index: 20;
    pointer-events: none;
    min-width: 140px;
    box-shadow: var(--shadow-md);
}
.combo-tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -4px;
    border: 4px solid transparent;
    border-top-color: var(--color-text);
}
.grouped-bars-col:hover .combo-tip {
    display: block;
}
.combo-tip-label {
    font-weight: 600;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}
.combo-tip-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 1px 0;
    font-size: 0.625rem;
}
.combo-tip-dot {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    flex-shrink: 0;
}
.combo-tip-val {
    margin-left: auto;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.chart-labels {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* === Live indicator bar === */
.live-bar {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* === Live events page === */
.live-card { padding: 0; }
.live-scroll { max-height: calc(100vh - 200px); overflow-y: auto; }
.live-empty-cell {
    text-align: center;
    color: var(--color-text-secondary);
    padding: var(--space-8) !important;
}
.live-cell-page {
    font-size: var(--text-sm);
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.live-cell-time {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    white-space: nowrap;
}
.live-row-new { animation: live-row-fade 0.3s ease; }
@keyframes live-row-fade {
    from { opacity: 0; background: var(--color-primary-soft); }
    to   { opacity: 1; background: transparent; }
}
.live-connected #live-text { color: var(--color-success); }
.live-upgrade-card { max-width: 720px; }

/* === Recovery page: CSS-only info toggle ==================================
   Pattern: hidden checkbox + label (the clickable trigger) + sibling div
   (the body). No JS, no <details>/<summary> double-fire bug, works across
   HTMX partial swaps. Moved out of partials/recovery_stats.html so rules
   don't re-parse on every swap. */
.info-toggle { display: none; }
.info-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--color-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    user-select: none;
    -webkit-user-select: none;
    margin-top: var(--space-3);
    /* Reset native <button> element styles when info-trigger is a button
       (for popover-based tooltips). Label-based triggers inherit cleanly. */
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}
.info-trigger.inline {
    margin-top: 0;
    font-size: var(--text-base);
    font-weight: 400;
}
.info-body {
    display: none;
    margin-top: var(--space-2);
    padding: var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--color-text-secondary);
}
.info-toggle:checked ~ .info-trigger { color: var(--color-text-secondary); }
.info-toggle:checked ~ .info-body    { display: block; }
.info-body.wide {
    padding: var(--space-4);
    background: var(--color-bg);
    border-radius: var(--radius-md);
    line-height: 1.6;
}

/* --- Native popover variant ---
   Uses the browser's Popover API (`popover` attribute + `popovertarget`
   button). Popovers render in the top layer so they bypass every
   containing block, z-index stack, and overflow:hidden on any ancestor —
   opening one never mutates the document flow, so nothing on the page
   moves. Positioning is handled by a small inline script in app.html
   that anchors the popover to its trigger's bounding rect on `toggle`. */
.info-popover {
    position: fixed;
    margin: 0;
    padding: var(--space-5);
    width: 380px;
    max-width: calc(100vw - var(--space-6) * 2);
    max-height: 70vh;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18), 0 6px 16px rgba(15, 23, 42, 0.08);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-text);
    /* Default placement before JS anchors it — center of viewport. Prevents
       a flash-of-wrong-position if the toggle event is delayed. */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.info-popover[data-anchored] {
    transform: none;
}
.info-popover::backdrop {
    background: rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

/* Content typography inside popovers */
.info-popover p {
    margin: 0 0 var(--space-3);
    color: var(--color-text-secondary);
}
.info-popover p:last-child { margin-bottom: 0; }
.info-popover strong {
    color: var(--color-text);
    font-weight: 600;
}
.info-popover ul {
    margin: 0 0 var(--space-3) 0;
    padding: 0 0 0 var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    color: var(--color-text-secondary);
}
.info-popover ul:last-child { margin-bottom: 0; }
.info-popover li { line-height: 1.55; }
.info-popover li::marker { color: var(--color-border); }
.info-popover a {
    color: var(--color-primary);
    font-weight: 500;
}
.info-popover a:hover { text-decoration: underline; }

/* Entrance animation — fades in and settles into place */
.info-popover { opacity: 0; transition: opacity 0.12s ease-out; }
.info-popover:popover-open { opacity: 1; }

/* Trigger button hover/focus states (the button element reset strips these) */
.info-trigger:hover { text-decoration: underline; }
.info-trigger:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* === Plan cards (shared by pages/plans.html + pages/onboarding.html) ==== */
.plan-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
    max-width: 1040px;
    margin-top: var(--space-6);
    margin-bottom: var(--space-6);
}
.plan-grid--four {
    grid-template-columns: repeat(4, 1fr);
    max-width: 1320px;
}
@media (max-width: 1180px) {
    .plan-grid--four { grid-template-columns: repeat(2, 1fr); max-width: 880px; }
}
@media (max-width: 900px) {
    .plan-grid { grid-template-columns: 1fr; max-width: 440px; }
    .plan-grid--four { grid-template-columns: 1fr; max-width: 440px; }
}

/* Outcome strip — what each plan does for you */
.plan-outcomes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    max-width: 1320px;
    margin: var(--space-5) auto;
}
@media (max-width: 900px) { .plan-outcomes { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .plan-outcomes { grid-template-columns: 1fr; } }
.plan-outcome {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
}
.plan-outcome--accent {
    border-color: var(--color-primary);
    background: color-mix(in oklab, var(--color-primary) 6%, var(--color-surface));
}
.plan-outcome-tier {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}
.plan-outcome-line {
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--color-text-muted);
    letter-spacing: 0;
    margin-bottom: var(--space-3);
}

/* Billing interval toggle */
.billing-interval-toggle {
    display: flex;
    gap: var(--space-2);
    margin: var(--space-5) 0 var(--space-3) 0;
    align-items: center;
    justify-content: center;
}
.billing-interval-toggle .plan-cta {
    width: auto;
    padding: 8px 18px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
.plan-toggle-savings {
    font-size: var(--text-xs);
    font-weight: 600;
    background: var(--color-success, #0f8a3c);
    color: #fff;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.02em;
}

/* Annual savings callout */
.plan-savings-callout {
    max-width: 1040px;
    margin: 0 auto var(--space-5) auto;
    padding: var(--space-3) var(--space-4);
    background: color-mix(in oklab, var(--color-success, #0f8a3c) 8%, var(--color-surface));
    border: 1px solid color-mix(in oklab, var(--color-success, #0f8a3c) 35%, var(--color-border));
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: var(--text-base);
    text-align: center;
}

/* Per-card price note (under price) */
.plan-price-note {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--space-3);
    line-height: 1.4;
}
.plan-price-note strong { color: var(--color-success, #0f8a3c); }

/* Trial pill — free-tier shops only */
.plan-trial-pill {
    display: inline-block;
    background: color-mix(in oklab, var(--color-success, #0f8a3c) 12%, var(--color-surface));
    color: var(--color-success, #0f8a3c);
    border: 1px solid color-mix(in oklab, var(--color-success, #0f8a3c) 35%, var(--color-border));
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 600;
    margin-bottom: var(--space-3);
}

/* ROI math line per card */
.plan-roi-line {
    background: var(--color-bg);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    line-height: 1.45;
    margin: 0 0 var(--space-4) 0;
}
.plan-roi-line strong { color: var(--color-text); font-weight: 600; }

/* Comparison table */
.plan-compare {
    max-width: 1320px;
    margin: var(--space-12) auto var(--space-10) auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-6);
}
.plan-compare-title {
    font-size: var(--text-2xl);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-5);
    text-align: center;
}
.plan-compare-scroll {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
}
.plan-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-base);
    min-width: 720px;
}
.plan-compare-table th, .plan-compare-table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}
.plan-compare-table thead th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1;
}
.plan-compare-table thead th:first-child { text-align: left; }
.plan-compare-table tbody th {
    font-weight: 500;
    color: var(--color-text);
    width: 38%;
}
.plan-compare-table tbody td {
    text-align: center;
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}
.plan-compare-table .is-highlight {
    background: color-mix(in oklab, var(--color-primary) 5%, var(--color-surface));
    color: var(--color-text);
    font-weight: 500;
}
.plan-compare-section {
    background: var(--color-bg) !important;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-weight: 700;
    text-align: left !important;
    border-top: 2px solid var(--color-border) !important;
    padding-top: var(--space-4) !important;
}
/* Feature tooltip */
.feat-tip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.feat-tip {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-border-strong);
    color: var(--color-text-secondary);
    font-size: 9px;
    font-weight: 700;
    font-family: var(--font-sans);
    line-height: 1;
    border: none;
    cursor: help;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background var(--transition-fast);
}
.feat-tip:hover,
.feat-tip:focus { background: var(--color-primary); color: #fff; outline: none; }
.feat-tip-body {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    max-width: 280px;
    background: var(--color-text);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 400;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    z-index: 30;
    line-height: 1.55;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    pointer-events: none;
    white-space: normal;
}
.feat-tip-wrap:hover .feat-tip-body,
.feat-tip:focus + .feat-tip-body { display: block; }
/* Keep tooltip on-screen when near the right edge of the table */
.plan-compare-table .feat-tip-body { left: auto; right: 0; }

/* Comparison table icon cells */
.cmp-yes {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-success, #0f8a3c);
}
.cmp-yes svg { stroke: var(--color-success, #0f8a3c); }
.cmp-no {
    display: inline-block;
    color: var(--color-border-strong);
    font-size: 1.1em;
    line-height: 1;
}

/* FAQ */
.plan-faq {
    max-width: 880px;
    margin: var(--space-10) auto var(--space-8) auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-6);
}
.plan-faq .plan-compare-title {
    margin-top: 0;
}
.plan-faq-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    margin-bottom: var(--space-3);
    padding: 0;
}
.plan-faq-item summary {
    cursor: pointer;
    list-style: none;
    padding: var(--space-3) var(--space-4);
    font-weight: 500;
    color: var(--color-text);
    font-size: var(--text-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
}
.plan-faq-item summary::-webkit-details-marker { display: none; }
.plan-faq-item summary::after {
    content: "+";
    font-size: var(--text-xl);
    color: var(--color-text-muted);
    font-weight: 400;
    line-height: 1;
}
.plan-faq-item[open] summary::after { content: "−"; }
.plan-faq-body {
    padding: 0 var(--space-4) var(--space-4) var(--space-4);
    color: var(--color-text-secondary);
    font-size: var(--text-base);
    line-height: 1.6;
}
.plan-card {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-6);
    transition: border-color var(--transition-fast), transform var(--transition-fast);
    display: flex;
    flex-direction: column;
    text-align: left;
}
.plan-card:hover {
    border-color: var(--color-border-strong);
}
.plan-card--featured {
    border-color: var(--color-primary);
}
.plan-card--featured:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}
.plan-card--free {
    border-color: var(--color-border);
    background: var(--color-bg);
    opacity: 0.85;
}
.plan-card--free .plan-name,
.plan-card--free .plan-price {
    color: var(--color-text-secondary);
}
.plan-card--recommended {
    border: 2px solid var(--color-success, #0f8a3c);
}
.plan-recommended-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-success, #0f8a3c);
    color: #fff;
    padding: 2px 12px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.plan-card.is-selected {
    border-color: var(--color-primary);
}
.plan-card input[type="radio"] {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
}
.plan-badge {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: var(--space-3);
    align-self: flex-start;
}
.plan-name {
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--color-text);
    margin-bottom: var(--space-2);
}
.plan-price {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    margin-bottom: var(--space-2);
}
.plan-price span {
    font-size: var(--text-md);
    font-weight: 400;
    color: var(--color-text-muted);
    letter-spacing: 0;
}
.plan-description {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-5);
    min-height: 40px;
}
.plan-features {
    list-style: none;
    text-align: left;
    margin: 0 0 var(--space-6) 0;
    padding: 0;
    flex: 1;
}
.plan-features li {
    padding: var(--space-2) 0;
    font-size: var(--text-base);
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
}
.plan-features li:last-child { border-bottom: none; }
.plan-features .feature-value {
    font-weight: 500;
    color: var(--color-success);
}
.plan-features .feature-limited {
    font-weight: 500;
    color: var(--color-text-muted);
}
.plan-cta {
    width: 100%;
    padding: 10px var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
}
.plan-cta:hover { background: var(--color-bg); }
.plan-cta.primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.plan-cta.primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.plan-cta.secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}
.plan-cta:disabled { opacity: 0.5; cursor: not-allowed; }

/* Plans page: "Every plan includes" footer block */
.plans-footer {
    margin-top: var(--space-12);
    padding: var(--space-6);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    max-width: 1040px;
}
.plans-footer h3 {
    font-size: var(--text-md);
    font-weight: 600;
    margin-bottom: var(--space-3);
    color: var(--color-text);
    letter-spacing: -0.01em;
}
.plans-footer ul {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    list-style: none;
    padding: 0;
}
@media (max-width: 800px) {
    .plans-footer ul { grid-template-columns: 1fr; }
}

/* === Onboarding wizard (pages/onboarding.html) ========================== */
.onboarding-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-4);
}
.onboarding-header {
    text-align: center;
    margin-bottom: var(--space-10);
}
.onboarding-header h1 {
    font-size: var(--text-3xl);
    font-weight: 600;
    letter-spacing: -0.025em;
    margin-bottom: var(--space-3);
    color: var(--color-text);
}
.onboarding-header p {
    color: var(--color-text-secondary);
    font-size: var(--text-md);
}
.onboarding-steps {
    display: flex;
    justify-content: center;
    gap: var(--space-6);
    margin-bottom: var(--space-10);
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}
.onboarding-steps .step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.onboarding-steps .dot {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--color-border);
    color: var(--color-text-secondary);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: var(--text-sm);
}
.onboarding-steps .step.active .dot { background: var(--color-primary); color: #fff; }
.onboarding-steps .step.active { color: var(--color-text); font-weight: 600; }

.integration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.integration-card {
    position: relative;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}
.integration-card:hover { border-color: var(--color-border-strong); }
.integration-card input[type="checkbox"] {
    position: absolute; top: var(--space-3); right: var(--space-3);
    width: 18px; height: 18px; cursor: pointer;
    accent-color: var(--color-primary);
}
.integration-card.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}
.integration-card .name { font-weight: 600; margin-bottom: var(--space-1); padding-right: var(--space-6); color: var(--color-text); }
.integration-card .desc { font-size: var(--text-sm); color: var(--color-text-secondary); }

/* Onboarding-only: floating "Recommended" ribbon on a plan-card */
.recommended-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.wizard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-border);
}
.wizard-actions .skip {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: var(--space-2);
}
.wizard-actions .skip:hover { color: var(--color-text); }
.wizard-step { display: none; }
.wizard-step.active { display: block; }

/* === Accessibility: visually hidden text === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === Responsive: table wrapper === */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* === Mobile hamburger toggle === */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 200;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-text);
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.4);
    z-index: 99;
}

/* === Responsive layout === */
@media (max-width: 768px) {
    /* Sidebar (already working — keep as-is) */
    .sidebar-toggle { display: flex; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 200ms ease;
    }
    .sidebar.sidebar--open { transform: translateX(0); }
    .sidebar-overlay.is-visible { display: block; }

    /* Main content — tighter padding, full width */
    .main-content {
        margin-left: 0;
        padding: var(--space-12) var(--space-4) var(--space-4);
        max-width: 100%;
    }

    /* Page header */
    .page-header { margin-bottom: var(--space-5); }
    .page-header h1 { font-size: var(--text-xl); }
    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    .page-toolbar-group {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    /* Cards — smaller padding on mobile */
    .card {
        padding: var(--space-4);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-4);
    }
    .card-header {
        font-size: var(--text-base);
        margin-bottom: var(--space-4);
    }

    /* Stat grid — always 2x2 on mobile, overriding any inline column template */
    .stat-grid,
    .stat-grid[style] {
        grid-template-columns: 1fr 1fr !important;
        gap: var(--space-3);
        margin-bottom: var(--space-5);
    }
    .stat-card { padding: var(--space-4); }
    .stat-value { font-size: var(--text-xl); }
    .stat-label { font-size: var(--text-xs); }
    .mini-stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-3);
    }

    /* Tables — horizontal scroll via a wrapper.
       Target tables directly: turn them into scrollable blocks.
       The existing .table-responsive helper already handles this; we
       mirror the behavior for bare tables that live inside cards. */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .card > table,
    .card > form > table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        white-space: nowrap;
    }
    th, td {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-sm);
    }

    /* Modal — breathing room on mobile, scrollable body */
    .modal-backdrop { padding-top: 40px; padding-bottom: 0; }
    .modal-content {
        margin: var(--space-3);
        width: auto;
        max-width: calc(100% - 2 * var(--space-3));
        max-height: calc(100vh - 2 * var(--space-3));
        padding: var(--space-4);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-md);
    }

    /* Charts — fixed column width so bars stay readable, horizontal scroll
       when the bucket count overflows the viewport. */
    .card:has(#chart-container) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .grouped-bars {
        min-width: 0;
        gap: 3px;
    }
    .grouped-bars-col {
        flex: 0 0 22px;
    }
    .grouped-bars-group {
        gap: 2px;
    }
    .chart-labels {
        min-width: 0;
    }

    /* Tooltip becomes a bottom-sheet on mobile so it escapes the card's
       horizontal scroll container and isn't clipped. Tap a bar to show. */
    .combo-tip {
        position: fixed;
        left: var(--space-4);
        right: var(--space-4);
        bottom: var(--space-4);
        top: auto;
        transform: none;
        margin: 0;
        white-space: normal;
        max-width: none;
        min-width: 0;
        padding: var(--space-3) var(--space-4);
        z-index: 1000;
    }
    .combo-tip::after {
        display: none;
    }
    .combo-tip-row {
        font-size: 0.75rem;
        padding: 3px 0;
    }

    /* Collapse any inline multi-column grid to single column on mobile.
       Inline styles win without !important. */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 2fr"],
    [style*="grid-template-columns: 2fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="grid-template-columns: repeat(3"],
    [style*="grid-template-columns: repeat(4"],
    [style*="grid-template-columns: repeat(2"],
    [style*="grid-template-columns: repeat(auto-fit"],
    [style*="grid-template-columns: repeat(auto-fill"] {
        grid-template-columns: 1fr !important;
    }
    /* .stat-grid is handled above with its own 2x2 rule — re-apply to win
       over the attribute-selector single-column collapse. */
    .stat-grid[style*="grid-template-columns"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Form inputs — 16px to prevent iOS zoom on focus */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px;
    }

    /* Buttons — allow wrap/stretch in toolbars */
    .btn { width: auto; }
    .page-toolbar-group .btn { flex: 1 1 auto; }

    /* Hide anything explicitly marked desktop-only */
    .desktop-only { display: none !important; }
}

@media (max-width: 480px) {
    /* Keep 2x2 even on narrow phones — don't collapse to 1 column */
    .grouped-bar { min-width: 10px; }
}

/* Contextual save bar */
.save-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #1a1a2e;
    color: #ffffff;
    z-index: 1000;
    transform: translateY(-100%);
    transition: transform 200ms ease-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.save-bar--visible {
    transform: translateY(0);
}

.save-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 24px;
    gap: 16px;
}

.save-bar-label {
    font-weight: 500;
    font-size: 14px;
}

.save-bar-actions {
    display: flex;
    gap: 8px;
}

.save-bar-btn {
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 150ms ease;
}

.save-bar-btn-secondary {
    background: transparent;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}

.save-bar-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.save-bar-btn-primary {
    background: #5c6ac4;
    color: #ffffff;
}

.save-bar-btn-primary:hover {
    background: #4c5aa8;
}


/* ============================================================================
 * Utility classes — extracted from templates during the DRY pass
 * (docs/superpowers/specs/2026-04-21-eventabee-template-dry-design.md).
 * Only classes with ≥10 inline-style occurrences land here; ad-hoc styles
 * that appear once or twice stay inline. Do not extend this set casually.
 * ============================================================================ */

/* Spacing — margin-bottom on the existing --space-N scale. */
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

/* Typography */
.text-h2    { font-size: 20px; font-weight: 600; color: var(--color-text); margin: 0 0 16px; }
.text-h3    { font-size: 16px; font-weight: 600; margin: 20px 0 12px; }
.text-muted { color: var(--color-text-secondary); }
.text-danger { color: var(--color-danger); }

/* Layout helpers */
.flex-center { display: flex; align-items: center; gap: 8px; }
.hidden      { display: none; }

/* ============================================================================
 * Badge primitive — see badge.html partial.
 * ============================================================================ */
.badge {
    display: inline-block;
    border-radius: 4px;
    padding: 1px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    vertical-align: middle;
    border: 1px solid transparent;
}
.badge-success { background: var(--badge-success-bg); color: var(--badge-success-fg); border-color: var(--badge-success-border); }
.badge-warning { background: var(--badge-warning-bg); color: var(--badge-warning-fg); border-color: var(--badge-warning-border); }
.badge-danger  { background: var(--badge-danger-bg);  color: var(--badge-danger-fg);  border-color: var(--badge-danger-border); }
.badge-neutral { background: var(--badge-neutral-bg); color: var(--badge-neutral-fg); border-color: var(--badge-neutral-border); }

/* Horizontal-scroll wrapper for wide tables. Use as
   <div class="table-wrap"><table class="data-table">...</table></div>
   so the table can overflow without pushing the page layout off-screen. */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-wrap > table {
    min-width: 100%;
}

/* Cookie-row hover: signals click-to-edit on the Cookies tab. */
tr.cookie-row:hover { background: var(--color-bg); }

/* ---- Consent Timeline (per-visitor consent evolution) ---- */

.consent-timeline {
  position: relative;
  padding-left: 0 !important; /* override the card padding; handled by entry margins */
}

.consent-timeline__entry {
  position: relative;
  padding-left: calc(var(--space-5) + 8px);
  padding-bottom: var(--space-5);
  border-left: 2px solid var(--color-border);
}

.consent-timeline__entry:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}

.consent-timeline__dot {
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-brand, #5c6ac4);
}

.consent-timeline__card {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-4);
}

.consent-timeline__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.consent-timeline__date {
  font-weight: 600;
  font-size: 0.875rem;
}

.consent-timeline__meta {
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  font-family: monospace;
}

.consent-timeline__action {
  margin-bottom: var(--space-3);
}

.consent-timeline__badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-surface-subdued, #f4f6f8);
  color: var(--color-text);
}
.consent-timeline__badge--accept { background: #e6f4ea; color: #1e7c3a; }
.consent-timeline__badge--reject { background: #fdecea; color: #a82a1f; }
.consent-timeline__badge--custom { background: #eef2f7; color: #3d4852; }
.consent-timeline__badge--gpc    { background: #fff4d6; color: #7a4f00; }

.consent-timeline__pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.consent-timeline__pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-family: monospace;
  border: 1px solid var(--color-border);
  background: var(--color-surface-subdued, #f4f6f8);
  color: var(--color-text-secondary);
}
.consent-timeline__pill--on        { background: #e6f4ea; color: #1e7c3a; border-color: #bfe2c9; }
.consent-timeline__pill--off       { background: #fdecea; color: #a82a1f; border-color: #f5c2bd; }
.consent-timeline__pill--on-delta  { background: #fff4d6; color: #7a4f00; border-color: #f2d88a; font-weight: 600; }
.consent-timeline__pill--off-delta { background: #fde2cc; color: #8a3b00; border-color: #f0b98a; font-weight: 600; }

.consent-timeline__meta-change {
  margin-top: var(--space-2);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  font-family: monospace;
}

/* === DSAR — confidence pills ============================================= */

/* Shared pill base: small rounded rectangle, micro font, no gradients */
.confidence-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.03em;
    border: 1px solid transparent;
    white-space: nowrap;
    line-height: 1.4;
}

/* HIGH — sage (muted green, approachable not alarming) */
.confidence-pill.confidence-high {
    background: #e6f4ea;
    color: #1e4a2b;
    border-color: #b7dfc3;
}

/* MEDIUM — honey-deep amber */
.confidence-pill.confidence-medium {
    background: #fff3e0;
    color: #7a4200;
    border-color: #f0c78a;
}

/* LOW — burnt sienna / muted red */
.confidence-pill.confidence-low {
    background: #fdeaea;
    color: #7a1c1c;
    border-color: #f2b8b8;
}

/* === DSAR — confidence summary row ======================================= */

.confidence-summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    padding: var(--space-3) 0;
}

/* === DSAR — SLA warning banner =========================================== */

.sla-banner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    background: var(--color-danger-soft);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
}

.sla-banner__icon {
    color: var(--color-danger);
    font-style: normal;
    flex-shrink: 0;
}

.sla-banner__text {
    color: var(--color-danger);
    font-weight: 500;
    flex: 1;
}

.sla-banner__link {
    color: var(--color-danger);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}

.sla-banner__link:hover {
    color: var(--color-danger);
}

/* === DSAR — review page layout =========================================== */

/* Header breadcrumb + title area */
.dsar-review__header {}

/* Meta panel dl grid — narrows to single column on mobile */
.dsar-review__meta dl {
    grid-template-columns: 160px 1fr;
}
@media (max-width: 640px) {
    .dsar-review__meta dl {
        grid-template-columns: 1fr;
    }
    .dsar-review__meta dt {
        margin-top: var(--space-3);
    }
}

/* Confidence card */
.dsar-review__confidence {}

/* Bundle contents files table */
.dsar-review__files {}

/* Release / refuse action area */
.dsar-review__actions {}

/* Activity timeline card */
.dsar-review__timeline {}

/* ────────────────────────────────────────────────────────────────────────
   Privacy mode — v0.3.5. Blurs PII fields until hovered/focused.
   Off by default; toggled via sidebar button + localStorage. Zero impact
   when body.privacy-mode is absent.
   ──────────────────────────────────────────────────────────────────────── */
html.pre-privacy-mode .pii,
body.privacy-mode .pii {
    filter: blur(6px);
    transition: filter 150ms ease;
    cursor: help;
}
html.pre-privacy-mode .pii:hover,
html.pre-privacy-mode .pii:focus,
html.pre-privacy-mode .pii:focus-within,
body.privacy-mode .pii:hover,
body.privacy-mode .pii:focus,
body.privacy-mode .pii:focus-within {
    filter: none;
}

/* Toggle button in sidebar footer */
.sidebar-privacy-toggle {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    cursor: pointer;
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-sm);
    margin-top: var(--space-2);
    width: 100%;
    justify-content: center;
}
.sidebar-privacy-toggle:hover { color: var(--color-text); border-color: var(--color-text-secondary); }
.sidebar-privacy-toggle[aria-pressed="true"] {
    background: var(--color-warning-soft, #fff4d6);
    border-color: #f0c78a;
    color: var(--accent-deep, #b8851f);
}
.sidebar-privacy-toggle .eye-off { display: none; }
.sidebar-privacy-toggle[aria-pressed="true"] .eye-on { display: none; }
.sidebar-privacy-toggle[aria-pressed="true"] .eye-off { display: inline-block; }

/* D5.4 — deep-link row highlight on the external-domains index when the
   Performance "Verify domain" action passes ?pending=<host>. Warm amber
   tone aligned with the existing --color-warning-soft / --color-warning
   pair so it reads as "attention here" without screaming error. */
.row--highlighted {
    background: var(--color-warning-soft, #fffbeb);
    box-shadow: inset 3px 0 0 0 var(--color-warning, #b45309);
}
.row--highlighted:hover {
    background: var(--color-warning-soft, #fffbeb);
}
