/* ============================================================
   CHATBOT DESCARY — Admin v3
   Design: Vitby.ai inspired — Clean, minimal, teal accent
   Typo: Inter (body + headings)
   ============================================================ */

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

/* --- Design Tokens --- */
:root {
    /* Spacing */
    --s-xs: 0.25rem; --s-sm: 0.5rem; --s-md: 1rem; --s-lg: 1.5rem; --s-xl: 2rem; --s-2xl: 3rem;
    /* Radius */
    --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 9999px;
    /* Sidebar */
    --sidebar-w: 240px; --sidebar-collapsed: 64px;
    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(.68, -.55, .27, 1.55);
}

/* --- Light Theme (default) --- */
html, html[data-theme="light"] {
    --bg: #ffffff;
    --bg-elevated: #ffffff;
    --bg-surface: #f9fafb;
    --bg-surface-hover: #f3f4f6;
    --border: #e5e7eb;
    --border-hover: #d1d5db;
    --text: #1a1a2e;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-glow: rgba(13,148,136,0.12);
    --accent-soft: rgba(13,148,136,0.06);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #eab308;
    --info: #3b82f6;
    --glass-bg: rgba(255,255,255,0.92);
    --glass-border: #e5e7eb;
    --glass-shadow: 0 4px 24px rgba(0,0,0,0.06);
    --header-bg: rgba(255,255,255,0.92);
    --sidebar-bg: #fafbfc;
    --indigo: #0d9488;
    --indigo-subtle: rgba(13,148,136,0.06);
}

/* --- Dark Theme --- */
html[data-theme="dark"] {
    --bg: #0f1117;
    --bg-elevated: #1a1d27;
    --bg-surface: #1e2130;
    --bg-surface-hover: #252938;
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.14);
    --text: #e5e7eb;
    --text-secondary: #b0b5c1;
    --text-muted: #6b7280;
    --text-dim: #4b5563;
    --accent: #14b8a6;
    --accent-hover: #0d9488;
    --accent-glow: rgba(20,184,166,0.18);
    --accent-soft: rgba(20,184,166,0.08);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #eab308;
    --info: #3b82f6;
    --glass-bg: rgba(26,29,39,0.92);
    --glass-border: rgba(255,255,255,0.08);
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.4);
    --header-bg: rgba(15,17,23,0.92);
    --sidebar-bg: #141720;
    --indigo: #14b8a6;
    --indigo-subtle: rgba(20,184,166,0.08);
}

/* --- Midnight Blue Theme --- */
html[data-theme="midnight"] {
    --bg: #0c1222;
    --bg-elevated: #131c31;
    --bg-surface: #182440;
    --bg-surface-hover: #1e2d4d;
    --border: rgba(59,130,246,0.12);
    --border-hover: rgba(59,130,246,0.22);
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59,130,246,0.18);
    --accent-soft: rgba(59,130,246,0.08);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #eab308;
    --info: #60a5fa;
    --glass-bg: rgba(19,28,49,0.92);
    --glass-border: rgba(59,130,246,0.1);
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.4);
    --header-bg: rgba(12,18,34,0.92);
    --sidebar-bg: #101828;
    --indigo: #3b82f6;
    --indigo-subtle: rgba(59,130,246,0.08);
}

/* --- Forest Green Theme --- */
html[data-theme="forest"] {
    --bg: #0b1610;
    --bg-elevated: #122118;
    --bg-surface: #182d20;
    --bg-surface-hover: #1f3828;
    --border: rgba(34,197,94,0.12);
    --border-hover: rgba(34,197,94,0.22);
    --text: #dcfce7;
    --text-secondary: #86efac;
    --text-muted: #6b9080;
    --text-dim: #4a6b5d;
    --accent: #22c55e;
    --accent-hover: #16a34a;
    --accent-glow: rgba(34,197,94,0.18);
    --accent-soft: rgba(34,197,94,0.08);
    --success: #4ade80;
    --danger: #ef4444;
    --warning: #eab308;
    --info: #3b82f6;
    --glass-bg: rgba(18,33,24,0.92);
    --glass-border: rgba(34,197,94,0.1);
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.4);
    --header-bg: rgba(11,22,16,0.92);
    --sidebar-bg: #0f1b14;
    --indigo: #22c55e;
    --indigo-subtle: rgba(34,197,94,0.08);
}

