/* ============================================================
   SaaS Support Chat — Design System
   Intercom-inspired, CSS variables, Inter font
   ============================================================ */

:root {
    /* Layout */
    --sidebar-w: 56px;
    --sidebar-w-open: 240px;

    /* Sidebar — Intercom dark */
    --sidebar-bg: #0f1117;
    --sidebar-border: rgba(255,255,255,.06);
    --sidebar-text: #8b92a5;
    --sidebar-hover: rgba(255,255,255,.06);
    --sidebar-active: #2563eb;
    --sidebar-active-bg: rgba(37,99,235,.12);

    /* Surfaces */
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface-2: #fafafa;
    --surface-3: #f0f0f0;
    --border: #e8e8e8;
    --border-2: #d4d4d4;

    /* Text */
    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --text-muted: #999999;

    /* Brand */
    --primary: #0057ff;
    --primary-light: #f0f4ff;
    --primary-hover: #0046d4;
    --primary-dark: #003db3;

    /* Semantic */
    --green: #00a67d;
    --green-light: #e6f7f2;
    --red: #e5484d;
    --red-light: #fff0f0;
    --yellow: #f5a623;
    --yellow-light: #fff8eb;
    --purple: #8b5cf6;
    --purple-light: #f5f3ff;

    /* Components */
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 16px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
    --transition: 0.15s ease;
    --transition-slow: 0.3s cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

::selection {
    background: rgba(0,87,255,.15);
}

/* ============================================================
   LAYOUT: sidebar + main
   ============================================================ */

.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   SIDEBAR — Intercom style dark panel
   ============================================================ */

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-slow), min-width var(--transition-slow);
    overflow: hidden;
    z-index: 100;
}

.sidebar.open {
    width: var(--sidebar-w-open);
    min-width: var(--sidebar-w-open);
}

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    height: 56px;
    flex-shrink: 0;
}

.logo-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.logo-text {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition-slow);
    letter-spacing: -0.2px;
}

.sidebar.open .logo-text {
    opacity: 1;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: 4px 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.25);
    padding: 16px 8px 6px;
    white-space: nowrap;
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: opacity var(--transition-slow);
}

.sidebar.open .nav-section-label {
    opacity: 1;
    height: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 1px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #e0e0e0;
    text-decoration: none;
}

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

.nav-item.active .nav-icon {
    color: var(--sidebar-active);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.nav-label {
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.sidebar.open .nav-label {
    opacity: 1;
}

/* Badge on nav item */
.nav-badge {
    position: absolute;
    top: 4px;
    left: 26px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sidebar.open .nav-badge {
    position: static;
    margin-left: auto;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
    font-family: inherit;
    font-size: 13px;
}

.sidebar-toggle:hover {
    background: var(--sidebar-hover);
    color: #e0e0e0;
}

.toggle-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: transform var(--transition-slow);
}

.sidebar.open .toggle-icon {
    transform: rotate(180deg);
}

.toggle-label {
    opacity: 0;
    white-space: nowrap;
    transition: opacity var(--transition-slow);
}

.sidebar.open .toggle-label {
    opacity: 1;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* Topbar — clean Intercom style */
.topbar {
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 6px;
}

.topbar-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition);
}

.topbar-btn:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

/* User avatar */
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.user-avatar:hover {
    text-decoration: none;
    opacity: 0.85;
}

/* Content area */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ============================================================
   COMMON COMPONENTS
   ============================================================ */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    text-decoration: none;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--surface-2);
    border-color: var(--border-2);
    text-decoration: none;
}

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.badge-green  { background: var(--green-light); color: var(--green); }
.badge-red    { background: var(--red-light); color: var(--red); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-blue   { background: var(--primary-light); color: var(--primary); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 15px;
    margin: 0;
}

/* ============================================================
   MODULE PAGES — shared styles for all non-inbox modules
   ============================================================ */

.module-page {
    padding: 24px;
    max-width: 1200px;
}

.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.module-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.2px;
}

/* Card grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

/* Channel card */
.channel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: box-shadow var(--transition);
}

.channel-card:hover {
    box-shadow: var(--shadow-md);
}

.channel-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.channel-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}

.channel-card-title i {
    font-size: 20px;
    color: var(--primary);
}

.channel-card-actions {
    display: flex;
    gap: 4px;
}

.channel-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Code snippet */
.code-snippet {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 12px;
    color: var(--text-secondary);
    word-break: break-all;
    position: relative;
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.code-snippet:hover {
    background: var(--surface-3);
}

.code-snippet code {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.code-snippet .copy-icon {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 16px;
    transition: color var(--transition);
}

.code-snippet:hover .copy-icon {
    color: var(--primary);
}

.code-snippet.copied {
    border-color: var(--green);
}

.code-snippet.copied .copy-icon {
    color: var(--green);
}

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table th {
    background: var(--surface-2);
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--surface-2);
}

.data-table .cell-actions {
    text-align: right;
    white-space: nowrap;
}

/* Form styles */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
}

.form-section-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.2px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,87,255,.08);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn .15s ease;
    padding: 20px;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp .2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 0 24px 20px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border-2);
    border-radius: 12px;
    transition: background var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

.toggle input:checked + .toggle-slider {
    background: var(--green);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* Alert / toast */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: var(--green-light);
    color: var(--green);
}

.alert-error {
    background: var(--red-light);
    color: var(--red);
}

/* Search bar for module pages */
.module-search {
    position: relative;
    max-width: 300px;
}

.module-search input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--surface);
}

