/* ===== BeautyBot Design System — from Figma ===== */

/* Google Fonts: Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== Theme Variables ===== */
:root, [data-theme="light"] {
    --bg-primary: #f9fafb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3f4f6;
    --bg-card: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-placeholder: #9ca3af;
    --accent: #ec4899;
    --accent-secondary: #9333ea;
    --accent-hover: #db2777;
    --accent-light: rgba(236, 72, 153, 0.08);
    --accent-gradient: linear-gradient(to right, #ec4899, #9333ea);
    --success: #15803d;
    --success-bg: #dcfce7;
    --warning: #a16207;
    --warning-bg: #fef9c3;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --info: #1d4ed8;
    --info-bg: #dbeafe;
    --border: #fce7f3;
    --border-secondary: #fbcfe8;
    --border-neutral: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(236, 72, 153, 0.08);
    --sidebar-width: 220px;
    --header-height: 56px;
    --input-bg: rgba(252, 243, 247, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --pink-50: #fdf2f8;
    --pink-100: #fce7f3;
    --pink-700: #be185d;
    --purple-100: #f3e8ff;
    --purple-700: #7e22ce;
}

[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #252836;
    --bg-card: #1e2130;
    --text-primary: #e4e6eb;
    --text-secondary: #a8aab0;
    --text-muted: #6c6e72;
    --text-placeholder: #555770;
    --accent: #f472b6;
    --accent-secondary: #a855f7;
    --accent-hover: #ec4899;
    --accent-light: rgba(244, 114, 182, 0.12);
    --accent-gradient: linear-gradient(to right, #f472b6, #a855f7);
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.15);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.15);
    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, 0.15);
    --border: #2d303d;
    --border-secondary: #3d2a4a;
    --border-neutral: #2d303d;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --input-bg: #252836;
    --pink-50: rgba(253, 242, 248, 0.06);
    --pink-100: rgba(252, 231, 243, 0.1);
    --pink-700: #f9a8d4;
    --purple-100: rgba(243, 232, 255, 0.1);
    --purple-700: #c084fc;
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== Auth ===== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    background: var(--bg-primary);
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}
.auth-logo span { font-size: 13px; color: var(--text-muted); }
.auth-form h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; text-align: center; }
.form-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.form-success { color: var(--success); font-size: 13px; margin-bottom: 12px; min-height: 18px; word-break: break-all; }
.auth-links { display: flex; justify-content: center; gap: 16px; margin-top: 16px; }
.auth-links a { color: var(--accent); text-decoration: none; font-size: 13px; }
.auth-links a:hover { text-decoration: underline; color: var(--accent-hover); }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    height: 44px;
}
.form-group textarea { height: auto; min-height: 70px; resize: vertical; }
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-placeholder);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-group input:disabled,
.form-group textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-neutral);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-neutral);
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--accent-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}
.brand-text h1 {
    font-size: 16px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}
.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    line-height: 1.3;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 12px 20px 4px;
    opacity: 0.7;
}
.nav-menu { list-style: none; padding: 0 0 4px; }
.nav-item {
    padding: 9px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--pink-50); color: var(--text-primary); }
.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}
.nav-icon { font-size: 15px; width: 20px; text-align: center; }
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-neutral);
    margin-top: auto;
}
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}
.theme-toggle input { display: none; }
.theme-toggle-track {
    width: 40px;
    height: 22px;
    background: var(--border-neutral);
    border-radius: 11px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.theme-toggle-track::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .theme-toggle-track {
    background: var(--accent-gradient);
}
[data-theme="dark"] .theme-toggle-track::after { transform: translateX(18px); }

/* ===== Content ===== */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    width: calc(100vw - var(--sidebar-width));
    display: flex;
    flex-direction: column;
}

/* ===== Main Header (common) ===== */
.main-header {
    padding: 0 32px;
    height: var(--header-height);
    min-height: var(--header-height);
    border-bottom: 1px solid var(--border-neutral);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 50;
}
.main-header h2 { font-size: 17px; font-weight: 700; }
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-user {
    position: relative;
}
.header-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.header-user-info:hover { background: var(--pink-50); }
.header-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.header-role-badge {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.header-chevron {
    color: var(--text-muted);
    transition: transform 0.2s;
}
.header-user-info.open .header-chevron { transform: rotate(180deg); }
.header-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-neutral);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 6px 0;
    z-index: 200;
}
.header-dropdown.open { display: block; }
.header-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.1s;
    cursor: pointer;
}
.header-dropdown a:hover { background: var(--pink-50); color: var(--text-primary); }
.header-dropdown a .dd-icon { width: 18px; text-align: center; font-size: 14px; }
.header-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-neutral);
    margin: 4px 0;
}
.header-dropdown a.dd-danger { color: var(--danger); }
.header-dropdown a.dd-danger:hover { background: var(--danger-bg); }

