/* === CSS Variables — Modern SaaS (Slate palette) === */
/* Dark theme: Linear/Stripe-inspired deep navy */
:root {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-card: #1E293B;
    --bg-hover: #334155;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent: #c9962b;
    --accent-hover: #d4a640;
    --border: #334155;
    --success: #22C55E;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.2);
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    /* Chart colors — dark mode */
    --chart-revenue: #3B82F6;
    --chart-revenue-fill: rgba(59, 130, 246, 0.12);
    --chart-profit: #22C55E;
    --chart-profit-fill: rgba(34, 197, 94, 0.10);
    --chart-orders: #FBBF24;
    --chart-orders-fill: rgba(251, 191, 36, 0.06);
    --chart-ads: #F59E0B;
    --chart-ads-fill: rgba(245, 158, 11, 0.08);
    --chart-prev: rgba(148, 163, 184, 0.4);
    --chart-grid: rgba(255, 255, 255, 0.04);
    --chart-tick: #64748B;
    --chart-tooltip-bg: rgba(15, 23, 42, 0.95);
    --chart-tooltip-border: rgba(51, 65, 85, 0.6);
    --chart-tooltip-text: #F1F5F9;
    --chart-hover-border: #1E293B;
}

/* Light theme: Stripe-inspired clean white */
[data-theme="light"] {
    --bg-primary: #F8FAFC;
    --bg-secondary: #F1F5F9;
    --bg-card: #FFFFFF;
    --bg-hover: #F1F5F9;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --accent: #c9962b;
    --accent-hover: #b8891f;
    --border: #E2E8F0;
    --success: #16A34A;
    --warning: #D97706;
    --error: #DC2626;
    --info: #2563EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 20px rgba(0, 0, 0, 0.06);
    /* Chart colors — light mode */
    --chart-revenue: #2563EB;
    --chart-revenue-fill: rgba(37, 99, 235, 0.08);
    --chart-profit: #16A34A;
    --chart-profit-fill: rgba(22, 163, 74, 0.06);
    --chart-orders: #CA8A04;
    --chart-orders-fill: rgba(202, 138, 4, 0.05);
    --chart-ads: #D97706;
    --chart-ads-fill: rgba(217, 119, 6, 0.06);
    --chart-prev: rgba(100, 116, 139, 0.35);
    --chart-grid: rgba(0, 0, 0, 0.04);
    --chart-tick: #64748B;
    --chart-tooltip-bg: rgba(255, 255, 255, 0.97);
    --chart-tooltip-border: rgba(0, 0, 0, 0.06);
    --chart-tooltip-text: #0F172A;
    --chart-hover-border: #FFFFFF;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { overflow-x: hidden; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* === Layout === */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.2s ease;
}

.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .logo-text { display: none; }

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-accent { color: var(--accent); }

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
}

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 12px;
}

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--border);
}

/* === Main content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* === Top bar === */
.top-bar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-left { display: flex; align-items: center; gap: 16px; }
.top-bar-right { display: flex; align-items: center; gap: 16px; }

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.page-title {
    font-size: 1rem;
    font-weight: 600;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}
.theme-toggle:hover { background: var(--bg-hover); }

.user-email {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
}
.btn-logout:hover { border-color: var(--error); color: var(--error); }

/* === Content area === */
.content-area {
    padding: 24px;
    max-width: 1400px;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.card-welcome {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-hover));
    border-color: var(--accent);
}
.card-welcome h2 { font-size: 1.5rem; margin-bottom: 4px; }

/* === Home grid === */
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

/* === Services === */
.services-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.service-badge {
    display: inline-block;
    padding: 6px 16px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.15s;
}
.service-badge:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-full { width: 100%; justify-content: center; }

/* === Quick actions === */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* === Empty state === */
.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 12px; }

/* === Text utilities === */
.text-muted { color: var(--text-muted); }

/* === Auth page === */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.auth-container { width: 100%; max-width: 400px; padding: 20px; }

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}
.auth-header .logo-text { font-size: 1.5rem; }
.auth-header p { margin-top: 8px; }

