:root {
    --primary: #2b3a67;
    --primary-light: #3d5180;
    --accent: #0d6efd;
    --danger: #dc3545;
    --success: #198754;
    --warning: #ffc107;
    --info: #0dcaf0;
    --bg: #f5f7fa;
    --sidebar-bg: #1a233a;
    --sidebar-text: #b0bec5;
    --text: #212529;
    --border: #e0e6ed;
    --radius: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

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

/* Auth layout */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg);
}

.auth-card {
    background: #fff;
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 420px;
}

.auth-card h1 { font-size: 28px; margin-bottom: 8px; }
.auth-subtitle { color: #6c757d; margin-bottom: 24px; }

.auth-links { text-align: center; margin-top: 16px; }

/* Admin/Portal layout */
.admin-layout, .portal-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    width: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand a {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.sidebar-nav li a {
    display: block;
    padding: 10px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
}

.sidebar-nav li a:hover, .sidebar-nav li a.active {
    background: rgba(255,255,255,0.06);
    color: #fff;
    text-decoration: none;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 13px;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 4px 0;
    font-size: 13px;
}
.btn-logout:hover { color: #fff; }

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 24px;
    min-height: 100vh;
}

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

.page-header h1 { font-size: 24px; }

.project-picker { min-width: 240px; }

.page-content { }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 500; }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,110,253,0.15); }

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { width: 16px; height: 16px; }
.form-check-label { font-size: 14px; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #0b5ed7; color: #fff; text-decoration: none; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; color: #fff; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #bb2d3b; color: #fff; text-decoration: none; }
.btn-warning { background: var(--warning); color: #212529; }
.btn-warning:hover { background: #e0a800; color: #212529; text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #157347; color: #fff; text-decoration: none; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-info { background: #e8f4fd; color: #084298; border: 1px solid #b6d4fe; }
.text-danger { color: var(--danger); font-size: 13px; }
.text-center { text-align: center; }

/* Toast */
.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.toast-success { background: #d1e7dd; color: #0f5132; }
.toast-error { background: #f8d7da; color: #842029; }
.toast-warning { background: #fff3cd; color: #664d03; }
.toast-info { background: #cff4fc; color: #055160; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.stat-card h3 { font-size: 13px; text-transform: uppercase; color: #6c757d; margin-bottom: 8px; letter-spacing: 0.05em; }
.stat-value { font-size: 28px; font-weight: 700; }

/* Tables */
.data-table {
    width: 100%;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.data-table th { background: #f8f9fa; font-weight: 600; text-transform: uppercase; font-size: 12px; color: #6c757d; }

.page-actions { margin-bottom: 16px; text-align: right; }

.no-project { text-align: center; padding: 60px 20px; }
.no-project h2 { margin-bottom: 8px; }
.no-project p { color: #6c757d; margin-bottom: 20px; }

.project-details { background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.detail-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-row strong { display: inline-block; min-width: 120px; }
.detail-row code, .detail-row pre { background: #f1f3f5; padding: 4px 8px; border-radius: 4px; font-size: 13px; }

/* Layout content (unauth) */
.layout-wrapper { min-height: 100vh; }
.content { }

/* Form card */
.form-card {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    max-width: 600px;
}
.form-card h2 { margin-bottom: 20px; }
.form-card .btn { margin-right: 8px; }

/* Module toggles */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.module-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.module-card h3 { font-size: 15px; margin-bottom: 4px; }
.module-card p { font-size: 13px; color: #6c757d; margin-bottom: 0; }

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 24px;
    transition: 0.3s;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

/* Admin project tabs */
.tab-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e5ea;
    padding-bottom: 10px;
}
.tab-link {
    padding: 6px 14px;
    border-radius: var(--radius);
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    font-size: 14px;
}
.tab-link:hover { background: #eef0f4; }
.tab-link.active { background: var(--primary, #2b3a67); color: #fff; }

/* Notification bell */
.notifications { position: relative; font-size: 20px; }
.notification-bell { cursor: pointer; position: relative; }
.badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    color: #fff;
}
.badge-danger { background: var(--danger); }
.badge-warning { background: var(--warning); color: #212529; }
.badge-success { background: var(--success); }
.badge-secondary { background: #adb5bd; }

/* Embed snippet */
.embed-snippet {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 13px;
    margin-bottom: 16px;
}
.embed-snippet code { color: #e2e8f0; background: none; }

/* Settings page */
.settings-page, .modules-page, .users-page, .context-page, .chatbot-sessions, .session-transcript, .traffic-page, .leads-page, .alerts-page, .whatsapp-page, .ipblacklist-page, .marketing-page, .dashboard-page { display: flex; flex-direction: column; gap: 20px; }
.text-muted { color: #6c757d; font-size: 14px; }

/* Chat transcript */
.chat-messages { display: flex; flex-direction: column; gap: 12px; max-height: 500px; overflow-y: auto; }
.chat-message { padding: 12px 16px; border-radius: var(--radius); max-width: 80%; }
.chat-message.user { background: #e3f2fd; align-self: flex-end; }
.chat-message.assistant { background: #f1f3f5; align-self: flex-start; }
.chat-message.system { background: #fff3cd; align-self: center; }
.chat-role { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; color: #6c757d; margin-bottom: 4px; }

/* Traffic page */
.traffic-page { display: flex; flex-direction: column; gap: 20px; }
.traffic-filters { display: flex; gap: 8px; }
.traffic-filters .btn { min-width: 80px; text-align: center; }
.chart-card { background: #fff; padding: 20px; border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.chart-card h2 { font-size: 16px; margin-bottom: 16px; }
.chart-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 768px) { .chart-row { grid-template-columns: 1fr; } }