:root {
    --bg-canvas: #f4f6f9;
    --bg-surface: #ffffff;
    --bg-subtle: #f8fafc;
    --border: #e6ebf2;
    --border-strong: #d5dde8;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --primary: #1a73e8;
    --primary-hover: #1557b0;
    --primary-soft: rgba(26, 115, 232, 0.10);
    --blue: #1e88e5;
    --pink: #e91e63;
    --amber: #fb8c00;
    --green: #10b981;
    --red: #ef4444;
    --purple: #7c3aed;
    --sidebar-width: 256px;
    --topbar-height: 62px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 4px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.07);
}

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

body {
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-canvas);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.55;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

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

button, input, select, textarea {
    font-family: inherit;
    font-size: 13.5px;
}

/* ============ AUTH SCREEN ============ */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #eef4ff 0%, #f4f6f9 50%, #fdf2f8 100%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 32px;
}

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

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1a73e8, #00bcd4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    box-shadow: 0 4px 10px rgba(26, 115, 232, 0.25);
}

.brand-title {
    font-size: 19px;
    font-weight: 800;
    color: #0f172a;
}

.brand-sub {
    font-size: 11.5px;
    color: var(--text-muted);
}

.auth-tabs {
    display: flex;
    gap: 8px;
    background: var(--bg-canvas);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-muted);
}

.auth-tab.active {
    background: var(--bg-surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* ============ APP SHELL (MANYBOT LAYOUT) ============ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 40;
    transition: transform 0.22s ease;
}

.sidebar-brand {
    height: var(--topbar-height);
    padding: 0 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 24px;
}

.nav-section-label {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: var(--text-light);
    text-transform: uppercase;
    padding: 14px 12px 6px;
}

.nav-item {
    width: 100%;
    border: none;
    background: transparent;
    color: #475569;
    padding: 9px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 11px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
    transition: background 0.15s, color 0.15s;
    text-align: start;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-subtle);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
}

.nav-ico {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.main-area {
    flex: 1;
    margin-inline-start: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin 0.22s ease;
}

body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}
html[dir="rtl"] body.sidebar-collapsed .sidebar {
    transform: translateX(100%);
}
body.sidebar-collapsed .main-area {
    margin-inline-start: 0;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
    gap: 12px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.icon-btn:hover {
    background: var(--bg-canvas);
    color: var(--text-main);
}

.topbar-page-title {
    font-weight: 700;
    font-size: 15px;
    color: #0f172a;
}

.user-pill-wrap {
    position: relative;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    cursor: pointer;
    font-weight: 600;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    min-width: 210px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 60;
}

.dropdown-item {
    width: 100%;
    border: none;
    background: transparent;
    padding: 8px 12px;
    border-radius: 6px;
    text-align: start;
    cursor: pointer;
    color: var(--text-main);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item:hover {
    background: var(--bg-canvas);
}

.content-body {
    padding: 22px;
    max-width: 1480px;
    width: 100%;
    margin: 0 auto;
}

/* ============ MANYBOT TOP 3 KPI SUMMARY CARDS ============ */
.manybot-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

.manybot-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
}

.manybot-substats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    text-align: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 14px;
    gap: 8px;
}

.substat-val {
    font-size: 18px;
    font-weight: 800;
    display: block;
    line-height: 1.2;
}

.substat-lbl {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.c-blue { color: var(--blue); }
.c-red { color: var(--red); }
.c-green { color: var(--green); }
.c-pink { color: var(--pink); }
.c-amber { color: var(--amber); }
.c-purple { color: var(--purple); }

.manybot-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.manybot-card-foot-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.manybot-badge-box {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.box-blue { background: linear-gradient(135deg, #2196f3, #1976d2); box-shadow: 0 4px 12px rgba(33, 150, 243, 0.25); }
.box-pink { background: linear-gradient(135deg, #f06292, #e91e63); box-shadow: 0 4px 12px rgba(233, 30, 99, 0.25); }
.box-amber { background: linear-gradient(135deg, #ffa726, #fb8c00); box-shadow: 0 4px 12px rgba(251, 140, 0, 0.25); }
.box-green { background: linear-gradient(135deg, #34d399, #10b981); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25); }

.manybot-main-title {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 700;
}

.manybot-main-val {
    font-size: 22px;
    font-weight: 800;
    color: #0f172a;
}

/* ============ CHART CARD ============ */
.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px 22px;
    margin-bottom: 20px;
}

.chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.chart-title {
    font-size: 15px;
    font-weight: 800;
    color: #1e88e5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-pill {
    width: 18px;
    height: 8px;
    border-radius: 3px;
    display: inline-block;
}

.chart-body-grid {
    display: grid;
    grid-template-columns: 1fr 190px;
    gap: 20px;
    align-items: center;
}

.chart-svg-wrap {
    width: 100%;
    overflow-x: auto;
}

.chart-side-stats {
    display: flex;
    flex-direction: column;
    gap: 18px;
    text-align: center;
    border-inline-start: 1px solid #f1f5f9;
    padding-inline-start: 14px;
}

.side-stat-num {
    font-size: 20px;
    font-weight: 800;
}

.side-stat-lbl {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ============ GENERIC CARDS, PANELS & FORMS ============ */
.panel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 18px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.panel-title {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

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

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
}

.input, .select, .textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    background: #fff;
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

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

.textarea {
    min-height: 100px;
    resize: vertical;
}

.btn {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 8px 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

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

.btn-success {
    background: var(--green);
    color: #fff;
}
.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-danger {
    background: var(--red);
    color: #fff;
}
.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-amber {
    background: var(--amber);
    color: #fff;
}

.btn-outline {
    background: #fff;
    border-color: var(--border-strong);
    color: var(--text-main);
}
.btn-outline:hover:not(:disabled) {
    background: var(--bg-subtle);
    border-color: var(--primary);
    color: var(--primary);
}

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

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.badge-blue { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-green { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge-amber { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-red { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.badge-pink { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
.badge-purple { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }

/* ============ TABLES & LISTS ============ */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-weight: 700;
    text-align: start;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 11px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.table tr:hover td {
    background: #fafcff;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
    gap: 12px;
}

.page-tile {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #fff;
}

.page-tile.selected {
    border-color: var(--primary);
    background: #f0f7ff;
}

.page-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #e2e8f0;
    flex-shrink: 0;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.pill-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.pill-btn {
    border: 1px solid var(--border-strong);
    background: #fff;
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.pill-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.scroll-box {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #fafcff;
}

/* ============ MODALS & TOAST ============ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 80;
}

.modal-box {
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    padding: 22px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.toast {
    position: fixed;
    bottom: 22px;
    inset-inline-end: 22px;
    background: #0f172a;
    color: #fff;
    padding: 11px 18px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13px;
    box-shadow: var(--shadow-md);
    z-index: 100;
    max-width: 400px;
}

.var-chip {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
}

.var-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.progress-track {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1a73e8, #10b981);
    transition: width 0.25s;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1080px) {
    .manybot-kpi-grid {
        grid-template-columns: 1fr;
    }
    .chart-body-grid {
        grid-template-columns: 1fr;
    }
    .chart-side-stats {
        flex-direction: row;
        justify-content: space-around;
        border-inline-start: none;
        border-top: 1px solid #f1f5f9;
        padding-inline-start: 0;
        padding-top: 12px;
    }
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .sidebar {
        transform: translateX(-100%);
    }
    html[dir="rtl"] .sidebar {
        transform: translateX(100%);
    }
    body.sidebar-open-mobile .sidebar {
        transform: translateX(0) !important;
    }
    .main-area {
        margin-inline-start: 0 !important;
    }
}