.auth-form { margin-bottom: 0; }

.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font);
}
.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201, 150, 43, 0.15);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.form-status {
    margin-top: 12px;
    font-size: 0.8125rem;
    text-align: center;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.75rem;
}

/* === KPI Cards (Apple spacing + Stripe typography) === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 12px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.15s, transform 0.15s;
}
.kpi-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    white-space: nowrap;
}

.kpi-change {
    font-size: 0.8125rem;
    margin-top: 6px;
    font-weight: 500;
}
.kpi-change.positive { color: var(--success); }
.kpi-change.negative { color: var(--error); }

/* === Pulse — Sub-navigation === */
.pulse-subnav {
    display: flex;
    gap: 4px;
    background: var(--bg-elevated, rgba(255,255,255,0.04));
    border-radius: var(--radius-sm, 6px);
    padding: 3px;
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.subnav-item {
    padding: 8px 16px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm, 4px);
    white-space: nowrap;
    transition: all 0.15s;
}

.subnav-item:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
}

.subnav-item.active {
    color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.subnav-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* === Pulse — Date range bar === */
.pulse-header {
    margin-bottom: 24px;
}

.date-range-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.pulse-options-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.pulse-option-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    user-select: none;
}

.pulse-expand-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    animation: fadeIn 0.15s ease;
}

/* Invisible spacer — same width as range buttons so compare dates align under main dates */
.range-buttons-spacer {
    /* 4 buttons × ~56px + 3 gaps × 4px = ~236px; fine-tuned to match .range-buttons */
    min-width: 0;
    flex: 0 0 auto;
    width: var(--range-buttons-width, 0px);
}

.btn-source {
    font-size: 0.75rem !important;
    padding: 2px 10px !important;
}

.date-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.range-buttons {
    display: flex;
    gap: 4px;
}

.btn-range {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-range:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-range.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.date-custom-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: var(--font);
    cursor: pointer;
    color-scheme: dark;
}

[data-theme="light"] .date-input {
    color-scheme: light;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent);
}

.date-separator {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* === Pulse — Charts === */
.chart-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.chart-card .card-header h3 {
    margin-bottom: 0;
}

/* Hero chart — full-width, taller */
.chart-card--hero {}

.chart-container--hero {
    position: relative;
    height: 360px;
}

/* Metric pill switcher (legacy) */
.chart-metric-pills {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary, rgba(255,255,255,0.04));
    border-radius: var(--radius-sm);
    padding: 2px;
}

.chart-pill {
    padding: 4px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chart-pill:hover {
    color: var(--text-primary);
}

.chart-pill.active {
    background: var(--accent);
    color: #fff;
}

/* Chart legend toggle buttons (multi-metric) */
.chart-legend-toggles {
    display: flex;
    gap: 6px;
    align-items: center;
}
.chart-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.5;
}
.chart-toggle:hover { color: var(--text-primary); opacity: 0.75; }
.chart-toggle.active {
    color: var(--text-primary);
    border-color: var(--text-muted);
    opacity: 1;
}
.chart-toggle-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-container {
    position: relative;
    height: 300px;
}

.chart-container-sm {
    height: 220px;
}