/* Header avatar */
.header-avatar {
    width: 32px; height: 32px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.header-user-text {
    display: flex; flex-direction: column; gap: 1px;
}

/* Impersonation banner */
.impersonation-banner {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a1a;
    padding: 8px 32px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}
.impersonation-banner strong { font-weight: 700; }
.impersonation-banner .btn { margin-left: 12px; }

/* ===== Page Header (inline, for actions row below main header) ===== */
.page-header {
    padding: 14px 32px;
    border-bottom: 1px solid var(--border-neutral);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
}
.page-header h2 { font-size: 17px; font-weight: 700; }
.filters { display: flex; gap: 8px; }
.filters select {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-family: inherit;
}

/* ===== Page Body ===== */
.page-body { padding: 24px 32px; }

/* ===== Conversations Layout ===== */
.conversations-layout {
    display: flex;
    height: calc(100vh - var(--header-height) - var(--header-height));
}
.conversation-list {
    width: 340px;
    min-width: 340px;
    border-right: 1px solid var(--border-neutral);
    overflow-y: auto;
    background: var(--bg-secondary);
}
.conversation-detail {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ===== Conversation Item ===== */
.conv-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-neutral);
    cursor: pointer;
    transition: background 0.1s;
}
.conv-item:hover { background: var(--pink-50); }
.conv-item.active { background: var(--accent-light); border-left: 3px solid var(--accent); }
.conv-item-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.conv-item-name { font-weight: 600; font-size: 14px; }
.conv-item-time { font-size: 11px; color: var(--text-muted); }
.conv-item-preview {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-item-meta { display: flex; gap: 6px; margin-top: 4px; }

/* ===== Badges ===== */
.badge {
    font-size: 12px;
    padding: 3px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    display: inline-block;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-human { background: var(--warning-bg); color: var(--warning); }
.badge-resolved { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-assigned { background: #e3f2fd; color: #1565c0; font-size: 0.7em; }
.badge-completed { background: #d4edda; color: #155724; }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-premium { background: var(--purple-100); color: var(--purple-700); }
.badge-vip { background: var(--pink-100); color: var(--pink-700); }
.badge-gradient {
    background: var(--accent-gradient);
    color: white;
    border-radius: 999px;
}

/* ===== Tab Bar ===== */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-neutral);
}
.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: inherit;
    transition: all 0.15s;
}
.tab-btn:hover {
    color: var(--text-primary);
}
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ===== Chat Detail ===== */
.chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-neutral);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
}
.chat-header-info h3 { font-size: 15px; font-weight: 600; }
.chat-actions { display: flex; gap: 8px; }

/* ===== Buttons ===== */
.btn {
    padding: 10px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s;
}
.btn-primary {
    background: var(--accent-gradient);
    color: white;
}
.btn-primary:hover { opacity: 0.9; }
.btn-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid transparent;
}
.btn-warning:hover { border-color: var(--warning); }
.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid transparent;
}
.btn-danger:hover { border-color: var(--danger); }
.btn-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid transparent;
}
.btn-success:hover { border-color: #155724; }

/* Token expiry banner */
.token-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    animation: slideDown 0.3s ease;
}
.token-banner-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.3);
}
.token-banner-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.btn-outline {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-full { width: 100%; padding: 12px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ===== Messages ===== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-primary);
}
.message {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.5;
}
.message-user {
    align-self: flex-end;
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}
.message-assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.message-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.message-user .message-time { color: rgba(255,255,255,0.7); }
.message-type-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--accent-light);
    color: var(--accent);
    margin-bottom: 4px;
    display: inline-block;
}
.voice-transcript { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== Draft Messages ===== */
.message-draft {
    align-self: flex-start;
    background: var(--warning-bg);
    border: 1px dashed var(--warning);
    border-bottom-left-radius: 4px;
}
.draft-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ===== Input Area ===== */
.chat-input {
    padding: 14px 20px;
    border-top: 1px solid var(--border-neutral);
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
}
.chat-input input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    height: 44px;
}
.chat-input input::placeholder { color: var(--text-placeholder); }
.chat-input input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-header h4 { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Settings Grid ===== */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}
.settings-grid > .card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