/* --- Warm Sunset Theme --- */
html[data-theme="sunset"] {
    --bg: #18110c;
    --bg-elevated: #231812;
    --bg-surface: #2e1f17;
    --bg-surface-hover: #3a271d;
    --border: rgba(245,158,11,0.12);
    --border-hover: rgba(245,158,11,0.22);
    --text: #fef3c7;
    --text-secondary: #d4a574;
    --text-muted: #92714d;
    --text-dim: #6b4f33;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-glow: rgba(245,158,11,0.18);
    --accent-soft: rgba(245,158,11,0.08);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #fbbf24;
    --info: #3b82f6;
    --glass-bg: rgba(35,24,18,0.92);
    --glass-border: rgba(245,158,11,0.1);
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.4);
    --header-bg: rgba(24,17,12,0.92);
    --sidebar-bg: #1d1410;
    --indigo: #f59e0b;
    --indigo-subtle: rgba(245,158,11,0.08);
}

/* --- Ocean Theme --- */
html[data-theme="ocean"] {
    --bg: #0b1628;
    --bg-elevated: #101e38;
    --bg-surface: #162848;
    --bg-surface-hover: #1c3256;
    --border: rgba(6,182,212,0.12);
    --border-hover: rgba(6,182,212,0.22);
    --text: #ecfeff;
    --text-secondary: #67e8f9;
    --text-muted: #5b8a95;
    --text-dim: #3d6370;
    --accent: #06b6d4;
    --accent-hover: #0891b2;
    --accent-glow: rgba(6,182,212,0.18);
    --accent-soft: rgba(6,182,212,0.08);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #eab308;
    --info: #22d3ee;
    --glass-bg: rgba(16,30,56,0.92);
    --glass-border: rgba(6,182,212,0.1);
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.4);
    --header-bg: rgba(11,22,40,0.92);
    --sidebar-bg: #0e1a30;
    --indigo: #06b6d4;
    --indigo-subtle: rgba(6,182,212,0.08);
}

/* --- Base --- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

h1, h2, h3, h4 {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    font-weight: 600;
    line-height: 1.3;
}

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

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============================================================
   LAYOUT
   ============================================================ */
.layout { display: flex; min-height: 100dvh; position: relative; z-index: 1; }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg, var(--bg-elevated));
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: width 0.3s var(--ease-out);
    overflow: hidden;
}

.sidebar-logo {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: var(--s-sm);
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}

.sidebar-logo-mark {
    width: 30px; height: 30px;
    background: var(--accent);
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-mark svg { width: 15px; height: 15px; }

.sidebar-logo-text {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    color: var(--text);
}

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

.nav-section {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    padding: 20px 12px 6px;
    font-weight: 600;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.nav-section:first-child {
    border-top: none;
    margin-top: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
    position: relative;
    margin-bottom: 1px;
}

.nav-link:hover { background: var(--bg-surface-hover); color: var(--text); text-decoration: none; }

.nav-link.active {
    background: transparent;
    color: var(--accent);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.5; }
.nav-link:hover svg { opacity: 0.8; }
.nav-link.active svg { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    padding: 1px 6px;
    border-radius: var(--r-full);
    font-weight: 700;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

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

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: var(--s-sm);
    padding: 8px;
    border-radius: var(--r-md);
    transition: background 0.15s;
    text-decoration: none;
    color: var(--text);
}

.sidebar-profile:hover { background: var(--bg-surface-hover); text-decoration: none; color: var(--text); }

.sidebar-avatar {
    width: 32px; height: 32px;
    border-radius: var(--r-full);
    background: var(--accent-soft);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 600; color: var(--accent);
    flex-shrink: 0;
}

.sidebar-profile-name { font-size: 0.8rem; font-weight: 500; }
.sidebar-profile-role { font-size: 0.65rem; color: var(--text-dim); }

/* --- Main Content --- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--bg);
}

/* --- Top Bar --- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--s-xl);
    height: 56px;
    display: flex;
    align-items: center;
    gap: var(--s-lg);
}

.topbar-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.topbar-search input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0.45rem 1rem 0.45rem 2.6rem;
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.topbar-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.topbar-search input::placeholder { color: var(--text-dim); }

.topbar-search svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    color: var(--text-dim);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--s-sm);
    margin-left: auto;
}

/* Language switcher */
.lang-switcher {
    position: relative;
}
.lang-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    min-width: 160px;
    z-index: 100;
    overflow: hidden;
}
html[data-theme="dark"] .lang-dropdown,
html[data-theme="dark"] .theme-dropdown,
html[data-theme="midnight"] .lang-dropdown,
html[data-theme="midnight"] .theme-dropdown,
html[data-theme="forest"] .lang-dropdown,
html[data-theme="forest"] .theme-dropdown,
html[data-theme="sunset"] .lang-dropdown,
html[data-theme="sunset"] .theme-dropdown,
html[data-theme="ocean"] .lang-dropdown,
html[data-theme="ocean"] .theme-dropdown {
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
html[data-theme="light"] .lang-dropdown,
html[data-theme="light"] .theme-dropdown {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.lang-dropdown.open {
    display: block;
}
.lang-option {
    display: block;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.1s;
}
.lang-option:hover {
    background: var(--bg-surface-hover);
}
.lang-option.active {
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-soft);
}

/* Theme switcher dropdown */
.theme-switcher {
    position: relative;
}
.theme-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    min-width: 180px;
    z-index: 100;
    overflow: hidden;
}
.theme-dropdown.open {
    display: block;
}
.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.1s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    font-family: inherit;
}
.theme-option:hover {
    background: var(--bg-surface-hover);
    text-decoration: none;
    color: var(--text);
}
.theme-option.active {
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-soft);
}
.theme-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid var(--border);
}
html[data-theme="light"] .theme-dot {
    border-color: rgba(0,0,0,0.1);
}