.chart-legend {
    display: flex;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* === Pulse — Data tables === */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 12px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table .text-right {
    text-align: right;
}

.data-table .product-name {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Pulse — Status badges === */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.status-ok, .status-active {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

.status-error, .status-failed {
    background: rgba(248, 81, 73, 0.15);
    color: var(--error);
}

.status-pending, .status-syncing {
    background: rgba(210, 153, 34, 0.15);
    color: var(--warning);
}

/* === Pulse — content containers === */
#pulse-content,
#sales-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* === Pulse — grid layouts === */
.pulse-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: stretch;
}
.pulse-grid-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

/* === Insights card === */
.insights-card { min-height: 100%; }
.insights-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.insights-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.insights-grid-2col .insight-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.insights-grid-2col .insight-item:nth-child(2n) { border-right: none; }
.insights-grid-2col .insight-item:nth-last-child(-n+2) { border-bottom: none; }
.insights-grid-2col .insight-item--full { grid-column: 1 / -1; border-right: none; border-bottom: none; }
.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.insight-item:last-child { border-bottom: none; padding-bottom: 0; }
.insight-item:first-child { padding-top: 0; }
.insights-grid-2col .insight-item:first-child { padding-top: 10px; }
.insights-grid-2col .insight-item:last-child { padding-bottom: 10px; }
.insight-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-primary);
    flex-shrink: 0;
}
.insight-icon--up { color: var(--success); border-color: var(--success); background: rgba(63, 185, 80, 0.1); }
.insight-icon--down { color: var(--error); border-color: var(--error); background: rgba(248, 81, 73, 0.1); }
.insight-icon--warn { color: var(--warning); border-color: var(--warning); background: rgba(210, 153, 34, 0.1); }
.insight-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.insight-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}
.insight-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* === Alert archive === */
.alert-archived {
    opacity: 0.55;
    border-left-width: 2px;
}
.alert-archived .alert-body {
    max-height: 36px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Pulse — Placeholder dashboard === */
.placeholder-dashboard {
    display: flex;
    justify-content: center;
    padding-top: 40px;
}

.placeholder-card {
    text-align: center;
    max-width: 480px;
    padding: 48px 32px;
}

.placeholder-icon {
    margin-bottom: 16px;
}

.placeholder-icon svg {
    width: 48px;
    height: 48px;
    color: var(--accent);
}

.placeholder-card h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.placeholder-features {
    margin: 24px 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.placeholder-feature {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.feature-check {
    color: var(--success);
    font-weight: 700;
}

.placeholder-cta {
    margin-top: 24px;
}

/* === Settings page === */
.settings-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
}
.settings-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.settings-tab:hover { color: var(--text-primary); }
.settings-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.settings-tab-content { animation: fadeIn 0.15s ease; }

.settings-header { margin-bottom: 32px; }
.settings-header h2 { font-size: 1.25rem; margin-bottom: 4px; }

.settings-section {
    margin-bottom: 32px;
}
.settings-section h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.connectors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.connector-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.15s;
}
.connector-card:hover { border-color: var(--accent); }
.connector-card.connected { border-left: 3px solid var(--success); }

.connector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.connector-name {
    font-weight: 600;
    font-size: 0.9375rem;
}
.connector-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.connector-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.75rem;
}
.connector-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}
.btn-danger {
    border-color: var(--error);
    color: var(--error);
}
.btn-danger:hover {
    background: var(--error);
    color: #fff;
}

.profile-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.theme-options {
    display: flex;
    gap: 8px;
}

/* ═══════════════════════════════════════
   === Content / Support / Messages CSS ===
   ═══════════════════════════════════════ */

/* Shared: content-header bar */
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.content-header-left, .content-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-select {
    padding: 7px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: var(--font);
    cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

/* Badges — generalized */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-lg { font-size: 0.8125rem; padding: 4px 14px; }
.badge-gold  { background: rgba(210, 153, 34, 0.18); color: var(--warning); }
.badge-green { background: rgba(63, 185, 80, 0.18); color: var(--success); }
.badge-red   { background: rgba(248, 81, 73, 0.18); color: var(--error); }
.badge-blue  { background: rgba(88, 166, 255, 0.18); color: var(--info); }
.badge-gray  { background: var(--bg-hover); color: var(--text-muted); }
.badge-info  { background: rgba(88, 166, 255, 0.12); color: var(--info); }
.auto-badge  { margin-left: 4px; font-size: 0.6875rem; opacity: 0.85; }

/* Buttons — extra variants */
.btn-green { background: var(--success); color: #fff; border: none; }
.btn-green:hover { background: #2ea043; color: #fff; }
.btn-red { background: var(--error); color: #fff; border: none; }
.btn-red:hover { background: #c93025; color: #fff; }
.btn-red-outline { border-color: var(--error); color: var(--error); }
.btn-red-outline:hover { background: var(--error); color: #fff; }
.inline-form { display: flex; flex-direction: column; gap: 8px; }

/* Form elements — global */
.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font);
}
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font);
    resize: vertical;
}
.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201, 150, 43, 0.12);
}
.form-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* Toggle / checkbox */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Info boxes */
.info-box {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 16px;
}
.info-active  { background: rgba(63, 185, 80, 0.12); border: 1px solid rgba(63, 185, 80, 0.3); color: var(--success); }
.info-inactive{ background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-muted); }
.info-note    { background: rgba(88, 166, 255, 0.08); border: 1px solid rgba(88, 166, 255, 0.2); color: var(--info); }