/* ===== Tables ===== */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-neutral);
    font-size: 14px;
}
.data-table th {
    background: var(--pink-50);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table tr:hover { background: var(--accent-light); }

/* ===== Stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.stat-value {
    font-size: 32px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-detail { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-card-success { border-left: 4px solid var(--success); }
.stat-card-success .stat-value { background: none; -webkit-text-fill-color: var(--success); color: var(--success); }
.stat-card-warning { border-left: 4px solid var(--warning); }
.stat-card-warning .stat-value { background: none; -webkit-text-fill-color: var(--warning); color: var(--warning); }
.stat-card-accent { border-left: 4px solid var(--accent); }
.stat-card-revenue { border-left: 4px solid #10b981; }
.stat-card-revenue .stat-value { background: none; -webkit-text-fill-color: #10b981; color: #10b981; }
.stats-grid-sm { margin-top: 16px; }
.section-title { font-size: 15px; color: var(--text-secondary); margin: 24px 0 12px; font-weight: 600; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 12px 16px; background: var(--bg-tertiary); color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-neutral); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-tertiary); }

/* ===== WhatsApp Setup Help ===== */
.wa-setup-help {
    background: var(--pink-50);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}
.wa-setup-help p { margin-bottom: 8px; font-weight: 600; }
.wa-setup-help ol { padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

/* ===== Agent Tabs ===== */
.agent-selector { margin-bottom: 16px; }
.agent-selector select {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
}
.agent-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-neutral);
    margin-bottom: 24px;
}
.agent-tab {
    padding: 10px 24px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    font-weight: 500;
    font-family: inherit;
}
.agent-tab:hover { color: var(--text-primary); }
.agent-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== Status Toggle ===== */
.status-toggle { display: flex; flex-direction: column; gap: 8px; }
.status-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.status-option input { display: none; }
.status-option:hover { border-color: var(--accent); }
.status-option.active {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--accent-light);
}
.status-option-label { font-size: 14px; font-weight: 600; display: block; }
.status-option-desc { font-size: 12px; color: var(--text-muted); display: block; margin-top: 2px; }

/* ===== Prompt Builder ===== */
.prompt-builder { display: grid; grid-template-columns: 1fr 400px; gap: 24px; }
.prompt-fields { min-width: 0; }
.prompt-preview {
    background: var(--pink-50);
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    color: var(--text-secondary);
    font-family: inherit;
    border: 1px solid var(--border);
}

/* ===== Test Chat Panel ===== */
.test-chat-panel .card {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
}
.test-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    min-height: 300px;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-primary);
}
.test-chat-messages .message { max-width: 85%; font-size: 13px; }
.test-chat-messages .empty-state { min-height: 100px; }
.test-chat-input {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}
.test-chat-input input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}
.test-chat-input input::placeholder { color: var(--text-placeholder); }
.test-chat-input input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ===== Training Section ===== */
.training-section { display: flex; flex-direction: column; gap: 20px; }
.training-actions h3, .training-docs-header h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.training-buttons { display: flex; gap: 8px; }
.training-docs-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.add-content-card { margin-bottom: 16px; border-color: var(--accent); }

/* ===== Knowledge toolbar ===== */
.knowledge-toolbar { margin-bottom: 20px; }
.upload-area { display: flex; align-items: center; gap: 12px; }
.upload-area input[type="file"] {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-family: inherit;
}

/* ===== Range input ===== */
input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--border-neutral);
    outline: none;
    border: none;
    padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--accent-gradient);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

/* ===== Empty State / Loading ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 14px;
    gap: 12px;
}
.loading { padding: 20px; text-align: center; color: var(--text-muted); }

/* ===== Calendar Page ===== */

/* Month navigation */
.cal-month-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.cal-month-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 160px;
    text-align: center;
}
.cal-month-nav select {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
}

