:root {
  /* === 12 STOREEZ (фирменный коричневый) — тема по умолчанию === */
  --primary: #4F3E35; --primary-hover: #3A2D26; --secondary: #BD9E6D;
  --accent-1: #7A685B; --accent-2: #A89583; --accent-3: #6B5446; --accent-4: #C4A996;
  --accent-5: #8A7A6A; --accent-6: #968472; --accent-7: #B89984; --accent-8: #8A6E58;
  --neutral: #8A817A; --neutral-2: #9C9388; --neutral-3: #5C534A;
  --bg-page: #F7F3EC; --bg-soft: #FBF8F3; --border-soft: #DBD7D2; --border-soft-2: #CDC6BC;
  --primary-rgb: 79, 62, 53; --secondary-rgb: 189, 158, 109; --accent-2-rgb: 168, 149, 131;
  --success: #10B981; --warning: #F59E0B; --danger: #EF4444; --pending: var(--neutral);
}
/* === Стандартный дизайн (тумблер в Настройках → data-theme="standard") === */
html[data-theme="standard"] {
  --primary: #3B82F6; --primary-hover: #2563EB; --secondary: #8B5CF6;
  --accent-1: #6366F1; --accent-2: #60A5FA; --accent-3: #7C3AED; --accent-4: #F472B6;
  --accent-5: #06B6D4; --accent-6: #0EA5E9; --accent-7: #818CF8; --accent-8: #9333EA;
  --neutral: #64748B; --neutral-2: #94A3B8; --neutral-3: #475569;
  --bg-page: #F1F5F9; --bg-soft: #F8FAFC; --border-soft: #E2E8F0; --border-soft-2: #CBD5E1;
  --primary-rgb: 59, 130, 246; --secondary-rgb: 139, 92, 246; --accent-2-rgb: 96, 165, 250;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
a { text-decoration: none; color: inherit; }
a:hover { text-decoration: none; }
body { font-family: 'Inter', sans-serif; height: 100vh; display: flex; overflow: hidden; transition: background-color 0.3s, color 0.3s; }
body > div:not(.modal-overlay):not(.bgd-modal-overlay):not(.tour-overlay) { flex: 1; min-width: 0; }

/* ---- DARK ---- */
body.dark { background: #1C140F; color: var(--bg-soft); --border: #2A211B; --bg-card: #2A211B; --text-muted-c: var(--neutral-2); --card-bg-alt: #2A211B; }
body.dark .sidebar { background: #1C140F; border-color: #2A211B; }
body.dark .sidebar-link { color: var(--neutral-2); }
body.dark .sidebar-link:hover { background: #2A211B; color: var(--bg-soft); }
body.dark .sidebar-link.active { background: var(--primary); color: #fff; }
body.dark .sidebar .section-title { color: var(--neutral-3); }
body.dark .topbar { background: #1C140F; border-color: #2A211B; }
body.dark .main-area { background: #1C140F; }
body.dark .kpi-card { background: #2A211B; border-color: rgba(62, 52, 42,0.5); }
body.dark .kpi-label { color: var(--neutral-2); }
body.dark .kpi-value { color: var(--bg-soft); }
body.dark .card { background: #2A211B; border-color: rgba(62, 52, 42,0.5); }
body.dark .card-title { color: var(--bg-soft); }
body.dark .text-muted { color: var(--neutral-2); }
body.dark .activity-item { border-color: rgba(62, 52, 42,0.3); }
body.dark .activity-item:hover { background: rgba(42, 33, 27,0.5); }
body.dark .badge-tag { background: #2A211B; color: var(--border-soft-2); }
body.dark .user-area { border-color: #2A211B; }
body.dark .user-name { color: var(--bg-soft); }
body.dark .user-role { color: var(--neutral-3); }
body.dark .topbar-btn { color: var(--neutral-2); }
body.dark .topbar-btn:hover { color: var(--bg-soft); }
body.dark .theme-sw { color: var(--neutral-2); }
body.dark .scenario-card { background: rgba(62, 52, 42,0.2); border-color: rgba(62, 52, 42,0.5); }
body.dark .scenario-btn { border-color: var(--neutral-3); color: var(--border-soft-2); }
body.dark .scenario-btn:hover { background: #463A30; color: var(--bg-soft); }
body.dark .bar-bg, body.dark .churn-bar-bg { background: #463A30; }
body.dark .filter-tag { background: rgba(62, 52, 42,0.3); color: var(--neutral-2); border-color: rgba(62, 52, 42,0.5); }
body.dark .filter-tag.active { background: rgba(var(--primary-rgb),0.15); color: var(--accent-2); border-color: rgba(var(--primary-rgb),0.3); }
body.dark .topbar-tab { color: var(--neutral); }
body.dark .topbar-tab.active { color: var(--bg-soft); }
body.dark .topbar-tab-link { color: var(--neutral); }
body.dark .topbar-tab-link.active { color: var(--bg-soft); }
body.dark .period-btn { background: #463A30; color: var(--neutral-2); }
body.dark .period-btn.active { background: var(--neutral-3); color: #fff; }
body.dark .data-table th { background: rgba(28, 21, 16,0.5); color: var(--neutral); border-color: #2A211B; }
body.dark .data-table td { border-color: rgba(62, 52, 42,0.3); color: var(--border-soft-2); }
body.dark .data-table tr:hover td { background: rgba(42, 33, 27,0.5); }
body.dark .rfm-plot { background: rgba(28, 21, 16,0.5); border-color: #463A30; }
body.dark .action-card { background: rgba(62, 52, 42,0.2); border-color: rgba(62, 52, 42,0.5); }
body.dark .ai-rec { background: rgba(62, 52, 42,0.2); border-color: rgba(62, 52, 42,0.5); }
body.dark .segment-item { border-color: rgba(62, 52, 42,0.3); }
body.dark .placeholder-icon { color: #463A30; }
body.dark ::-webkit-scrollbar-track { background: #1C140F; }
body.dark ::-webkit-scrollbar-thumb { background: #463A30; }

/* ---- LIGHT ---- */
body.light { background: var(--bg-page); color: #1C140F; --border: var(--border-soft); --bg-card: #FFFFFF; --text-muted-c: var(--neutral); --card-bg-alt: var(--border-soft); }
body.light .sidebar { background: #FFFFFF; border-color: var(--border-soft); }
body.light .sidebar-link { color: var(--neutral); }
body.light .sidebar-link:hover { background: var(--bg-page); color: #1C140F; }
body.light .sidebar-link.active { background: var(--primary); color: #fff; }
body.light .sidebar .section-title { color: var(--neutral-2); }
body.light .topbar { background: #FFFFFF; border-color: var(--border-soft); }
body.light .main-area { background: var(--bg-page); }
body.light .kpi-card { background: #FFFFFF; border-color: var(--border-soft); box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
body.light .kpi-label { color: var(--neutral); }
body.light .kpi-value { color: #1C140F; }
body.light .card { background: #FFFFFF; border-color: var(--border-soft); box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
body.light .card-title { color: #1C140F; }
body.light .text-muted { color: var(--neutral); }
body.light .activity-item { border-color: var(--border-soft); }
body.light .activity-item:hover { background: var(--bg-soft); }
body.light .badge-tag { background: var(--bg-page); color: var(--neutral-3); }
body.light .user-area { border-color: var(--border-soft); }
body.light .user-name { color: #1C140F; }
body.light .user-role { color: var(--neutral-2); }
body.light .topbar-btn { color: var(--neutral); }
body.light .topbar-btn:hover { color: #1C140F; }
body.light .theme-sw { color: var(--neutral); }
body.light .scenario-card { background: var(--bg-soft); border-color: var(--border-soft); }
body.light .scenario-btn { border-color: var(--border-soft-2); color: var(--neutral-3); }
body.light .scenario-btn:hover { background: var(--bg-page); color: #1C140F; }
body.light .bar-bg, body.light .churn-bar-bg { background: var(--border-soft); }
body.light .filter-tag { background: var(--bg-page); color: var(--neutral); border-color: var(--border-soft); }
body.light .filter-tag.active { background: rgba(var(--primary-rgb),0.1); color: var(--primary-hover); border-color: rgba(var(--primary-rgb),0.3); }
body.light .topbar-tab { color: var(--neutral-2); }
body.light .topbar-tab.active { color: #1C140F; }
body.light .topbar-tab-link { color: var(--neutral-2); }
body.light .topbar-tab-link.active { color: #1C140F; }
body.light .period-btn { background: var(--border-soft); color: var(--neutral); }
body.light .period-btn.active { background: var(--border-soft-2); color: #1C140F; }
body.light .data-table th { background: var(--bg-soft); color: var(--neutral); border-color: var(--border-soft); }
body.light .data-table td { border-color: var(--bg-page); color: #463A30; }
body.light .data-table tr:hover td { background: var(--bg-soft); }
body.light .rfm-plot { background: var(--bg-soft); border-color: var(--border-soft); }
body.light .action-card { background: var(--bg-soft); border-color: var(--border-soft); }
body.light .ai-rec { background: var(--bg-soft); border-color: var(--border-soft); }
body.light .segment-item { border-color: var(--bg-page); }
body.light .placeholder-icon { color: var(--border-soft); }
body.light ::-webkit-scrollbar-track { background: var(--bg-page); }
body.light ::-webkit-scrollbar-thumb { background: var(--border-soft-2); }

/* ---- Layout ---- */
.sidebar { width: 256px; border-right: 1px solid; display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; transition: width 0.22s ease; }
.sidebar-header { display: flex; align-items: stretch; flex-shrink: 0; }
.sidebar-logo { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: inherit; flex: 1; min-width: 0; overflow: hidden; padding: 1.5rem 0 1.5rem 1.25rem; }
.logo-icon { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-brand { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.025em; white-space: nowrap; }
.sidebar-collapse-btn { display: flex; align-items: center; justify-content: center; padding: 0 0.5rem; border: none; cursor: pointer; background: transparent; flex-shrink: 0; transition: background 0.15s; }
.sidebar-collapse-btn .material-symbols-outlined { font-size: 18px; transition: color 0.15s; }
body.dark .sidebar-collapse-btn { color: var(--neutral-3); }
body.dark .sidebar-collapse-btn:hover { background: #2A211B; color: var(--neutral-2); }
body.light .sidebar-collapse-btn { color: var(--border-soft-2); }
body.light .sidebar-collapse-btn:hover { background: var(--bg-page); color: var(--neutral); }
/* Sidebar tooltip (collapsed mode) */
.sidebar-tooltip { position: fixed; padding: 6px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 500; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.15s; z-index: 2000; transform: translateY(-50%); }
.sidebar-tooltip.visible { opacity: 1; }
body.dark .sidebar-tooltip { background: #2A211B; color: var(--bg-soft); border: 1px solid #463A30; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
body.light .sidebar-tooltip { background: #FFFFFF; color: #1C140F; border: 1px solid var(--border-soft); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
/* Collapsed sidebar */
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .sidebar-logo { display: none; }
.sidebar.collapsed .sidebar-collapse-btn { padding: 1.5rem 0; width: 64px; }
.sidebar.collapsed .section-title { display: none; }
.sidebar.collapsed .sidebar-link { justify-content: center; padding: 0.65rem 0; }
.sidebar.collapsed .sb-label { display: none; }
.ai-sidebar-btn { border-top: 1px solid; }
body.dark .ai-sidebar-btn { border-color: #2A211B; }
body.light .ai-sidebar-btn { border-color: var(--border-soft); }
/* Remove double border: ai-sidebar-btn already has border-top, user-area doesn't need another */
.ai-sidebar-btn + .user-area { border-top: none; }
.sidebar.collapsed .ai-sidebar-btn { justify-content: center; padding: 0.65rem 0; }
.sidebar.collapsed .ai-sidebar-btn-text { display: none; }
.sidebar.collapsed .user-area-link { justify-content: center; }
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed #userMenuArrow { display: none; }
.sidebar nav { flex: 1; padding: 0 0.75rem; overflow-y: auto; position: relative; }
/* Scroll shadows on nav — top when scrolled down, bottom when not at end */
.sidebar nav.scrolled { box-shadow: inset 0 8px 8px -8px rgba(0,0,0,0.1); }
.sidebar nav.scroll-bottom { box-shadow: inset 0 -8px 8px -8px rgba(0,0,0,0.1); }
.sidebar nav.scrolled.scroll-bottom { box-shadow: inset 0 8px 8px -8px rgba(0,0,0,0.1), inset 0 -8px 8px -8px rgba(0,0,0,0.1); }
body.dark .sidebar nav.scrolled { box-shadow: inset 0 8px 8px -8px rgba(0,0,0,0.3); }
body.dark .sidebar nav.scroll-bottom { box-shadow: inset 0 -8px 8px -8px rgba(0,0,0,0.3); }
body.dark .sidebar nav.scrolled.scroll-bottom { box-shadow: inset 0 8px 8px -8px rgba(0,0,0,0.3), inset 0 -8px 8px -8px rgba(0,0,0,0.3); }
.section-title { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 0 1rem; margin: 1.25rem 0 0.5rem; }
.sidebar-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 1rem; font-size: 0.875rem; font-weight: 500; border-radius: 8px; text-decoration: none; transition: all 0.15s; margin-bottom: 2px; }
.sidebar-link-soon { cursor: default; opacity: 0.45; }
.sidebar-link-soon:hover { background: none !important; color: inherit !important; }
.sb-soon-badge { margin-left: auto; font-size: 0.55rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.15rem 0.4rem; border-radius: 4px; background: rgba(138,128,118,0.15); color: var(--neutral); flex-shrink: 0; }
.sidebar.collapsed .sb-soon-badge { display: none; }
.sidebar-link .material-symbols-outlined { font-size: 20px; }
/* Sidebar favorite star */
.sidebar-fav-star { font-size: 16px !important; opacity: 0; margin-left: auto; flex-shrink: 0; cursor: pointer; transition: opacity 0.15s, color 0.15s; color: inherit; }
.sidebar-link:hover .sidebar-fav-star { opacity: 0.3; }
.sidebar-fav-star:hover { opacity: 0.7 !important; }
.sidebar-fav-star.is-fav { opacity: 0.6; color: #F59E0B; }
.sidebar-link:hover .sidebar-fav-star.is-fav { opacity: 0.8; }
/* Favorites section title */
.sidebar-fav-title { display: flex; align-items: center; justify-content: space-between; }
/* Header tab links (subsection navigation) */
.topbar-tab-link { text-decoration: none; color: var(--text-muted-c, var(--neutral)); font-size: 0.8rem; font-weight: 500; padding: 0.3rem 0.7rem; border-radius: 6px; transition: all 0.15s; white-space: nowrap; position: relative; }
.topbar-tab-link:hover { opacity: 0.8; }
.topbar-tab-link.active { font-weight: 600; }
.topbar-tab-link.active::after { content: ''; position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); width: 80%; height: 3px; border-radius: 2px; background: var(--primary); box-shadow: 0 0 8px rgba(var(--primary-rgb),0.5), 0 0 16px rgba(var(--primary-rgb),0.25); }
.user-area { padding: 1rem; border-top: 1px solid; display: flex; align-items: center; gap: 0.75rem; }
.user-area-link { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; text-decoration: none; color: inherit; border-radius: 8px; padding: 0.25rem; margin: -0.25rem; transition: background 0.15s; }
.user-area-link:hover { background: rgba(var(--primary-rgb), 0.08); }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 0.8rem; flex-shrink: 0; overflow: hidden; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 500; }
.user-role { font-size: 0.7rem; }
.logout-btn { background: none; border: none; cursor: pointer; padding: 0.25rem; color: inherit; opacity: 0.5; transition: opacity 0.2s; }
.logout-btn:hover { opacity: 1; }

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; width: 100%; }
.topbar { height: 60px; border-bottom: 1px solid; display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; flex-shrink: 0; position: relative; z-index: 1; }
.topbar h2 { font-size: 1.25rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.topbar-btn { background: none; border: none; cursor: pointer; padding: 0.5rem; position: relative; display: flex; }
/* .topbar-search styles are injected by shared.js injectSearchStyles() */
.theme-sw { background: none; border: none; cursor: pointer; padding: 0.5rem; display: flex; transition: all 0.15s; }
.topbar-tab { font-size: 0.8rem; font-weight: 500; cursor: pointer; padding: 0.3rem 0.7rem; border-radius: 6px; transition: all 0.15s; position: relative; }
.topbar-tab:hover { opacity: 0.8; }
.topbar-tab.active { font-weight: 600; opacity: 1; }
.topbar-tab.active::after {
  content: ''; position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  width: 80%; height: 3px; border-radius: 2px;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(var(--primary-rgb),0.5), 0 0 16px rgba(var(--primary-rgb),0.25);
}

.main-area { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; align-items: stretch; min-height: 0; gap: 0; overflow-anchor: none; }

/* ---- Buttons ---- */
/* ---- Modal System ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-card); border-radius: 16px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; padding: 0.25rem; border-radius: 6px; color: inherit; opacity: 0.5; transition: opacity 0.15s; display: flex; }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 1.5rem; flex: 1; overflow-y: auto; max-height: 70vh; }
.modal-label { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.35rem; display: block; color: var(--text-muted-c); }
.modal-input, .modal-select, .modal-textarea { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.85rem; background: var(--bg-main, var(--bg-page)); margin-bottom: 1rem; color: inherit; font-family: inherit; box-sizing: border-box; transition: border-color 0.15s; }
.modal-input:focus, .modal-select:focus, .modal-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.1); }
.modal-textarea { min-height: 80px; resize: vertical; }
body.dark .modal-input, body.dark .modal-select, body.dark .modal-textarea { background: #1C140F; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border); }
.modal-error { color: var(--danger); font-size: 0.78rem; margin-top: -0.5rem; margin-bottom: 0.75rem; display: none; }
.modal-error.show { display: block; }
.modal-field { margin-bottom: 1rem; }
.modal-row { display: flex; gap: 1rem; }
.modal-row .modal-field { flex: 1; }

/* Modal buttons (used in .modal-footer for Отмена + Действие) */
.modal-btn { padding: 0.5rem 1.25rem; border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--bg-card); color: inherit; transition: all 0.15s; font-family: inherit; }
.modal-btn:hover { background: var(--card-bg-alt); }
.modal-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.modal-btn-primary:hover { filter: brightness(1.1); background: var(--primary); }
.modal-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.modal-btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.modal-btn-danger:hover { filter: brightness(1.1); background: var(--danger); }

.btn-primary { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; font-family: 'Inter', sans-serif; transition: all 0.15s; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); border-radius: 8px; padding: 0.4rem 0.85rem; font-size: 0.8rem; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 0.4rem; font-family: 'Inter', sans-serif; transition: all 0.15s; }
.btn-outline:hover { background: var(--primary); color: #fff; }
.link-btn { background: none; border: none; color: var(--primary); font-size: 0.8rem; font-weight: 500; cursor: pointer; font-family: 'Inter', sans-serif; transition: opacity 0.15s; text-decoration: none; }
.link-btn:hover { opacity: 0.8; text-decoration: underline; }
.btn-action { border: none; border-radius: 6px; padding: 0.4rem 0.8rem; font-size: 0.75rem; font-weight: 600; cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.15s; }

/* Period switcher */
.period-group { display: flex; border-radius: 8px; overflow: hidden; }
.period-btn { padding: 0.3rem 0.7rem; font-size: 0.7rem; font-weight: 500; border: none; cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.15s; display: flex; align-items: center; }
.btn-action.primary { background: var(--primary); color: #fff; }
.btn-action.primary:hover { background: var(--primary-hover); }
.btn-action.danger { background: var(--danger); color: #fff; }
.btn-action.danger:hover { opacity: 0.9; }
.btn-action.warning { background: var(--warning); color: #fff; }
.btn-action.warning:hover { opacity: 0.9; }

/* ---- Grids ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; margin-bottom: 1.5rem; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }

/* ---- KPI Cards ---- */
.kpi-card { border-radius: 12px; padding: 1.25rem; border: 1px solid; position: relative; overflow: hidden; transition: all 0.2s; }
.kpi-card:hover { transform: translateY(-2px); }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.kpi-label { font-size: 0.8rem; font-weight: 500; margin-bottom: 0.25rem; }
.kpi-value { font-size: 1.5rem; font-weight: 700; }
.kpi-icon { padding: 0.5rem; border-radius: 8px; display: flex; }
.kpi-change { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.45rem; border-radius: 6px; margin-top: 0.35rem; }
.kpi-change.up { background: rgba(16,185,129,0.1); color: #10B981; }
.kpi-change.down { background: rgba(239,68,68,0.1); color: #EF4444; }
.kpi-change.warn { background: rgba(245,158,11,0.1); color: #F59E0B; }
.kpi-change.neutral { background: rgba(138,128,118,0.1); color: var(--neutral); }
.kpi-change .material-symbols-outlined { font-size: 14px; }
.kpi-change .text-muted { font-size: 0.68rem; font-weight: 500; }

/* ---- Cards ---- */
.card { border-radius: 12px; border: 1px solid; overflow: hidden; transition: all 0.2s; }
.card-header { padding: 1.25rem; display: flex; justify-content: space-between; align-items: center; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 0 1.25rem 1.25rem; }

/* ---- Activity ---- */
.activity-list { flex: 1; overflow-y: auto; min-height: 0; }
.activity-item { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.85rem 1.25rem; border-bottom: 1px solid; transition: background 0.15s; }
.activity-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 700; flex-shrink: 0; }
.activity-text { flex: 1; }
.activity-text p { font-size: 0.85rem; line-height: 1.4; }
.activity-text .activity-name { font-weight: 600; }
.activity-text .activity-link { color: var(--primary); text-decoration: none; }
.activity-text .activity-link:hover { text-decoration: underline; }
.activity-meta { font-size: 0.7rem; margin-top: 0.25rem; display: flex; align-items: center; gap: 0.3rem; }
.badge-tag { font-size: 0.65rem; padding: 0.15rem 0.5rem; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.badge-hot { background: rgba(var(--secondary-rgb),0.1); color: var(--secondary); border: 1px solid rgba(var(--secondary-rgb),0.2); }
.badge-revenue { color: var(--success); font-weight: 700; font-size: 0.85rem; white-space: nowrap; }

/* ---- Scenarios ---- */
.scenario-list { display: flex; flex-direction: column; gap: 0.75rem; }
.scenario-card { padding: 0.85rem; border-radius: 8px; border: 1px solid; }
.scenario-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.scenario-name { font-size: 0.85rem; font-weight: 500; }
.scenario-status { font-size: 0.6rem; padding: 0.15rem 0.5rem; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.status-active { background: rgba(16,185,129,0.15); color: var(--success); }
.status-paused { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-completed { background: rgba(138,128,118,0.15); color: var(--neutral-2); }
.status-draft { background: rgba(var(--primary-rgb),0.1); color: var(--accent-2); }
.scenario-stats { display: flex; justify-content: space-between; font-size: 0.75rem; }
.scenario-btn { width: 100%; padding: 0.65rem; border: 1px solid; border-radius: 8px; background: none; color: inherit; font-size: 0.85rem; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 1rem; font-family: 'Inter', sans-serif; transition: all 0.15s; }

/* ---- Filter tags ---- */
.filter-tag { font-size: 0.7rem; padding: 0.25rem 0.6rem; border-radius: 6px; border: 1px solid; cursor: pointer; transition: all 0.15s; font-weight: 500; }

/* ---- Sticky filter bar ---- */
/* Container for filter-tags that sticks to top of scroll parent on scroll.
   Parent must have overflow-y:auto and padding:0 on top (use margin on first child instead).
   Usage: <div class="sticky-filter-bar"> <span class="filter-tag">...</span> </div>
   JS: add class "stuck" when bar is pinned (use sentinel IntersectionObserver pattern). */
.sticky-filter-bar { position: sticky; top: 0; z-index: 20; padding: 0.5rem 2rem 0.6rem; margin: 0 -2rem 1rem; transition: box-shadow 0.2s; }
body.light .sticky-filter-bar { background: var(--bg-page); }
body.dark .sticky-filter-bar { background: #1C140F; }
.sticky-filter-bar.stuck { box-shadow: 0 4px 8px -4px rgba(0,0,0,0.1); }
body.dark .sticky-filter-bar.stuck { box-shadow: 0 4px 8px -4px rgba(0,0,0,0.3); }

/* ---- Sticky date/group label ---- */
/* Inline badge that sticks below the filter bar while scrolling a date group.
   Set top via JS: el.style.top = filterBarHeight + 8 + 'px'
   Add box-shadow via JS when stuck (IntersectionObserver). */
.sticky-date-label { font-size: 0.7rem; font-weight: 600; padding: 0.25rem 0.6rem; border-radius: 6px; display: inline-block; position: sticky; z-index: 10; transition: box-shadow 0.2s; }

/* ---- Data Table ---- */
.table-wrap { flex: 1; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th { padding: 0.75rem 1rem; text-align: left; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid; position: sticky; top: 0; z-index: 1; }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid; transition: background 0.15s; }
.cell-name { font-weight: 500; display: flex; align-items: center; gap: 0.5rem; }
.cell-revenue { font-weight: 600; color: var(--success); }
.channel-tag { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.65rem; padding: 0.15rem 0.5rem; border-radius: 4px; font-weight: 600; text-transform: uppercase; }
.channel-tag.email { background: rgba(var(--primary-rgb),0.15); color: var(--accent-2); }
.channel-tag.push { background: rgba(var(--secondary-rgb),0.15); color: var(--accent-4); }
.channel-tag.wallet { background: rgba(245,158,11,0.15); color: #FBBF24; }
.channel-tag.sms { background: rgba(16,185,129,0.15); color: #34D399; }
.channel-tag.max { background: rgba(122,104,91,0.15); color: var(--accent-4); }
.channel-tag.flow { background: rgba(122,104,91,0.15); color: var(--secondary); text-transform: none; }

/* ---- Legend ---- */
.legend-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin-top: 1rem; }
.legend-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---- Segments ---- */
.segment-list { display: flex; flex-direction: column; gap: 0.5rem; }
.segment-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; border-bottom: 1px solid; }
.segment-rank { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.segment-info { flex: 1; }
.segment-name { font-size: 0.875rem; font-weight: 600; }
.segment-growth { font-size: 0.85rem; font-weight: 700; }
.segment-growth.up { color: var(--success); }

/* ---- Mini chart ---- */
.mini-chart { display: flex; align-items: flex-end; gap: 6px; height: 100px; }
.mini-bar { flex: 1; background: rgba(var(--primary-rgb),0.25); border-radius: 3px 3px 0 0; transition: all 0.2s; }
.mini-bar.active { background: var(--primary); }
.mini-bar:hover { background: rgba(var(--primary-rgb),0.5); }

/* ---- Chart tooltips (shared) ---- */
.chart-bar-wrap { position: relative; flex: 1; display: flex; align-items: flex-end; height: 100%; }
.chart-bar-wrap .mini-bar { width: 100%; flex: none; }
/* Original .chart-tooltip hidden — JS clones content into .chart-tip-float (position:fixed) */
.chart-tooltip { display: none !important; }
/* Floating chart tooltip (appended to body via JS, escapes overflow:hidden) */
.chart-tip-float {
  position: fixed; z-index: 9998;
  border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.7rem;
  white-space: nowrap; pointer-events: none; line-height: 1.6; text-align: center;
  font-family: 'Inter', sans-serif;
  opacity: 0; transition: opacity 0.15s;
}
.chart-tip-float.visible { opacity: 1; }
.chart-tip-float::after {
  content: ''; position: absolute; left: var(--arrow-x, 50%); transform: translateX(-50%);
  border: 5px solid transparent;
}
.chart-tip-float.above::after { top: 100%; }
.chart-tip-float.below::after { bottom: 100%; }
body.dark .chart-tip-float { background: #1C140F; color: var(--bg-soft); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
body.dark .chart-tip-float.above::after { border-top-color: #1C140F; }
body.dark .chart-tip-float.below::after { border-bottom-color: #1C140F; }
body.light .chart-tip-float { background: #FFFFFF; color: #1C140F; box-shadow: 0 4px 16px rgba(0,0,0,0.12); border: 1px solid var(--border-soft); }
body.light .chart-tip-float.above::after { border-top-color: #FFFFFF; }
body.light .chart-tip-float.below::after { border-bottom-color: #FFFFFF; }
.funnel-bar { position: relative; overflow: visible; }
.funnel-stage { overflow: visible; }
.funnel-churn { overflow: visible; }
.funnel-container { overflow: visible; }

/* ---- RFM Chart ---- */
.rfm-chart { position: relative; }
.rfm-y-label { position: absolute; left: -10px; top: 50%; transform: rotate(-90deg) translateX(-50%); transform-origin: 0 0; font-size: 0.65rem; white-space: nowrap; }
.rfm-x-label { text-align: center; font-size: 0.65rem; margin-top: 0.5rem; }
.rfm-plot { position: relative; height: 250px; margin-left: 20px; border: 1px solid; border-radius: 8px; }
.rfm-dot { position: absolute; width: 10px; height: 10px; border-radius: 50%; transition: transform 0.2s; cursor: pointer; }
.rfm-dot:hover { transform: scale(1.8); z-index: 2; }
.rfm-dot:hover .chart-tooltip { transform: translateX(-50%) scale(calc(1 / 1.8)); }
.rfm-dot.vip { background: var(--secondary); box-shadow: 0 0 6px rgba(122,104,91,0.4); }
.rfm-dot.loyal { background: #10B981; box-shadow: 0 0 6px rgba(16,185,129,0.4); }
.rfm-dot.atrisk { background: #F59E0B; box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.rfm-dot.sleeping { background: var(--neutral); box-shadow: 0 0 6px rgba(138,128,118,0.3); }
.rfm-trend { position: absolute; left: 8%; bottom: 10%; width: 80%; height: 70%; border-bottom: 2px dashed rgba(var(--primary-rgb),0.2); border-left: 2px dashed rgba(var(--primary-rgb),0.2); border-radius: 0 0 0 40%; }

/* ---- Funnel ---- */
.funnel-container { display: flex; flex-direction: column; gap: 0.25rem; padding: 1rem 0; }
.funnel-stage { display: flex; }
.funnel-bar { padding: 0.75rem 1.25rem; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; color: #fff; font-weight: 500; transition: all 0.2s; }
.funnel-bar:hover { opacity: 0.9; transform: scaleX(1.02); }
.funnel-label { font-size: 0.85rem; }
.funnel-num { font-size: 1rem; font-weight: 700; }
.funnel-arrow { display: flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0 0.15rem 2rem; }
.funnel-churn { display: flex; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px dashed var(--danger); }

/* ---- Action cards ---- */
.action-card { padding: 1rem; border-radius: 10px; border: 1px solid; }
.action-badge { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--danger); margin-bottom: 0.5rem; }
.action-count { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.25rem; }
.action-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; }

/* ---- AI Recommendations ---- */
.ai-rec { padding: 1rem; border-radius: 10px; border: 1px solid; }
.ai-rec-badge { display: inline-block; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.15rem 0.5rem; border-radius: 4px; border: 1px solid; margin-bottom: 0.5rem; }
.ai-rec-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; }

/* ---- Churn bars ---- */
.churn-bars { display: flex; flex-direction: column; gap: 1rem; }
.churn-row { display: flex; align-items: center; gap: 1rem; }
.churn-label { font-size: 0.85rem; font-weight: 500; min-width: 180px; }
.churn-bar-bg { flex: 1; height: 24px; border-radius: 6px; overflow: hidden; }
.churn-bar-fill { height: 100%; border-radius: 6px; transition: width 1s ease; }
.churn-count { font-size: 0.85rem; font-weight: 700; min-width: 60px; text-align: right; }

/* ---- Heatmap ---- */
.heatmap-container { position: relative; }
.heatmap-y-label { position: absolute; left: -8px; top: 50%; transform: rotate(-90deg) translateX(-50%); transform-origin: 0 0; font-size: 0.65rem; white-space: nowrap; }
.heatmap-x-label { text-align: center; font-size: 0.65rem; margin-top: 0.5rem; }
.heatmap-grid { margin-left: 20px; }
.heatmap-y-axis { display: flex; flex-direction: column; position: absolute; left: 24px; top: 0; bottom: 26px; justify-content: space-around; }
.heatmap-y-axis span { font-size: 0.65rem; color: var(--text-muted-c); text-align: right; width: 55px; }
.heatmap-grid { position: relative; padding-left: 60px; }
.heatmap-cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.heatmap-x-axis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 4px; }
.heatmap-x-axis span { font-size: 0.65rem; color: var(--text-muted-c); text-align: center; }
.hm-cell { border-radius: 8px; padding: 0.9rem 0.4rem; text-align: center; cursor: pointer; transition: all 0.2s; min-height: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hm-cell:hover { transform: scale(1.05); z-index: 1; }
.hm-val { font-size: 1rem; font-weight: 700; display: block; }
.hm-label { font-size: 0.6rem; font-weight: 500; opacity: 0.8; }
.hm-danger { background: rgba(239,68,68,0.2); color: #F87171; border: 1px solid rgba(239,68,68,0.3); }
.hm-warning { background: rgba(245,158,11,0.15); color: #FBBF24; border: 1px solid rgba(245,158,11,0.25); }
.hm-ok { background: rgba(16,185,129,0.1); color: #34D399; border: 1px solid rgba(16,185,129,0.2); }
.hm-good { background: rgba(16,185,129,0.2); color: #10B981; border: 1px solid rgba(16,185,129,0.3); }
.hm-great { background: rgba(var(--primary-rgb),0.2); color: var(--accent-2); border: 1px solid rgba(var(--primary-rgb),0.3); }
.hm-critical { background: rgba(var(--secondary-rgb),0.2); color: var(--accent-4); border: 1px solid rgba(var(--secondary-rgb),0.3); animation: pulse 2s infinite; }
.hm-neutral { background: rgba(138,128,118,0.15); color: var(--neutral-2); border: 1px solid rgba(138,128,118,0.2); }

/* ---- Clickable links ---- */
.client-link { color: inherit; text-decoration: none; font-weight: 600; cursor: pointer; transition: color 0.15s; }
.client-link:hover { color: var(--primary); text-decoration: underline; }
.product-link { color: var(--primary); text-decoration: none; font-weight: 500; cursor: pointer; transition: color 0.15s; }
.product-link:hover { text-decoration: underline; }

/* ---- Placeholder page ---- */
.placeholder-page { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; text-align: center; padding: 3rem; }
.placeholder-icon { font-size: 80px; }
.placeholder-title { font-size: 1.5rem; font-weight: 700; }
.placeholder-desc { font-size: 0.9rem; max-width: 400px; line-height: 1.6; }

/* ---- Profile tags & stats ---- */
.ptag { font-size: 0.7rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 20px; }
.ptag-purple { background: rgba(var(--primary-rgb),0.1); color: var(--accent-2); border: 1px solid rgba(var(--primary-rgb),0.2); }
.ptag-pink { background: rgba(var(--secondary-rgb),0.1); color: var(--accent-4); border: 1px solid rgba(var(--secondary-rgb),0.2); }
.ptag-green { background: rgba(16,185,129,0.1); color: #10B981; border: 1px solid rgba(16,185,129,0.2); }
.ptag-amber { background: rgba(245,158,11,0.1); color: #F59E0B; border: 1px solid rgba(245,158,11,0.2); }
.ptag-orange { background: rgba(249,115,22,0.1); color: #F97316; border: 1px solid rgba(249,115,22,0.2); }
.ptag-red { background: rgba(239,68,68,0.1); color: #EF4444; border: 1px solid rgba(239,68,68,0.2); }
.ptag-gray { background: rgba(138,128,118,0.1); color: var(--neutral); border: 1px solid rgba(138,128,118,0.2); }
.ptag-violet { background: rgba(122,104,91,0.1); color: var(--secondary); border: 1px solid rgba(122,104,91,0.2); }
.stat-cell { text-align: center; }
.stat-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-val { font-size: 1.1rem; font-weight: 700; margin-top: 0.15rem; }

/* ---- Animations ---- */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { border-radius: 3px; }
body.dark ::-webkit-scrollbar-thumb:hover { background: var(--neutral-3); }
body.light ::-webkit-scrollbar-thumb:hover { background: var(--neutral-2); }

/* ---- Nav Back Link ---- */
.nav-back { text-decoration:none; color:var(--text-muted-c,var(--neutral)); display:flex; align-items:center; gap:0.25rem; font-size:0.85rem; transition:color 0.15s; white-space:nowrap; }
.nav-back:hover { color:var(--primary); }
.nav-back .material-symbols-outlined { font-size:20px; }

/* ---- Metrika-style Period Picker (pf2) ---- */
.pf2-picker { display:flex; align-items:center; gap:0.5rem; width:fit-content; max-width:100%; align-self:flex-start; flex-shrink:0; flex-wrap:wrap; }
.pf2-main { display:flex; align-items:center; background:var(--bg-card,#fff); border:1px solid var(--border); border-radius:12px; position:relative; min-height:40px; padding:4px; gap:0; }
body.dark .pf2-main { background:var(--bg-card,#2A211B); }
.prod-thumb { width:34px; height:34px; border-radius:6px; object-fit:cover; flex-shrink:0; background:var(--border); cursor:pointer; }
.pf2-slider { position:absolute; top:4px; left:4px; height:calc(100% - 8px); border-radius:8px; background:var(--primary); z-index:0; pointer-events:none; transition:left 0.25s cubic-bezier(0.4,0,0.2,1), width 0.25s cubic-bezier(0.4,0,0.2,1); }
.pf2-btn { padding:0.4rem 0.85rem; font-size:0.78rem; font-weight:500; cursor:pointer; border:none; background:none; color:var(--text-muted-c,var(--neutral)); font-family:inherit; transition:color 0.15s; white-space:nowrap; position:relative; z-index:1; line-height:1.4; }
.pf2-btn:hover { color:var(--primary); }
.pf2-btn.active { color:#fff; }
.pf2-range { display:flex; align-items:center; gap:0.25rem; padding:0.4rem 0.75rem; font-size:0.78rem; font-weight:500; cursor:pointer; border:none; background:none; color:var(--text-muted-c,var(--neutral)); font-family:inherit; transition:color 0.15s; white-space:nowrap; position:relative; z-index:1; flex-shrink:0; }
.pf2-range.active { color:#fff; }
.pf2-range:hover { color:var(--primary); }
.pf2-range.open .material-symbols-outlined { transform:rotate(180deg); }
.pf2-range .material-symbols-outlined,
.pf2-granularity-arrow {
  font-size:16px;
  transition:transform 0.2s;
  flex-shrink:0;
}
.pf2-granularity-wrap { display:flex; align-items:center; position:relative; z-index:5; flex-shrink:0; background:var(--bg-card,#fff); border:1px solid var(--border); border-radius:12px; padding:4px; min-height:40px; }
.pf2-granularity-wrap.open { border-color:var(--border); }
.pf2-granularity-btn {
  border:none;
  border-radius:8px;
  background:transparent;
  color:var(--text-muted-c,var(--neutral));
  padding:0.42rem 0.55rem 0.42rem 0.7rem;
  font-size:0.78rem;
  font-weight:500;
  font-family:inherit;
  line-height:1.4;
  cursor:pointer;
  min-height:32px;
  transition:color 0.15s, background 0.15s;
  display:inline-flex;
  align-items:center;
  gap:0.2rem;
  white-space:nowrap;
}
.pf2-granularity-btn:hover { color:var(--primary); }
.pf2-granularity-btn:focus { outline:none; }
.pf2-granularity-btn:disabled { opacity:0.55; cursor:default; }
.pf2-granularity-wrap:hover .pf2-granularity-btn { color:var(--primary); }
.pf2-granularity-wrap.open .pf2-granularity-arrow { transform:rotate(180deg); }
.pf2-granularity-menu {
  position:absolute;
  top:calc(100% + 6px);
  left:0;
  min-width:max-content;
  padding:6px;
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--bg-card,#fff);
  box-shadow:0 12px 40px rgba(0,0,0,0.12),0 4px 12px rgba(0,0,0,0.06);
  display:none;
  flex-direction:column;
  gap:2px;
}
.pf2-granularity-menu.open { display:flex; }
.pf2-granularity-option {
  border:none;
  background:transparent;
  color:var(--text-muted-c,var(--neutral));
  font:inherit;
  font-size:0.78rem;
  font-weight:500;
  line-height:1.4;
  text-align:left;
  padding:0.5rem 0.7rem;
  border-radius:8px;
  cursor:pointer;
  transition:background 0.15s, color 0.15s;
  white-space:nowrap;
}
.pf2-granularity-menu .pf2-granularity-option:hover { color:var(--primary) !important; background:transparent; }
.pf2-granularity-option.active { background:var(--primary); color:var(--bg-soft) !important; }
.pf2-granularity-menu .pf2-granularity-option.active:hover { background:var(--primary); color:var(--bg-soft) !important; }
body.dark .pf2-granularity-btn { color:var(--text-muted-c,var(--neutral-2)); background-color:transparent; }
body.dark .pf2-granularity-menu { background:#2A211B; border-color:var(--border,#463A30); box-shadow:0 12px 40px rgba(0,0,0,0.35),0 4px 12px rgba(0,0,0,0.2); }
body.dark .pf2-granularity-option { color:var(--text-muted-c,var(--neutral-2)); }
body.light .pf2-granularity-btn { color:var(--text-muted-c,var(--neutral)); background-color:transparent; }
body.light .pf2-granularity-option { color:var(--text-muted-c,var(--neutral)); }
body.dark .pf2-granularity-wrap { background:var(--bg-card,#2A211B); }
body.dark .pf2-granularity-wrap.disabled,
body.light .pf2-granularity-wrap.disabled { border-color:var(--border); }

/* Calendar popup (fixed, appended to body) */
.pf2-cal-wrap { position:fixed; z-index:1000; display:none; }
.pf2-cal-wrap.open { display:block; }
.pf2-cal { background:var(--bg-card,#fff); border:1px solid var(--border); border-radius:12px; box-shadow:0 12px 40px rgba(0,0,0,0.12),0 4px 12px rgba(0,0,0,0.06); padding:0; min-width:680px; overflow:hidden; }
body.dark .pf2-cal { background:var(--bg-card,#2A211B); border-color:var(--border,#463A30); box-shadow:0 12px 40px rgba(0,0,0,0.35),0 4px 12px rgba(0,0,0,0.2); }
.pf2-cal-header { display:flex; align-items:center; justify-content:space-between; padding:0.85rem 1rem; border-bottom:1px solid var(--border); }
.pf2-cal-nav { width:28px; height:28px; border-radius:6px; border:1px solid var(--border); background:none; cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--text-muted-c,var(--neutral)); transition:all 0.15s; flex-shrink:0; }
.pf2-cal-nav:hover { border-color:var(--primary); color:var(--primary); background:rgba(var(--primary-rgb),0.06); }
.pf2-cal-nav .material-symbols-outlined { font-size:18px; }
.pf2-cal-months-title { display:flex; gap:2rem; flex:1; justify-content:center; }
.pf2-cal-months-title span { font-size:0.85rem; font-weight:600; min-width:140px; text-align:center; }
.pf2-cal-grid { display:grid; grid-template-columns:1fr 1fr 1fr; gap:0; }
.pf2-cal-month { padding:0.75rem 1rem; }
.pf2-cal-month:not(:last-child) { border-right:1px solid var(--border); }
.pf2-cal-weekdays { display:grid; grid-template-columns:repeat(7,1fr); gap:0; margin-bottom:0.25rem; }
.pf2-cal-wd { text-align:center; font-size:0.68rem; font-weight:600; text-transform:uppercase; color:var(--text-muted-c,var(--neutral-2)); padding:0.2rem 0; letter-spacing:0.02em; }
.pf2-cal-wd.weekend { color:rgba(239,68,68,0.5); }
.pf2-cal-days { display:grid; grid-template-columns:repeat(7,1fr); gap:0; }
.pf2-cal-day { text-align:center; font-size:0.78rem; padding:0; height:30px; display:flex; align-items:center; justify-content:center; cursor:pointer; border-radius:0; transition:background 0.1s, color 0.1s; position:relative; color:var(--text-color,#1C140F); }
body.dark .pf2-cal-day { color:var(--text-color,var(--border-soft)); }
.pf2-cal-day:hover:not(.disabled):not(.empty):not(.range-start):not(.range-end):not(.in-range) { background:var(--primary) !important; color:#fff !important; border-radius:6px; }
.pf2-cal-day.empty { cursor:default; }
.pf2-cal-day.today { font-weight:700; }
.pf2-cal-day.today::after { content:''; position:absolute; bottom:2px; left:50%; transform:translateX(-50%); width:4px; height:4px; border-radius:50%; background:var(--primary); }
.pf2-cal-day.weekend { color:var(--text-muted-c,var(--neutral-2)); }
.pf2-cal-day.disabled { color:var(--text-muted-c,var(--neutral-2)); opacity:0.35; cursor:not-allowed; }
.pf2-cal-day.in-range { background:rgba(var(--primary-rgb),0.10); transition:background 0.1s, border-radius 0.1s; }
.pf2-cal-day.in-range:hover { background:rgba(var(--primary-rgb),0.18); }
.pf2-cal-day.range-start { background:var(--primary); color:#fff; border-radius:6px 0 0 6px; }
.pf2-cal-day.range-end { background:var(--primary); color:#fff; border-radius:0 6px 6px 0; }
.pf2-cal-day.range-start.range-end { border-radius:6px; }
.pf2-cal-day.range-start.today::after, .pf2-cal-day.range-end.today::after { background:#fff; }
.pf2-cal-footer { display:flex; align-items:center; gap:0.75rem; padding:0.75rem 1rem; border-top:1px solid var(--border); }
.pf2-cal-input { width:95px; padding:0.35rem 0.5rem; border:1px solid var(--border); border-radius:6px; font-size:0.78rem; font-family:inherit; text-align:center; background:var(--bg-card,#fff); color:var(--text-color); outline:none; transition:border-color 0.15s; }
body.dark .pf2-cal-input { background:var(--bg-card,#2A211B); color:var(--text-color,var(--border-soft)); }
.pf2-cal-input:focus { border-color:var(--primary); }
.pf2-cal-dash { color:var(--text-muted-c,var(--neutral-2)); font-size:0.82rem; }
.pf2-cal-period { font-size:0.75rem; color:var(--text-muted-c,var(--neutral)); margin-left:auto; }
.pf2-cal-apply { padding:0.35rem 1rem; border:none; border-radius:6px; background:var(--primary); color:#fff; font-size:0.78rem; font-weight:500; cursor:pointer; font-family:inherit; transition:background 0.15s; }
.pf2-cal-apply:hover { background:var(--primary-hover,var(--primary-hover)); }

/* ---- User Menu Dropdown ---- */
.user-menu-dropdown {
  border-radius: 12px; padding: 0.35rem; z-index: 2000;
  opacity: 0; transform: translateY(8px); transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
.user-menu-dropdown.open { opacity: 1; transform: translateY(0); }
body.dark .user-menu-dropdown { background: #2A211B; border: 1px solid #463A30; }
body.light .user-menu-dropdown { background: #FFFFFF; border: 1px solid var(--border-soft); box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.user-menu-item {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.75rem;
  font-size: 0.82rem; font-weight: 500; border-radius: 8px; cursor: pointer;
  transition: background 0.1s; text-decoration: none; color: inherit;
}
.user-menu-item .material-symbols-outlined { font-size: 18px; opacity: 0.6; }
.user-menu-item:hover { background: rgba(var(--primary-rgb),0.08); }
.user-menu-danger:hover { background: rgba(239,68,68,0.08); color: var(--danger); }
.user-menu-danger:hover .material-symbols-outlined { color: var(--danger); opacity: 1; }
.user-menu-divider { height: 1px; margin: 0.25rem 0.5rem; }
body.dark .user-menu-divider { background: #463A30; }
body.light .user-menu-divider { background: var(--border-soft); }
.user-menu-badge {
  background: var(--danger); color: #fff; font-size: 0.6rem; font-weight: 700;
  padding: 0.1rem 0.4rem; border-radius: 10px; margin-left: auto;
  min-width: 18px; text-align: center; display: inline-flex; align-items: center; justify-content: center;
}

/* ---- Bug Report Modal ---- */
.bug-report-modal { max-height: 90vh; overflow-y: auto; }
.bug-prio-btn {
  padding: 0.25rem 0.65rem; border-radius: 6px; font-size: 0.72rem; font-weight: 600;
  border: 1px solid var(--border, #463A30); background: none; color: inherit;
  cursor: pointer; transition: all 0.15s; font-family: 'Inter', sans-serif;
}
.bug-prio-btn:hover { border-color: var(--primary); color: var(--primary); }
.bug-prio-btn.active[data-prio="low"] { background: rgba(16,185,129,0.15); color: var(--success); border-color: var(--success); }
.bug-prio-btn.active[data-prio="medium"] { background: rgba(245,158,11,0.15); color: var(--warning); border-color: var(--warning); }
.bug-prio-btn.active[data-prio="high"] { background: rgba(239,68,68,0.15); color: var(--danger); border-color: var(--danger); }
.bug-ss-expanded img { max-height: none !important; }

/* ---- Contextual Help Hints ---- */
.help-hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  font-size: 9px; font-weight: 600; font-style: normal;
  opacity: 0.35; cursor: help; position: relative;
  vertical-align: middle; margin-left: 4px; flex-shrink: 0;
  transition: opacity 0.2s;
  line-height: 1;
}
body.dark .help-hint { border: 1px solid var(--neutral-3); color: var(--neutral-2); }
body.light .help-hint { border: 1px solid var(--border-soft-2); color: var(--neutral-2); }
.help-hint:hover { opacity: 0.85; }
body.dark .help-hint:hover { border-color: var(--accent-2); color: var(--accent-2); }
body.light .help-hint:hover { border-color: var(--primary); color: var(--primary); }

/* Floating tooltip (appended to body via JS, escapes overflow:hidden) */
.help-tip-float {
  position: fixed; z-index: 9999;
  padding: 8px 12px; border-radius: 8px;
  font-size: 0.72rem; font-weight: 400; line-height: 1.5; font-family: 'Inter', sans-serif;
  white-space: normal; width: max-content; max-width: 260px;
  text-align: left; pointer-events: none;
  opacity: 0; transition: opacity 0.15s;
}
.help-tip-float.visible { opacity: 1; }
.help-tip-float::after {
  content: ''; position: absolute; left: var(--arrow-x, 50%); transform: translateX(-50%);
  border: 5px solid transparent;
}
.help-tip-float.above::after { top: 100%; }
.help-tip-float.below::after { bottom: 100%; }
body.dark .help-tip-float { background: #1C140F; color: var(--border-soft); border: 1px solid #463A30; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
body.dark .help-tip-float.above::after { border-top-color: #463A30; }
body.dark .help-tip-float.below::after { border-bottom-color: #463A30; }
body.light .help-tip-float { background: #FFFFFF; color: #463A30; border: 1px solid var(--border-soft); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
body.light .help-tip-float.above::after { border-top-color: var(--border-soft); }
body.light .help-tip-float.below::after { border-bottom-color: var(--border-soft); }

/* ---- Onboarding Tour ---- */
.tour-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s;
}
.tour-overlay.visible { opacity: 1; }
.tour-modal {
  width: 680px; max-width: 92vw; max-height: 88vh;
  border-radius: 20px; overflow: hidden;
  display: flex; flex-direction: column;
  transform: translateY(20px) scale(0.97); transition: transform 0.3s;
}
.tour-overlay.visible .tour-modal { transform: translateY(0) scale(1); }
body.dark .tour-modal { background: #2A211B; border: 1px solid #463A30; box-shadow: 0 24px 80px rgba(0,0,0,0.5); }
body.light .tour-modal { background: #FFFFFF; border: 1px solid var(--border-soft); box-shadow: 0 24px 80px rgba(0,0,0,0.2); }
.tour-hero {
  padding: 2.5rem 2.5rem 1.5rem; text-align: center;
  background: linear-gradient(135deg, rgba(var(--primary-rgb),0.08), rgba(var(--secondary-rgb),0.08));
}
body.dark .tour-hero { background: linear-gradient(135deg, rgba(var(--primary-rgb),0.12), rgba(var(--secondary-rgb),0.1)); }
.tour-hero-icon { font-size: 48px; margin-bottom: 0.75rem; }
.tour-hero h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.5rem; }
body.dark .tour-hero h2 { color: var(--bg-page); }
body.light .tour-hero h2 { color: #1C140F; }
.tour-hero p { font-size: 0.9rem; line-height: 1.6; max-width: 480px; margin: 0 auto; }
body.dark .tour-hero p { color: var(--neutral-2); }
body.light .tour-hero p { color: var(--neutral); }
.tour-body { padding: 1.5rem 2.5rem; overflow-y: auto; flex: 1; }
body.dark .tour-body { color: var(--border-soft-2); }
body.light .tour-body { color: #463A30; }
.tour-funnel { display: flex; flex-direction: column; gap: 0; }
.tour-stage {
  display: flex; align-items: stretch; gap: 1rem; position: relative;
  padding: 0.85rem 0; transition: background 0.2s;
}
.tour-stage-line {
  width: 3px; flex-shrink: 0; margin-left: 15px; position: relative;
}
.tour-stage-line::before {
  content: ''; position: absolute; inset: 0; border-radius: 2px;
}
.tour-stage-dot {
  width: 33px; height: 33px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}
.tour-stage-dot .material-symbols-outlined { font-size: 17px; color: #fff; }
.tour-stage-content { flex: 1; padding-top: 0.25rem; }
.tour-stage-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.2rem; }
body.dark .tour-stage-title { color: var(--bg-page); }
body.light .tour-stage-title { color: #1C140F; }
.tour-stage-desc { font-size: 0.78rem; line-height: 1.5; }
body.dark .tour-stage-desc { color: var(--neutral-2); }
body.light .tour-stage-desc { color: var(--neutral); }
.tour-stage-tools { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.tour-tool-tag {
  font-size: 0.68rem; font-weight: 500; padding: 0.15rem 0.5rem;
  border-radius: 4px; white-space: nowrap;
}
body.dark .tour-tool-tag { background: rgba(var(--primary-rgb),0.12); color: var(--accent-2); border: 1px solid rgba(var(--primary-rgb),0.2); }
body.light .tour-tool-tag { background: rgba(var(--primary-rgb),0.08); color: var(--primary); border: 1px solid rgba(var(--primary-rgb),0.15); }
.tour-footer {
  padding: 1.25rem 2.5rem; display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid;
}
body.dark .tour-footer { border-color: #463A30; }
body.light .tour-footer { border-color: var(--border-soft); }
.tour-dots { display: flex; gap: 6px; }
.tour-dot {
  width: 8px; height: 8px; border-radius: 50%; transition: all 0.2s; cursor: pointer;
}
body.dark .tour-dot { background: #463A30; }
body.light .tour-dot { background: var(--border-soft); }
.tour-dot.active { width: 24px; border-radius: 4px; background: var(--primary); }
.tour-nav { display: flex; gap: 0.5rem; }
.tour-btn {
  padding: 0.5rem 1.2rem; border-radius: 8px; font-size: 0.85rem; font-weight: 500;
  cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.15s; border: none;
}
.tour-btn-skip { background: none; border: none; cursor: pointer; font-size: 0.8rem; font-family: 'Inter', sans-serif; transition: opacity 0.15s; }
body.dark .tour-btn-skip { color: var(--neutral); }
body.light .tour-btn-skip { color: var(--neutral-2); }
.tour-btn-skip:hover { opacity: 0.7; }
.tour-btn-prev { border: 1px solid; }
body.dark .tour-btn-prev { background: #1C140F; color: var(--neutral-2); border-color: #463A30; }
body.dark .tour-btn-prev:hover { background: #2A211B; color: var(--bg-soft); }
body.light .tour-btn-prev { background: var(--bg-soft); color: var(--neutral); border-color: var(--border-soft); }
body.light .tour-btn-prev:hover { background: var(--bg-page); color: #1C140F; }
.tour-btn-next { background: var(--primary); color: #fff; }
.tour-btn-next:hover { background: var(--primary-hover); }

/* Tour Confetti — full-screen */
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotateZ(0deg); opacity: 1; }
  95%  { opacity: 1; }
  100% { transform: translateY(var(--fall, 100vh)) rotateZ(var(--r, 720deg)); opacity: 0; }
}
@keyframes confetti-sway {
  0%, 100% { margin-left: 0; }
  25%  { margin-left: var(--sx, 18px); }
  75%  { margin-left: calc(var(--sx, 18px) * -1); }
}
.tour-confetti {
  position: fixed; top: -14px; z-index: 10001;
  width: var(--w, 8px); height: var(--h, 12px);
  border-radius: var(--br, 2px);
  background: var(--c, #FF6B6B);
  animation: confetti-fall var(--d, 3.2s) ease-out forwards,
             confetti-sway var(--sd, 2s) ease-in-out infinite;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .tour-confetti { animation: none; display: none; }
}

/* ---- Tour Mobile ---- */
@media (max-width: 600px) {
  .tour-modal { border-radius: 14px; }
  .tour-hero { padding: 1.5rem 1.25rem 1rem; }
  .tour-hero-icon { font-size: 36px; margin-bottom: 0.5rem; }
  .tour-hero h2 { font-size: 1.15rem; }
  .tour-hero p { font-size: 0.82rem; }
  .tour-body { padding: 1rem 1.25rem; }
  .tour-stage-dot { width: 28px; height: 28px; }
  .tour-stage-dot .material-symbols-outlined { font-size: 14px; }
  .tour-stage-title { font-size: 0.82rem; }
  .tour-stage-desc { font-size: 0.72rem; }
  .tour-tool-tag { font-size: 0.62rem; padding: 0.1rem 0.4rem; }
  .tour-footer { padding: 1rem 1.25rem; }
  .tour-btn { padding: 0.4rem 0.9rem; font-size: 0.8rem; }
  .tour-btn-skip { font-size: 0.75rem; }
}

/* ---- Page Header (channel pages) ---- */
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.page-header-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.page-header-icon .material-symbols-outlined { font-size: 26px; }
.page-header-title { font-size: 1.4rem; font-weight: 700; }
.page-header-sub { font-size: 0.8rem; color: var(--text-muted-c); margin-top: 0.15rem; }

/* ---- Back Link ---- */
.back-link { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; font-weight: 500; color: var(--text-muted-c); text-decoration: none; margin-bottom: 1rem; padding: 0.3rem 0; transition: color 0.15s; cursor: pointer; }
.back-link:hover { color: var(--primary); }
.back-link .material-symbols-outlined { font-size: 18px; }

/* ---- Filter Bar ---- */
.filter-bar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filter-bar input { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.8rem; color: inherit; font-family: inherit; width: 240px; outline: none; }
.filter-bar input:focus { border-color: var(--primary); }
.filter-bar select { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.8rem; color: inherit; font-family: inherit; cursor: pointer; outline: none; }

/* ---- Toggle Switch ---- */
.toggle-sw { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; }
.toggle-sw input { opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; inset: 0; background: var(--border); border-radius: 10px; transition: all 0.2s; }
.toggle-sw input:checked + .toggle-track { background: var(--success); }
.toggle-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: all 0.2s; }
.toggle-sw input:checked + .toggle-track::after { left: 18px; }

/* ---- Month Bar Chart (horizontal bars) ---- */
.month-bar-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
.month-bar-label { font-size: 0.7rem; font-weight: 500; width: 50px; flex-shrink: 0; text-align: right; }
.month-bar-track { flex: 1; height: 22px; background: var(--border); border-radius: 5px; overflow: hidden; position: relative; }
.month-bar-fill { height: 100%; border-radius: 5px; display: flex; align-items: center; padding-left: 0.5rem; font-size: 0.65rem; font-weight: 600; color: #fff; transition: width 0.4s ease; }
.month-bar-val { font-size: 0.7rem; font-weight: 600; width: 60px; flex-shrink: 0; text-align: right; }
/* Vertical month bar (seller/store profiles) */
.month-bar-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }

/* ---- Loading Skeleton ---- */
@keyframes skeleton-pulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.3; }
  100% { opacity: 0.6; }
}
.skeleton-loading { padding: 1rem; }
.skeleton-row { display: flex; gap: 1rem; margin-bottom: 0.85rem; align-items: center; }
.skeleton-bar { height: 14px; border-radius: 6px; animation: skeleton-pulse 1.4s ease-in-out infinite; }
body.dark .skeleton-bar { background: #463A30; }
body.light .skeleton-bar { background: var(--border-soft); }
.skeleton-bar.w-full { width: 100%; }
.skeleton-bar.w-3-4 { width: 75%; }
.skeleton-bar.w-half { width: 50%; }
.skeleton-bar.w-1-4 { width: 25%; }
.skeleton-bar.w-1-5 { width: 20%; }
.skeleton-bar.h-sm { height: 10px; }
.skeleton-bar.h-lg { height: 18px; }
.skeleton-bar.circle { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }

/* ---- Info Icon (ⓘ) with hover tooltip ---- */
.info-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--text-muted-c); color: var(--text-muted-c); font-size: 0.6rem; font-weight: 700; font-style: italic; font-family: Georgia, serif; cursor: help; flex-shrink: 0; transition: all 0.15s; opacity: 0.5; }
.info-icon:hover { border-color: var(--primary); color: var(--primary); opacity: 1; }

/* ---- Error State ---- */
.state-error { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1.5rem; text-align: center; gap: 0.75rem; }
.state-error-icon { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: rgba(239,68,68,0.1); color: var(--danger); }
.state-error-icon .material-symbols-outlined { font-size: 28px; }
.state-error-title { font-size: 0.95rem; font-weight: 700; }
.state-error-msg { font-size: 0.82rem; color: var(--text-muted-c, var(--neutral)); max-width: 400px; line-height: 1.5; }
.state-error-btn { margin-top: 0.5rem; padding: 0.45rem 1.25rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card); color: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.15s; display: inline-flex; align-items: center; gap: 0.35rem; }
.state-error-btn:hover { border-color: var(--primary); color: var(--primary); }
.state-error-btn .material-symbols-outlined { font-size: 16px; }

/* ---- Empty State ---- */
.state-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1.5rem; text-align: center; gap: 0.75rem; }
.state-empty-icon { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
body.dark .state-empty-icon { background: rgba(62, 52, 42,0.5); color: var(--neutral); }
body.light .state-empty-icon { background: var(--bg-page); color: var(--neutral-2); }
.state-empty-icon .material-symbols-outlined { font-size: 28px; }
.state-empty-title { font-size: 0.95rem; font-weight: 700; }
.state-empty-msg { font-size: 0.82rem; color: var(--text-muted-c, var(--neutral)); max-width: 400px; line-height: 1.5; }

/* ---- Responsive ---- */
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr; } .grid-2 { grid-template-columns: 1fr; } .grid-2-1 { grid-template-columns: 1fr; } }
/* Mobile sidebar is handled by shared.js mobile drawer */

/* ============================================================
   MOBILE RESPONSIVE FIXES
   ============================================================ */

/* Profile / Product sidebar: full-width on mobile */
@media (max-width: 768px) {
  .profile-sidebar,
  .product-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border, var(--border-soft)) !important;
  }
}

/* Tables: horizontal scroll wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 768px) {
  .table-wrap,
  .card-body > table,
  .main-area > table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
  }
}

/* Modals: constrain max-width on mobile */
@media (max-width: 768px) {
  .modal,
  .bgd-modal,
  .tour-modal,
  .tpl-modal {
    max-width: calc(100vw - 2rem) !important;
    margin: 1rem;
  }
}

/* Touch targets: minimum 44px for buttons and links */
@media (max-width: 768px) {
  .pf2-picker { align-items:stretch; }
  .pf2-main,
  .pf2-granularity-wrap { min-height:44px; }
  .btn-primary,
  .btn-outline,
  .btn-action,
  .link-btn,
  .filter-tag,
  .topbar-btn,
  .theme-sw,
  .period-btn,
  .pf2-btn,
  .pf2-range,
  .pf2-granularity-btn,
  .scenario-btn,
  .topbar-tab,
  .topbar-tab-link,
  .nav-back,
  .channel-tag {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .sidebar-link {
    min-height: 44px;
    display: flex;
  }
  .filter-tag {
    min-height: 36px;
    padding: 0.35rem 0.7rem;
  }
}

/* Cards grid: single column on mobile */
@media (max-width: 768px) {
  .grid-3,
  .grid-2-1 {
    grid-template-columns: 1fr !important;
  }
}

/* Topbar: prevent overflow on small screens */
@media (max-width: 768px) {
  .topbar {
    overflow: hidden;
    gap: 0.5rem;
  }
  .topbar h2 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
  }
  .topbar-actions {
    flex-shrink: 0;
    gap: 0.35rem;
  }
}

/* ============================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================ */

/* Focus-visible outlines on interactive elements */
:focus-visible {
  outline: 2px solid var(--primary, var(--primary));
  outline-offset: 2px;
}

/* Remove default outlines only when focus-visible is supported */
:focus:not(:focus-visible) {
  outline: none;
}

/* Specific focus styles for common interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--primary, var(--primary));
  outline-offset: 2px;
  border-radius: 4px;
}

.sidebar-link:focus-visible {
  outline: 2px solid var(--primary, var(--primary));
  outline-offset: -2px;
  border-radius: 8px;
}

.btn-primary:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--primary, var(--primary));
}

/* Reduced motion: disable animations and transitions */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .kpi-card:hover { transform: none; }
  .hm-cell:hover { transform: none; }
  .rfm-dot:hover { transform: none; }
  .funnel-bar:hover { transform: none; }
  .sidebar { transition: none; }
  .bgd-modal-overlay { transition: none; backdrop-filter: none; }
  .bgd-modal { transition: none; }
  .tour-overlay { transition: none; }
  .tour-modal { transition: none; }
}

/* High contrast mode support */
@media (forced-colors: active) {
  .sidebar-link.active {
    border: 2px solid LinkText;
  }
  .btn-primary,
  .btn-action.primary {
    border: 2px solid ButtonText;
  }
  .kpi-card,
  .card {
    border: 1px solid CanvasText;
  }
  .filter-tag.active {
    border: 2px solid LinkText;
  }
  .status-active,
  .status-paused,
  .status-completed,
  .status-draft {
    border: 1px solid CanvasText;
  }
  :focus-visible {
    outline: 2px solid LinkText;
  }
}

/* Skip to content link -- visually hidden but keyboard accessible */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 10001;
  padding: 0.75rem 1.5rem;
  background: var(--primary, var(--primary));
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  transition: top 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.skip-to-content:focus {
  top: 0;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Focus trap styles for modals */
.modal-overlay:focus-within,
.bgd-modal-overlay:focus-within,
.tpl-modal-overlay:focus-within,
.tour-overlay:focus-within {
  z-index: 10000;
}

/* Screen reader only utility class */
.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;
}

/* Filter negate toggle */
.fm-negate-btn {
  background: var(--bg-main); border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; padding: 3px 8px; display: inline-flex; align-items: center; gap: 4px;
  color: var(--success); font-size: 0.7rem; font-weight: 600; transition: all 0.15s;
  white-space: nowrap;
}
.fm-negate-btn:hover { border-color: var(--primary); }
.fm-negate-btn.fm-negate-active {
  color: var(--danger); border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.08);
}
/* Filter group (nested conditions) */
.fm-group {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 0.75rem; margin: 0.5rem 0;
  background: var(--bg-main);
}
.fm-group .fm-group {
  background: var(--bg-card);
  border-color: rgba(var(--primary-rgb),0.2);
}
.fm-group-header {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem;
  font-size: 0.75rem; color: var(--text-muted-c);
}
.fm-group-op {
  background: var(--primary); color: #fff; border: none; border-radius: 6px;
  padding: 2px 10px; font-size: 0.7rem; font-weight: 700; cursor: pointer;
  text-transform: uppercase;
}
.fm-group-op:hover { background: var(--primary-hover); }
.fm-group-op.fm-op-or { background: var(--warning); }
.fm-group-op.fm-op-or:hover { background: #D97706; }
.fm-group-actions {
  display: flex; gap: 0.5rem; margin-top: 0.5rem;
}
.fm-group-actions button {
  background: none; border: 1px dashed var(--border); border-radius: 8px;
  padding: 4px 12px; font-size: 0.72rem; color: var(--text-muted-c);
  cursor: pointer; transition: all 0.15s;
}
.fm-group-actions button:hover {
  border-color: var(--primary); color: var(--primary); background: rgba(var(--primary-rgb),0.05);
}
/* Drag-and-drop */
.fm-drag-over {
  outline: 2px dashed var(--primary) !important;
  outline-offset: 2px;
  background: rgba(var(--primary-rgb),0.04) !important;
}
.fm-row[draggable="true"]:hover .fm-drag-handle { opacity: 1 !important; }
.fm-row[draggable="true"] { transition: opacity 0.15s; }