/* Settings form */
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-content { max-width: 640px; }

/* Detail header */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.detail-header h2 { font-size: 1.125rem; margin-bottom: 8px; }
.detail-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

/* Content body */
.content-body {
    font-size: 0.9375rem;
    line-height: 1.75;
    white-space: pre-wrap;
}

/* Metadata grid */
.metadata-grid { display: flex; flex-direction: column; gap: 8px; }
.meta-row {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.meta-label { min-width: 140px; font-weight: 500; color: var(--text-secondary); }
.meta-value { color: var(--text-primary); }

/* Attachments */
.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.attachment-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    transition: border-color 0.15s;
}
.att-approved { border-left: 3px solid var(--success); }
.att-pending  { border-left: 3px solid var(--warning); }
.att-thumb { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; margin-bottom: 8px; }
.att-file-icon {
    width: 100%; height: 120px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover); border-radius: 6px;
    font-size: 0.75rem; color: var(--text-muted);
    margin-bottom: 8px;
}
.att-info { display: flex; flex-direction: column; gap: 4px; font-size: 0.8125rem; }
.att-name { font-weight: 500; word-break: break-word; }
.att-ai { color: var(--info); font-size: 0.75rem; }
.att-size { color: var(--text-muted); font-size: 0.75rem; }
.att-actions { display: flex; gap: 6px; margin-top: 8px; }