/* Month grid */
.cal-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-neutral);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.cal-month-header {
    background: var(--pink-50);
    padding: 10px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cal-month-cell {
    background: var(--bg-card);
    padding: 8px 10px;
    min-height: 64px;
    position: relative;
}
.cal-month-empty { background: var(--bg-tertiary); }
.cal-day-num { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.cal-today { background: var(--accent-light); }
.cal-today .cal-day-num {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}
.cal-has-appts .cal-day-num { font-weight: 700; color: var(--text-primary); }
.cal-day-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent-gradient);
    color: white;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

/* View toggle */
.cal-view-toggle {
    display: inline-flex;
    gap: 4px;
    margin-left: 12px;
}

/* ===== Week Grid ===== */
.cal-week-grid {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--border-neutral);
}
.cal-week-header-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    gap: 1px;
}
.cal-week-time-header {
    background: var(--pink-50);
    padding: 10px;
}
.cal-week-day-header {
    background: var(--pink-50);
    padding: 10px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.cal-week-day-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cal-week-day-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.cal-week-today-header { background: var(--accent-light); }
.cal-week-today-num {
    background: var(--accent-gradient);
    color: white !important;
}
.cal-week-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 480px;
    overflow-y: auto;
}
.cal-week-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    gap: 1px;
    min-height: 48px;
}
.cal-week-time-label {
    background: var(--bg-tertiary);
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: right;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}
.cal-week-cell {
    background: var(--bg-card);
    position: relative;
    padding: 2px;
    min-height: 48px;
}
.cal-week-today-col {
    background: var(--accent-light);
}
.cal-week-appt {
    background: var(--pink-50);
    border-radius: 4px;
    padding: 3px 6px;
    margin-bottom: 2px;
    font-size: 11px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}
.cal-week-appt:hover {
    background: var(--pink-100);
}
.cal-week-appt-time {
    font-weight: 600;
    color: var(--text-secondary);
}
.cal-week-appt-dur {
    color: var(--text-muted);
    font-size: 10px;
}

/* ===== Day Grid ===== */
.cal-day-grid {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--border-neutral);
}
.cal-day-header-row {
    display: grid;
    grid-template-columns: 60px repeat(var(--day-col-count, 1), 1fr);
    gap: 1px;
}
.cal-day-time-header {
    background: var(--pink-50);
    padding: 10px;
}
.cal-day-member-header {
    background: var(--pink-50);
    padding: 12px 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: capitalize;
}
.cal-day-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 520px;
    overflow-y: auto;
}
.cal-day-row {
    display: grid;
    grid-template-columns: 60px repeat(var(--day-col-count, 1), 1fr);
    gap: 1px;
    min-height: 52px;
}
.cal-day-time-label {
    background: var(--bg-tertiary);
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: right;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}
.cal-day-cell {
    background: var(--bg-card);
    padding: 4px;
    min-height: 52px;
}
.cal-day-appt {
    background: var(--pink-50);
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 4px;
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.cal-day-appt:hover {
    background: var(--pink-100);
}
.cal-day-appt-time {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.cal-day-appt-dur {
    font-size: 11px;
    color: var(--text-muted);
}
.cal-day-appt-notes {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* Availability + Time-off slot states */
.cal-slot-available {
    background: rgba(21, 128, 61, 0.06) !important;
}
.cal-slot-timeoff {
    background: var(--bg-tertiary) !important;
    position: relative;
}
.cal-slot-timeoff::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 4px,
        rgba(107, 114, 128, 0.08) 4px,
        rgba(107, 114, 128, 0.08) 8px
    );
    pointer-events: none;
}
.cal-slot-empty {
    width: 100%;
    height: 100%;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-placeholder);
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}
.cal-slot-empty:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* Appointment name */
.cal-week-appt-name,
.cal-day-appt-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

/* Week grid sub-columns (round robin) */
.cal-week-subcols {
    display: flex;
    gap: 1px;
    margin-top: 4px;
    width: 100%;
}
.cal-week-subcol-name {
    flex: 1;
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-week-subcols-body {
    display: flex;
    gap: 1px;
    height: 100%;
}
.cal-week-subcol {
    flex: 1;
    min-width: 0;
    padding: 2px;
    position: relative;
}
.cal-week-subcols-mode .cal-week-cell {
    padding: 0;
}

/* ===== Week/Day responsive ===== */
@media (max-width: 768px) {
    .cal-week-grid { overflow-x: auto; }
    .cal-week-header-row,
    .cal-week-row {
        min-width: 600px;
    }
    .cal-day-grid { overflow-x: auto; }
    .cal-week-subcols-mode .cal-week-header-row,
    .cal-week-subcols-mode .cal-week-row {
        min-width: 900px;
    }
}

/* Working hours grid */
.wh-grid { display: flex; flex-direction: column; gap: 4px; }
.wh-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.wh-row:last-child { border-bottom: none; }
.wh-toggle { display: flex; align-items: center; gap: 8px; min-width: 130px; cursor: pointer; }
.wh-day { font-size: 14px; color: var(--text-primary); font-weight: 500; }
.wh-sep { color: var(--text-muted); font-size: 13px; }
.wh-row input[type="time"] {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    max-width: 120px;
}
.wh-row input[type="time"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); outline: none; }
.wh-row input[type="time"]:disabled { opacity: 0.35; }