/* Sidebar theme picker */
.sidebar-theme-picker {
    padding: 4px 0.75rem 8px;
}
.sidebar-theme-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.sidebar-theme-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
    position: relative;
}
.sidebar-theme-dot:hover {
    transform: scale(1.15);
}
.sidebar-theme-dot.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}
.sidebar-theme-dot[title]::after {
    content: '';
}

.topbar-btn {
    width: 36px; height: 36px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.topbar-btn:hover { background: var(--bg-surface-hover); color: var(--text); border-color: var(--border-hover); }
.topbar-btn svg { width: 16px; height: 16px; }

/* --- Page Content --- */
.page { padding: var(--s-xl) var(--s-xl) var(--s-xl); max-width: 1280px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-xl);
    flex-wrap: wrap;
    gap: var(--s-md);
}

.page-header h1 { font-size: 20px; font-weight: 600; }

.breadcrumb { font-size: 12px; color: var(--text-dim); margin-bottom: var(--s-xs); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb span { margin: 0 6px; }

/* ============================================================
   BENTO GRID — Stats Dashboard
   ============================================================ */
.bento {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--s-md);
    margin-bottom: var(--s-xl);
}

.bento-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s var(--ease-out), border-color 0.2s;
    opacity: 0;
    transform: translateY(12px);
    animation: cardIn 0.4s var(--ease-out) forwards;
}

.bento-card:nth-child(1) { animation-delay: 0s; }
.bento-card:nth-child(2) { animation-delay: 0.06s; }
.bento-card:nth-child(3) { animation-delay: 0.12s; }
.bento-card:nth-child(4) { animation-delay: 0.18s; }

@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }

.bento-card:hover {
    border-color: var(--border-hover);
}

.bento-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
}

.bento-card:nth-child(1)::after { background: var(--accent); }
.bento-card:nth-child(2)::after { background: var(--success); }
.bento-card:nth-child(3)::after { background: var(--info); }
.bento-card:nth-child(4)::after { background: var(--warning); }

.bento-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 6px;
}

.bento-value {
    font-family: 'Inter', sans-serif;
    font-size: 2rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text);
}

.bento-trend {
    font-size: 12px;
    margin-top: 6px;
    color: var(--text-dim);
}

/* Large card spanning 2 columns */
.bento-card.span-2 { grid-column: span 2; }
.bento-card.span-3 { grid-column: span 3; }