/* Reject / revision panel */
.action-buttons { margin-bottom: 16px; }
.reject-panel { margin-top: 16px; }
.revision-options { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.revision-option {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s;
}
.revision-option:has(input:checked) { border-color: var(--accent); background: rgba(201, 150, 43, 0.06); }
.revision-option strong { display: block; margin-bottom: 2px; }
.revision-option p { font-size: 0.8125rem; color: var(--text-muted); margin: 0; }

/* Revision history */
.revision-entry {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.revision-entry:last-child { border-bottom: none; }
.rev-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.rev-feedback { font-size: 0.875rem; color: var(--text-secondary); }

/* Message thread */
.message-thread {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}
.message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    max-width: 85%;
}
.msg-admin {
    background: rgba(201, 150, 43, 0.1);
    border-left: 3px solid var(--accent);
    align-self: flex-start;
}
.msg-client {
    background: var(--bg-hover);
    border-right: 3px solid var(--info);
    align-self: flex-end;
}
.msg-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.msg-body { font-size: 0.875rem; line-height: 1.6; }
.message-form { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 8px; }

/* Audit log */
.audit-content { max-width: 1100px; }
.audit-details pre {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 6px;
}

/* Messages feed */
.threads-list { display: flex; flex-direction: column; }
.thread-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    color: var(--text-primary);
}
.thread-item:last-child { border-bottom: none; }
.thread-item:hover { background: var(--bg-hover); }
.thread-icon { flex-shrink: 0; color: var(--text-muted); }
.thread-info { flex: 1; min-width: 0; }
.thread-title { font-weight: 500; margin-bottom: 4px; }
.thread-preview { font-size: 0.8125rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.thread-date { font-size: 0.75rem; color: var(--text-muted); }

/* Ticket / content detail gap helpers */
.content-detail { display: flex; flex-direction: column; gap: 20px; }
.ticket-detail { display: flex; flex-direction: column; gap: 20px; }
.create-ticket { max-width: 640px; }

/* === Pulse v5 — Profit Intelligence === */

/* Business Status Bar — 1-line summary at the top */
.business-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.875rem;
}
.business-status--good {
    background: rgba(34, 197, 94, 0.08);
    border-left: 4px solid var(--success);
}
.business-status--warning {
    background: rgba(245, 158, 11, 0.08);
    border-left: 4px solid var(--warning);
}
.business-status--critical {
    background: rgba(239, 68, 68, 0.08);
    border-left: 4px solid var(--error);
}
.business-status--neutral {
    background: rgba(59, 130, 246, 0.06);
    border-left: 4px solid var(--info);
}
.business-status__main {
    display: flex;
    align-items: center;
    gap: 10px;
}
.business-status__icon {
    font-size: 1rem;
}
.business-status--good .business-status__icon { color: var(--success); }
.business-status--warning .business-status__icon { color: var(--warning); }
.business-status--critical .business-status__icon { color: var(--error); }
.business-status--neutral .business-status__icon { color: var(--info); }
.business-status__message {
    font-weight: 600;
    color: var(--text-primary);
}
.business-status__details {
    display: flex;
    gap: 20px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.business-status__details strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Sync status bar */
.sync-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.sync-bar__sources {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.sync-source { display: flex; align-items: center; gap: 3px; }
.sync-source--ok strong { color: var(--success); }
.sync-source--syncing strong { color: var(--accent); }
.sync-source--error strong { color: var(--error); }
.sync-source--pending strong { color: var(--text-secondary); }
.sync-error-icon { color: var(--error); cursor: help; }
.sync-spinner { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-xs { padding: 2px 8px; font-size: 0.7rem; }
.sync-bar__btn { white-space: nowrap; }

/* KPI highlight card (net profit) */
.kpi-card--highlight {
    border: 2px solid var(--accent);
    background: linear-gradient(135deg, var(--bg-card), rgba(201, 150, 43, 0.06));
}

/* Profit / loss text colors */
.text-profit { color: var(--success); }
.text-loss { color: var(--error); }

/* Margin badges */
.margin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.margin-high { background: rgba(63, 185, 80, 0.15); color: var(--success); }
.margin-medium { background: rgba(210, 153, 34, 0.15); color: var(--warning); }
.margin-low { background: rgba(248, 81, 73, 0.15); color: var(--error); }

/* Segment bar (margin segments visualization) */
.segment-bar {
    display: flex;
    height: 28px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
}
.segment-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #fff;
    min-width: 20px;
    transition: width 0.3s ease;
}
.segment-fill--high { background: var(--success); }
.segment-fill--medium { background: var(--warning); }
.segment-fill--low { background: var(--error); }

.segment-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}
.segment-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.segment-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.segment-warning {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(248, 81, 73, 0.08);
    border: 1px solid rgba(248, 81, 73, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--error);
}

/* Horizontal bar chart (replaces doughnuts) */
.hbar-list { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: flex; align-items: center; gap: 10px; }
.hbar-label {
    flex: 0 0 100px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hbar-track {
    flex: 1;
    height: 22px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
}
.hbar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--color-blue, #58a6ff);
    transition: width 0.4s ease;
    min-width: 2px;
}
.hbar-value {
    flex: 0 0 130px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}
.hbar-pct {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Alert cards — vertical layout */
.alert-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: border-color 0.15s;
}
.alert-card:hover { border-color: var(--text-muted); }

.alert-card--warning { border-left: 3px solid var(--warning); }
.alert-card--critical { border-left: 3px solid var(--error); }
.alert-card--info { border-left: 3px solid var(--info); }

.alert-type-icon { font-size: 1rem; flex-shrink: 0; }
.alert-card__content { flex: 1; min-width: 0; }
.alert-card__top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.alert-severity-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}
.alert-severity-badge--warning { background: rgba(210, 153, 34, 0.18); color: var(--warning); }
.alert-severity-badge--critical { background: rgba(248, 81, 73, 0.18); color: var(--error); }
.alert-severity-badge--info { background: rgba(88, 166, 255, 0.18); color: var(--info); }