.module-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,87,255,.08);
}

.module-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

/* Animation keyframes */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

/* Contact avatar (colored) */
.contact-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

/* ============================================================
   AI TRAINING — knowledge base module
   ============================================================ */

.ai-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.ai-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.ai-stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.ai-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.ai-filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.ai-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all .15s;
    margin-bottom: -1px;
}

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

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

.knowledge-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.knowledge-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    transition: all .15s;
}

.knowledge-item:hover {
    border-color: var(--border-2);
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.knowledge-item.inactive {
    opacity: .5;
}

.knowledge-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.knowledge-item-info {
    display: flex;
    align-items: center;
    font-size: 14px;
    min-width: 0;
    overflow: hidden;
}

.knowledge-item-info strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.knowledge-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .15s;
}

.knowledge-item:hover .knowledge-item-actions {
    opacity: 1;
}

.knowledge-item-preview {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   AI SUGGESTION BAR — in inbox chat
   ============================================================ */

.ai-suggestion-bar {
    background: linear-gradient(135deg, #eef2ff, #f0e6ff);
    border: 1px solid rgba(99,102,241,.2);
    border-radius: 10px;
    padding: 12px 14px;
    margin: 0 16px 8px;
    display: none;
}

.ai-suggestion-bar.visible {
    display: block;
    animation: slideUp .2s ease;
}

.ai-suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.ai-suggestion-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6366f1;
}

.ai-suggestion-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
}

.ai-suggestion-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    margin-bottom: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.ai-suggestion-actions {
    display: flex;
    gap: 8px;
}

.ai-suggestion-actions .btn {
    font-size: 12px;
    padding: 4px 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* ============================================================
   DASHBOARD
   ============================================================ */

.dash-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.dash-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow var(--transition);
}

.dash-stat-card:hover {
    box-shadow: var(--shadow-md);
}

.dash-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.dash-stat-body {
    min-width: 0;
}

.dash-stat-number {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.dash-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
}

.dash-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.dash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.dash-card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

/* Bar chart */
.dash-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 160px;
    padding-top: 10px;
}

.dash-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.dash-bar-value {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.dash-bar {
    width: 100%;
    max-width: 36px;
    min-height: 4px;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
}

.dash-bar-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Channels breakdown */
.dash-channels {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dash-channel-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dash-channel-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.dash-channel-info i {
    font-size: 16px;
    color: var(--primary);
}

.dash-channel-count {
    margin-left: auto;
    font-weight: 600;
    color: var(--text-secondary);
}

.dash-channel-bar {
    height: 6px;
    background: var(--surface-3);
    border-radius: 3px;
    overflow: hidden;
}

.dash-channel-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    min-width: 2px;
    transition: width 0.5s ease;
}

/* ============================================================
   CANNED RESPONSES DROPDOWN
   ============================================================ */

.canned-dropdown {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 260px;
    overflow-y: auto;
    z-index: 50;
    margin-bottom: 4px;
}

.canned-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background var(--transition);
}

.canned-option:hover,
.canned-option.active {
    background: var(--primary-light);
}

.canned-option:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.canned-option:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.canned-shortcut {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.canned-title {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   AUDIT LOG
   ============================================================ */

.audit-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.audit-item:hover {
    background: var(--surface-2);
}

.audit-item:last-child {
    border-bottom: none;
}

.audit-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.audit-body {
    flex: 1;
    min-width: 0;
}

.audit-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audit-action {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.audit-user {
    font-size: 12px;
    color: var(--text-muted);
}

.audit-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audit-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================================
   SCROLLBAR — thin & subtle
   ============================================================ */

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.12);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,.22);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
        width: var(--sidebar-w-open) !important;
        min-width: var(--sidebar-w-open) !important;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar.open .nav-label,
    .sidebar.open .logo-text,
    .sidebar.open .toggle-label,
    .sidebar.open .nav-section-label {
        opacity: 1;
    }

    .dash-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .dash-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   DND Toggle — Do Not Disturb (calls)
   ============================================================ */

.dnd-toggle {
    position: relative;
}
.dnd-toggle.dnd-active {
    color: var(--red) !important;
    background: var(--red-light);
}
.dnd-toggle.dnd-active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
    border: 1.5px solid var(--surface);
}

/* ============================================================
   Call Popup — Global incoming call notification
   ============================================================ */

.call-popup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    animation: callPopupSlide 0.3s ease-out;
}

@keyframes callPopupSlide {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.call-popup-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1a1a2e;
    color: #fff;
    padding: 14px 16px;
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,.3);
    min-width: 280px;
}

.call-popup-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #10b981;
    flex-shrink: 0;
}

.call-popup-ring {
    animation: callRing 1s ease-in-out infinite;
}

@keyframes callRing {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(15deg); }
    20% { transform: rotate(-15deg); }
    30% { transform: rotate(10deg); }
    40% { transform: rotate(-10deg); }
    50% { transform: rotate(5deg); }
    60% { transform: rotate(0deg); }
}

.call-popup-info {
    flex: 1;
    min-width: 0;
}

.call-popup-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-popup-number {
    font-size: 12px;
    color: rgba(255,255,255,.6);
}

.call-popup-label {
    font-size: 11px;
    color: #10b981;
    margin-top: 2px;
}

.call-popup-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.call-popup-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.15s;
}
.call-popup-btn:hover {
    transform: scale(1.1);
}

.call-popup-goto {
    background: rgba(255,255,255,.15);
    color: #fff;
}

.call-popup-dismiss {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Spin animation for loaders */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}