/* ============================================================
   CARD
   ============================================================ */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px 24px;
    margin-bottom: var(--s-lg);
    opacity: 0;
    transform: translateY(12px);
    animation: cardIn 0.4s var(--ease-out) forwards;
    animation-delay: 0.1s;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-lg);
    padding-bottom: var(--s-md);
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg-surface-hover); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: rgba(34,197,94,0.1); color: #16a34a; }
.badge-danger { background: rgba(239,68,68,0.1); color: #dc2626; }
.badge-info { background: rgba(59,130,246,0.1); color: #2563eb; }
.badge-warning { background: rgba(234,179,8,0.1); color: #ca8a04; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* Dark themes: use brighter badge text colors */
html[data-theme="dark"] .badge-success,
html[data-theme="midnight"] .badge-success,
html[data-theme="forest"] .badge-success,
html[data-theme="sunset"] .badge-success,
html[data-theme="ocean"] .badge-success { color: var(--success); }
html[data-theme="dark"] .badge-danger,
html[data-theme="midnight"] .badge-danger,
html[data-theme="forest"] .badge-danger,
html[data-theme="sunset"] .badge-danger,
html[data-theme="ocean"] .badge-danger { color: var(--danger); }
html[data-theme="dark"] .badge-info,
html[data-theme="midnight"] .badge-info,
html[data-theme="forest"] .badge-info,
html[data-theme="sunset"] .badge-info,
html[data-theme="ocean"] .badge-info { color: var(--info); }
html[data-theme="dark"] .badge-warning,
html[data-theme="midnight"] .badge-warning,
html[data-theme="forest"] .badge-warning,
html[data-theme="sunset"] .badge-warning,
html[data-theme="ocean"] .badge-warning { color: var(--warning); }

.badge-dot::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:hover { text-decoration: none; }

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-surface-hover); color: var(--text); border-color: var(--border-hover); }

.btn-danger { background: rgba(239,68,68,0.08); color: var(--danger); border: 1px solid rgba(239,68,68,0.12); }
.btn-danger:hover { background: rgba(239,68,68,0.15); }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 12px; }
.btn-full { width: 100%; }
.btn-group { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: var(--s-lg); }
.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    font-size: 12px;
    color: var(--text-muted);
}

.form-hint { font-size: 12px; color: var(--text-dim); margin-top: 0.2rem; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="tel"],
input[type="date"], input[type="time"], input[type="color"],
select, textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-dim); }
textarea { resize: vertical; min-height: 100px; }

select {
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.2rem;
}

input[type="color"] { padding: 3px; height: 40px; width: 70px; cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-md); }

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ============================================================
   TABS — Config client
   ============================================================ */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--s-xl);
    overflow-x: auto;
}

.tab {
    padding: 0.7rem 1.2rem;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.tab:hover { color: var(--text); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--r-md);
    margin-bottom: var(--s-md);
    font-size: 14px;
    border: none;
    border-left: 4px solid transparent;
    animation: slideDown 0.3s var(--ease-out);
}

@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } }

.alert-success { background: rgba(34,197,94,0.06); border-left-color: var(--success); color: var(--success); }
.alert-error { background: rgba(239,68,68,0.06); border-left-color: var(--danger); color: var(--danger); }
.alert-warning { background: rgba(234,179,8,0.06); border-left-color: var(--warning); color: var(--warning); }

/* ============================================================
   SNIPPET
   ============================================================ */
.snippet {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: var(--s-md) var(--s-lg);
    border-radius: var(--r-md);
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 13px;
    color: var(--accent);
    position: relative;
    overflow-x: auto;
}

.snippet .copy-btn {
    position: absolute;
    top: 0.4rem; right: 0.4rem;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border);
    padding: 0.2rem 0.5rem;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 11px;
    color: var(--text-muted);
    font-family: inherit;
    transition: all 0.15s;
}

.snippet .copy-btn:hover { background: var(--border); color: var(--text); }

/* ============================================================
   MESSAGES (Conversations)
   ============================================================ */
.messages { display: flex; flex-direction: column; gap: 0.5rem; padding: var(--s-md) 0; }

.msg {
    padding: 0.7rem 1rem;
    border-radius: var(--r-lg);
    max-width: 75%;
    font-size: 14px;
    line-height: 1.6;
}