.alert-title {
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.alert-message {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.alert-time {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
}

.alert-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.8125rem;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
    white-space: nowrap;
}
.alert-dismiss:hover { color: var(--text-primary); }

/* Channel stats (marketing page) */
.channel-stats {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.channel-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}
.channel-stat-row:last-child { border-bottom: none; }
.channel-stat-label { color: var(--text-secondary); }
.channel-stat-value { font-weight: 600; color: var(--text-primary); }

/* === Tooltips (metric ?) === */
.metric-tooltip {
    position: relative;
    display: inline-flex;
    cursor: help;
    margin-left: 4px;
    vertical-align: middle;
}
.metric-tooltip__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-muted);
    font-size: 0.625rem;
    font-weight: 700;
    transition: all 0.15s;
}
.metric-tooltip:hover .metric-tooltip__icon,
.metric-tooltip:focus .metric-tooltip__icon {
    background: var(--accent);
    color: #fff;
}
.metric-tooltip__popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-secondary);
    z-index: 200;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}
.metric-tooltip:hover .metric-tooltip__popup,
.metric-tooltip:focus .metric-tooltip__popup {
    display: block;
}
.metric-tooltip__popup strong {
    color: var(--text-primary);
    font-size: 0.875rem;
}
.metric-tooltip__formula {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 6px;
    background: var(--bg-hover);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--accent);
}
body.hide-tooltips .metric-tooltip { display: none; }

/* === Target progress bar === */
.target-card {
    display: flex;
    flex-direction: column;
}
.target-card .target-forecast {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.pulse-grid-2col > .card {
    display: flex;
    flex-direction: column;
}
.pulse-grid-2col > .card > .card-header {
    flex-shrink: 0;
}
.target-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.target-header h3 { margin-bottom: 0; }
.target-bar-wrap { margin-bottom: 4px; }
.target-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.target-bar {
    height: 20px;
    background: var(--bg-hover);
    border-radius: 10px;
    overflow: hidden;
}
.target-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 10px;
    transition: width 0.5s ease;
    min-width: 4px;
}
.target-bar--profit { height: 14px; border-radius: 7px; }
.target-bar__fill--profit {
    background: linear-gradient(90deg, var(--success), #2ea043);
    border-radius: 7px;
}
.target-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 4px;
}
.target-pct { font-weight: 700; color: var(--accent); }

/* Target forecast (fills empty space under progress bars) */
.target-forecast {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.target-forecast__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.target-forecast__icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
}
.target-forecast__icon--ahead {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}
.target-forecast__icon--behind {
    background: rgba(248, 81, 73, 0.15);
    color: var(--error);
}
.target-forecast__icon--ok {
    background: rgba(210, 153, 34, 0.15);
    color: var(--warning);
}
.target-forecast__pace {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}
.target-forecast__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.target-forecast__item {
    padding: 8px 0;
}
.target-forecast__label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.target-forecast__value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}
.target-forecast__sub {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* === Help icon (Settings tooltips) === */
.help-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--bg-hover); color: var(--text-muted);
    font-size: 0.625rem; font-weight: 700; cursor: help;
    vertical-align: middle; margin-right: 4px;
}
.connector-help { opacity: 0.8; }
.connector-help:hover { opacity: 1; }