/* Reminder options (reuse status-option) */
.reminder-options { display: flex; flex-direction: column; gap: 8px; }
.reminder-options .status-option input[type="checkbox"] { display: none; }

/* Team - add member section */
.add-member-section { padding-bottom: 8px; margin-bottom: 12px; }

/* Custom checkbox for team assignment */
.cal-checkbox { display: flex; align-items: center; cursor: pointer; }
.cal-checkbox input { display: none; }
.cal-checkmark {
    width: 20px; height: 20px;
    border: 2px solid var(--border-secondary);
    border-radius: 6px;
    position: relative;
    transition: all 0.15s;
}
.cal-checkbox input:checked + .cal-checkmark {
    background: var(--accent-gradient);
    border-color: transparent;
}
.cal-checkbox input:checked + .cal-checkmark::after {
    content: '';
    position: absolute;
    left: 5px; top: 2px;
    width: 6px; height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ===== Charts Grid ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}
.chart-card { min-height: 300px; }
.chart-card .card-body { padding: 16px; }
.chart-card-sm { min-height: 280px; max-width: 400px; }
.chart-card-sm .card-body { padding: 16px; display: flex; align-items: center; justify-content: center; }

/* ===== Page Header with Button ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .settings-grid { grid-template-columns: 1fr; }
    .prompt-builder { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h1, .version, .nav-item span:not(.nav-icon),
    .sidebar-footer, .wiki-link, .theme-toggle { display: none; }
    .header-user-text { display: none; }
    .content { margin-left: 60px; width: calc(100vw - 60px); }
    .conversation-list { width: 100%; min-width: 0; }
    .conversation-detail { display: none; }
    .form-row { grid-template-columns: 1fr; }
    .auth-card { margin: 16px; padding: 24px; }
    .test-chat-panel .card { position: static; max-height: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-card-sm { max-width: none; }
}

/* ===== Google Calendar Integration ===== */
.integration-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
}

.integration-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.integration-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.integration-status {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.integration-actions {
    flex-shrink: 0;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.status-dot.green {
    background: #34a853;
}

/* ===== Agents Grid ===== */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 0;
}
.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border-neutral);
    border-radius: var(--radius-md);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}
.agent-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.agent-card-icon {
    width: 56px; height: 56px;
    background: var(--accent-light);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}
.agent-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.agent-card p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}
.agent-card-new {
    border-style: dashed;
    border-color: var(--border-neutral);
    background: transparent;
    opacity: 0.7;
}
.agent-card-new:hover {
    border-color: var(--accent);
    opacity: 1;
    background: var(--accent-light);
}
.agent-card-new .agent-card-icon {
    background: var(--bg-tertiary);
    font-size: 24px;
    color: var(--text-muted);
}
.agent-detail-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    font-weight: 500;
    padding: 0;
    margin-bottom: 16px;
}
.agent-detail-back:hover { text-decoration: underline; }
.agent-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.agent-detail-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

/* ===== Docs Page ===== */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.doc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-neutral);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: all 0.2s;
}
.doc-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}
.doc-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.doc-card p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

/* ===== Roles Info ===== */
.roles-legend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.role-info-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.role-info-card h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.role-info-card p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.btn-outline-danger {
    background: transparent;
    color: #ea4335;
    border: 1px solid #ea4335;
    padding: 6px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-outline-danger:hover {
    background: #ea4335;
    color: #fff;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}
.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-neutral);
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid var(--border-neutral);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== Phone Numbers Page ===== */
.phone-numbers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 16px;
}
.phone-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.phone-info .info-row {
    display: flex;
    gap: 8px;
    font-size: 13px;
    padding: 4px 0;
}
.info-label { color: var(--text-muted); min-width: 140px; }
.info-value { color: var(--text-primary); font-weight: 500; }
.assignment-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}
.assignment-info { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.badge-info { background: var(--info-bg); color: var(--info); }