.msg-user { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-bot { background: var(--bg-surface); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-agent { background: var(--warning); color: #1a1a2e; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-system { background: none; color: var(--text-dim); font-size: 12px; text-align: center; max-width: 100%; align-self: stretch; font-style: italic; }

.msg-time { font-size: 0.6rem; opacity: 0.6; margin-top: 0.3rem; }

/* ============================================================
   ACTIVITY FEED
   ============================================================ */
.activity { display: flex; flex-direction: column; gap: 0; }

.activity-item {
    display: flex;
    align-items: center;
    gap: var(--s-md);
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.activity-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-dot.conv { background: var(--accent); }
.activity-dot.lead { background: var(--success); }
.activity-dot.transfer { background: var(--warning); }

.activity-text { flex: 1; color: var(--text-secondary); }
.activity-time { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty { text-align: center; padding: var(--s-2xl) var(--s-md); color: var(--text-dim); }
.empty-icon { font-size: 2.5rem; margin-bottom: var(--s-md); opacity: 0.3; }
.empty p { font-size: 14px; margin-bottom: var(--s-md); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    position: relative;
    z-index: 1;
    background: var(--bg);
}

.login-page::after {
    content: '';
    position: fixed;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    top: -150px; right: -100px;
    animation: drift 25s ease-in-out infinite;
    z-index: -1;
}

@keyframes drift {
    0%,100% { transform: translate(0,0); }
    50% { transform: translate(-40px, 30px); }
}

.login-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-xl);
    padding: var(--s-2xl);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--glass-shadow);
    animation: cardIn 0.5s var(--ease-out);
}

.login-logo { text-align: center; margin-bottom: var(--s-xl); }
.login-logo h1 { font-size: 1.3rem; margin-top: var(--s-sm); }
.login-logo p { color: var(--text-muted); font-size: 14px; }

.login-footer { text-align: center; margin-top: var(--s-xl); font-size: 12px; color: var(--text-dim); }

/* ============================================================
   MOBILE HEADER
   ============================================================ */
.mobile-bar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 60;
    align-items: center;
    padding: 0 var(--s-md);
    gap: var(--s-sm);
}

.hamburger {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--r-sm);
}

.hamburger:hover { background: var(--bg-surface); }
.hamburger svg { width: 20px; height: 20px; }

.mobile-title { font-family: 'Inter', sans-serif; font-weight: 600; font-size: 0.95rem; }

.overlay {
    display: none;
}

/* Menu mobile */
.mm-container {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99999;
}
.mm-container.mm-open {
    display: flex;
}
.mm-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1;
}
.mm-panel {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 270px;
    background: var(--bg-elevated);
    z-index: 2;
    padding: 12px;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    -webkit-overflow-scrolling: touch;
}
html[data-theme="dark"] .mm-panel,
html[data-theme="midnight"] .mm-panel,
html[data-theme="forest"] .mm-panel,
html[data-theme="sunset"] .mm-panel,
html[data-theme="ocean"] .mm-panel {
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
}
html[data-theme="light"] .mm-panel {
    background: #ffffff;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
}
.mm-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    padding: 14px 12px 4px;
    font-weight: 600;
}
.mm-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 14px;
    -webkit-tap-highlight-color: rgba(13,148,136,0.15);
}
.mm-link:active {
    background: var(--accent-soft);
}
.mm-link.mm-active {
    color: var(--accent);
    background: var(--accent-soft);
}
.mm-badge {
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: auto;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* Client card actions */
.client-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    border-top: 1px solid var(--border);
    padding-top: var(--s-md);
}

.client-actions .btn {
    font-size: 12px;
    padding: 0.35rem 0.5rem;
    justify-content: center;
}

.client-actions .btn svg { width: 11px; height: 11px; }