/* === Report presets === */
.preset-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.btn-preset {
    padding: 8px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text-secondary); cursor: pointer; font-size: 0.8125rem;
    transition: all 0.2s;
}
.btn-preset:hover { border-color: var(--accent); color: var(--text-primary); }
.btn-preset.active { border-color: var(--accent); background: var(--accent); color: #fff; }

/* === Modal (connect connector) === */
.modal-overlay {
    position: fixed; inset: 0; z-index: 9900;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-content {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid var(--border); padding: 24px;
    width: 90%; box-shadow: 0 24px 60px rgba(0,0,0,0.4);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.modal-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer; padding: 0 4px; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.status-badge.status-syncing { background: var(--accent); color: #111; animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }

/* === Responsive — tablet === */
@media (max-width: 1024px) {
    .pulse-grid-3col { grid-template-columns: 1fr 1fr; }
    .pulse-grid-3col > :nth-child(3) { grid-column: 1 / -1; }
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; inset: 0; right: auto;
        transform: translateX(-100%);
        width: var(--sidebar-width);
        z-index: 9500;
        transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop {
        display: none; position: fixed; inset: 0;
        background: rgba(0,0,0,0.5); z-index: 9400;
    }
    .sidebar.open ~ .sidebar-backdrop { display: block; }
    .main-content { margin-left: 0; }
    .content-area { padding: 16px; }
    .home-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .pulse-grid-2col { grid-template-columns: 1fr; }
    .pulse-grid-3col { grid-template-columns: 1fr; }
    .date-range-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
    .range-buttons { flex-wrap: wrap; }
    .date-custom-form { flex-wrap: wrap; }
    .date-input { width: 130px; }
    .connector-card { padding: 12px; }
    .connectors-grid { grid-template-columns: 1fr; }
    .settings-form .form-group { margin-bottom: 12px; }

    /* Top bar — prevent overflow */
    .top-bar { padding: 0 12px; gap: 8px; overflow: hidden; }
    .top-bar-right { gap: 8px; }
    .user-email { display: none; }
    .page-title { font-size: 0.875rem; }

    /* Funnel — stack on mobile */
    .funnel-step { flex-wrap: wrap; gap: 4px !important; }
    .funnel-step > div:first-child { width: 100% !important; text-align: left !important; }
    .funnel-step > div:nth-child(3),
    .funnel-step > div:nth-child(4) { width: auto !important; }
}

/* === Mobile-first KPI view (<640px) === */
@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi-card { padding: 12px; overflow: hidden; }
    .kpi-value { font-size: 1.25rem; }
    .kpi-label { font-size: 0.625rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .kpi-change { font-size: 0.6875rem; }

    .chart-container { height: 200px; }
    .chart-container--hero { height: 240px; }
    .chart-container-sm { height: 160px; }
    .chart-metric-pills { gap: 1px; }
    .chart-pill { padding: 3px 10px; font-size: 0.6875rem; }
    .chart-legend-toggles { gap: 4px; flex-wrap: wrap; }
    .chart-toggle { padding: 3px 8px; font-size: 0.6875rem; }

    /* Stack everything single column */
    .pulse-grid-2col { grid-template-columns: 1fr; gap: 12px; }
    .pulse-grid-3col { grid-template-columns: 1fr; gap: 12px; }

    /* Compact cards */
    .card { padding: 16px; margin-bottom: 12px; }
    .card h3 { font-size: 0.75rem; }

    /* Content overflow prevention */
    .content-area { overflow-x: hidden; }

    /* Compact data tables — scrollable on mobile */
    .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
    .card { overflow: hidden; }
    .card > .data-table-wrap,
    .card > table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 380px; }
    .data-table th, .data-table td { padding: 6px 8px; font-size: 0.8125rem; white-space: nowrap; }
    .data-table .product-name { max-width: 120px; }
    .data-table .hide-mobile { display: none; }

    /* Target bar compact */
    .target-bar { height: 14px; }
    .target-meta { font-size: 0.75rem; }

    /* Subnav scroll */
    .pulse-subnav { gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
    .subnav-item { padding: 8px 12px; font-size: 0.75rem; white-space: nowrap; flex-shrink: 0; }

    /* Pulse options row — stack on mobile */
    .pulse-options-row { flex-direction: column; gap: 6px; align-items: flex-start !important; }
    .pulse-option-toggle { font-size: 0.75rem; }
    .range-buttons-spacer { display: none; }

    /* Business status — stack on mobile */
    .business-status { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 16px; }
    .business-status__details { flex-wrap: wrap; gap: 8px 16px; font-size: 0.75rem; }
    .business-status__message { font-size: 0.8125rem; }

    /* Forecast card — stack values */
    #forecast-container .card > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; gap: 12px !important; }
}

/* ═══ AI Advisor Card ═══ */

.advisor-card { border-left: 3px solid var(--accent, #6366f1); }
.advisor-refresh-btn__loading { display: none; }
.advisor-refresh-btn.htmx-request .advisor-refresh-btn__text { display: none; }
.advisor-refresh-btn.htmx-request .advisor-refresh-btn__loading { display: inline; }
.advisor-refresh-btn.htmx-request { opacity: 0.6; cursor: wait; }

.advisor-loading {
    padding: 24px; text-align: center; color: var(--text-muted);
    font-size: 0.85rem;
}
.loading-dots::after {
    content: ''; animation: dots 1.5s steps(4,end) infinite;
}
@keyframes dots {
    0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; }
}

.advisor-item {
    padding: 12px 16px; border-left: 4px solid var(--border);
    margin: 0 16px; border-radius: 0;
    border-bottom: 1px solid var(--border);
}
.advisor-item:last-child { border-bottom: none; }
.advisor-item--critical {
    border-left-color: #ef4444;
    background: rgba(239,68,68,0.06);
}
.advisor-item--important {
    border-left-color: #f59e0b;
    background: rgba(245,158,11,0.05);
}
.advisor-item--nice_to_have {
    border-left-color: #22c55e;
    background: rgba(34,197,94,0.04);
}

.advisor-item__header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px; font-size: 0.85rem;
}

.advisor-icon {
    width: 20px; height: 20px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px; padding: 2px;
}
.advisor-icon--revenue { color: #22c55e; }
.advisor-icon--marketing { color: #6366f1; }
.advisor-icon--product { color: #f59e0b; }
.advisor-icon--conversion { color: #3b82f6; }
.advisor-icon--costs { color: #ef4444; }

.advisor-priority {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; padding: 2px 6px; border-radius: 3px;
    flex-shrink: 0;
}
.advisor-priority--critical {
    color: #ef4444; background: rgba(239,68,68,0.12);
}
.advisor-priority--important {
    color: #f59e0b; background: rgba(245,158,11,0.12);
}
.advisor-priority--nice_to_have {
    color: #22c55e; background: rgba(34,197,94,0.12);
}

.advisor-explanation {
    font-size: 0.82rem; color: var(--text-secondary); margin: 4px 0;
    line-height: 1.4;
}

.advisor-action {
    font-size: 0.8rem; color: var(--accent, #6366f1);
    font-weight: 500; margin-top: 6px;
}

.advisor-notice {
    padding: 8px 16px; font-size: 0.8rem; color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.advisor-notice--tip {
    background: rgba(99,102,241,0.08);
}
.advisor-notice a { color: var(--accent); text-decoration: underline; }

.advisor-empty {
    padding: 24px 16px; text-align: center; color: var(--text-muted);
    font-size: 0.85rem;
}

.advisor-more { margin: 0 16px 12px; }
.advisor-more-btn {
    font-size: 0.8rem; color: var(--accent); cursor: pointer;
    padding: 8px 0; list-style: none;
}
.advisor-more-btn::-webkit-details-marker { display: none; }

/* Store profile form */
.store-profile-form .form-group { margin-bottom: 16px; }
.store-profile-form label { display: block; font-size: 0.82rem; font-weight: 500; margin-bottom: 4px; }
.store-profile-form .form-input {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: 6px; background: var(--bg-card); color: var(--text-primary);
    font-size: 0.85rem; font-family: inherit;
}
.store-profile-form textarea.form-input { resize: vertical; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.checkbox-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.82rem; cursor: pointer;
}
.checkbox-label input[type="checkbox"] { accent-color: var(--accent, #6366f1); }