@media (max-width: 1100px) {
    .bento { grid-template-columns: repeat(2, 1fr); }
    .bento-card.span-2, .bento-card.span-3 { grid-column: span 1; }
    .form-row { grid-template-columns: 1fr 1fr; }
    .client-actions { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .mobile-bar { display: flex; }
    .sidebar {
        position: fixed;
        left: -300px;
        width: 270px;
        z-index: -1;
        pointer-events: none;
        opacity: 0;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .topbar {
        display: none !important;
    }
    .overlay {
        display: none;
    }

    .main { margin-left: 0; }
    .page { padding: calc(56px + var(--s-md)) var(--s-sm) var(--s-md); max-width: 100vw; overflow-x: hidden; }

    .topbar { display: none; }

    .bento { grid-template-columns: 1fr 1fr; gap: var(--s-sm); }
    .bento-card { padding: var(--s-md); }
    .bento-value { font-size: 1.5rem; }

    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header h1 { font-size: 1.2rem; }

    .client-actions { grid-template-columns: repeat(3, 1fr); }

    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { padding: 0.6rem 0.8rem; font-size: 12px; flex-shrink: 0; }

    .card { padding: var(--s-md); }

    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 500px; }

    .msg { max-width: 90%; }

    /* Cards clients en colonne */
    div[style*="grid-template-columns:repeat(auto-fill"] {
        grid-template-columns: 1fr !important;
    }

    /* Grilles 2 colonnes dans les cards */
    div[style*="grid-template-columns:repeat(3,1fr)"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Live chat layout */
    div[style*="grid-template-columns:300px"] {
        grid-template-columns: 1fr !important;
    }

    /* Conversation notes */
    div[style*="grid-template-columns:1fr 280px"] {
        grid-template-columns: 1fr !important;
    }

    .snippet { font-size: 11px; overflow-x: auto; }

    /* Activite recente en colonne */
    div[style*="grid-template-columns:1fr 2fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Preview iframe */
    #previewFrame { width: 100% !important; height: 400px !important; }

    /* Analytics filtres */
    form[style*="display:flex"][style*="flex-wrap:wrap"] {
        flex-direction: column !important;
    }

    /* Boutons d'en-tete */
    .btn-group { flex-wrap: wrap; }

    /* Schedule grid */
    div[style*="display:flex"][style*="gap:var(--s-md)"] > .checkbox-group { min-width: 90px !important; }
    input[type="time"] { width: 100px !important; }

    /* Horaire grille */
    div[style*="flex-direction:column"][style*="gap:0.4rem"] > div {
        flex-wrap: wrap;
    }
}

@media (max-width: 400px) {
    .bento { grid-template-columns: 1fr; }
    .client-actions { grid-template-columns: repeat(2, 1fr); }
    table { min-width: 350px; }
    .btn { font-size: 12px; padding: 0.4rem 0.75rem; }
    .card { padding: var(--s-sm); }
}

/* ============================================================
   HELP SYSTEM — Tooltips, Panel, Page
   ============================================================ */

/* Help icon (contextual tooltip trigger) */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: var(--r-full);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    vertical-align: middle;
    margin-left: 4px;
    flex-shrink: 0;
    line-height: 1;
    font-family: 'Inter', sans-serif;
}

.help-icon:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Help tooltip (floating panel from ? icon) */
.help-tooltip {
    position: absolute;
    z-index: 200;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-sm) var(--s-md);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 320px;
    min-width: 200px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    animation: tooltipIn 0.15s var(--ease-out);
    pointer-events: auto;
}

html[data-theme="dark"] .help-tooltip,
html[data-theme="midnight"] .help-tooltip,
html[data-theme="forest"] .help-tooltip,
html[data-theme="sunset"] .help-tooltip,
html[data-theme="ocean"] .help-tooltip {
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.help-tooltip::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 16px;
    width: 10px;
    height: 10px;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: rotate(45deg);
}

@keyframes tooltipIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Help page — TOC links */
.help-toc-link {
    display: block;
    padding: 0.4rem 0.6rem;
    border-radius: var(--r-sm);
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s;
}
.help-toc-link:hover {
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}

/* Help section smooth scroll target offset */
.help-section {
    scroll-margin-top: 80px;
}

/* Contextual help panel (slide-in from right) */
.help-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    max-width: 90vw;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    z-index: 99998;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    box-shadow: -4px 0 16px rgba(0,0,0,0.06);
}

html[data-theme="dark"] .help-panel,
html[data-theme="midnight"] .help-panel,
html[data-theme="forest"] .help-panel,
html[data-theme="sunset"] .help-panel,
html[data-theme="ocean"] .help-panel {
    box-shadow: -8px 0 32px rgba(0,0,0,0.3);
}

.help-panel.open {
    right: 0 !important;
}

.help-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.help-panel-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.help-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-lg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.help-panel-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.help-panel-close {
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.help-panel-close:hover {
    background: var(--bg-surface-hover);
    color: var(--text);
}

.help-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--s-lg);
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.help-panel-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--s-sm);
    margin-top: var(--s-lg);
    color: var(--text);
}

.help-panel-content h4:first-child {
    margin-top: 0;
}

.help-panel-content p {
    margin-bottom: var(--s-sm);
}

.help-panel-content ul {
    padding-left: var(--s-lg);
    margin-bottom: var(--s-sm);
}

.help-panel-content li {
    margin-bottom: var(--s-xs);
}

.help-panel-footer {
    padding: var(--s-md) var(--s-lg);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* Topbar help button */
.topbar-btn-help {
    width: 36px;
    height: 36px;
    border-radius: var(--r-full);
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
}

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

@media (max-width: 768px) {
    .help-panel {
        width: 100vw;
        max-width: 100vw;
        right: -100vw;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
