:root{--sidebar:#0f172a;--sidebar2:#111827;--primary:#2563eb;--muted:#64748b;--bg:#f6f8fb;--card:#fff;--border:#e5e7eb}
*{box-sizing:border-box} body{background:var(--bg);font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#0f172a}.app-shell{min-height:100vh}.sidebar{position:fixed;inset:0 auto 0 0;width:280px;background:linear-gradient(180deg,var(--sidebar),var(--sidebar2));color:white;padding:24px;z-index:1040;transition:.25s}.brand-box{display:flex;gap:12px;align-items:center}.brand-icon{width:46px;height:46px;border-radius:14px;background:#fff;color:var(--primary);display:grid;place-items:center;font-size:24px;font-weight:800}.brand-title{font-weight:800;font-size:20px}.brand-box small{color:#cbd5e1}.sidebar .nav-link{color:#cbd5e1;border-radius:14px;padding:12px 14px;margin:3px 0;font-weight:600}.sidebar .nav-link:hover,.sidebar .nav-link.active{background:rgba(255,255,255,.1);color:white}.sidebar .nav-link i{margin-right:10px}.sidebar .nav-link.disabled{opacity:.45}.topbar{margin-left:280px;height:76px;background:#fff;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:14px;padding:0 28px;position:sticky;top:0;z-index:1000}.main-content{margin-left:280px;padding:28px}.btn-white{background:#fff;border:1px solid var(--border)}.user-chip{display:flex;align-items:center;gap:8px}.avatar{width:32px;height:32px;border-radius:50%;background:#dbeafe;color:#1d4ed8;display:inline-grid;place-items:center;font-weight:700}.stat-card{background:#fff;border:1px solid var(--border);border-radius:22px;padding:22px;box-shadow:0 10px 30px rgba(15,23,42,.04);height:100%}.stat-icon{width:48px;height:48px;border-radius:16px;background:#eff6ff;color:#2563eb;display:grid;place-items:center;font-size:22px}.stat-value{font-size:28px;font-weight:800;margin:12px 0 2px}.soft-card{background:#fff;border:1px solid var(--border);border-radius:22px;padding:24px;box-shadow:0 10px 30px rgba(15,23,42,.04)}.auth-bg{min-height:100vh;background:radial-gradient(circle at top left,#dbeafe,transparent 30%),linear-gradient(135deg,#f8fafc,#eef2ff);display:grid;place-items:center;padding:20px}.auth-card{width:100%;max-width:460px;background:#fff;border:1px solid var(--border);border-radius:26px;box-shadow:0 24px 70px rgba(15,23,42,.12);padding:32px}.form-control,.form-select{border-radius:12px;padding:12px}.btn{border-radius:12px;padding:10px 16px;font-weight:700}.landing-hero{min-height:100vh;background:linear-gradient(135deg,#0f172a,#1e3a8a);color:white;display:flex;align-items:center}.landing-card{background:rgba(255,255,255,.08);backdrop-filter:blur(12px);border:1px solid rgba(255,255,255,.14);border-radius:26px;padding:24px}@media(max-width:991px){.sidebar{transform:translateX(-100%)}.sidebar.show{transform:translateX(0)}.topbar,.main-content{margin-left:0}.main-content{padding:18px}.topbar{padding:0 16px}.auth-card{padding:24px}}
.module-toolbar{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap}.table thead th{font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:#64748b;background:#f8fafc}.badge-soft{background:#eff6ff;color:#1d4ed8;border:1px solid #bfdbfe}.empty-state{padding:48px 20px;text-align:center;color:#64748b}.empty-state i{font-size:46px;color:#94a3b8}.form-hint{font-size:12px;color:#64748b}.template-preview{background:#f8fafc;border:1px solid var(--border);border-radius:16px;padding:16px;white-space:pre-wrap}.action-btns{display:flex;gap:6px;flex-wrap:wrap}.modal-content{border-radius:22px;border:1px solid var(--border)}


/* =========================================================
   CACRM FULL RESPONSIVE LAYOUT FIX V2
   Fixes: page overflow, dashboard cards, tables, sidebar scroll,
   mobile overlay, content width, and zoom-out issue.
   ========================================================= */

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

html,
body {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    min-width: 0 !important;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

.app-shell,
.dashboard-wrapper,
.page-wrapper {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    max-width: 250px;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
}

.sidebar .brand-box {
    flex: 0 0 auto;
    padding: 22px 20px 14px;
    min-height: 126px;
}

.sidebar .nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 14px 24px;
    margin-top: 0 !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.35) transparent;
}

.sidebar .nav::-webkit-scrollbar {
    width: 7px;
}

.sidebar .nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar .nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.28);
    border-radius: 999px;
}

.sidebar .nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.45);
}

.sidebar .nav-link {
    display: flex !important;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-height: 1.25;
}

.sidebar .nav-link i {
    flex: 0 0 18px;
    width: 18px;
    text-align: center;
    margin-right: 0 !important;
}

/* Content layout */
.topbar,
.main-content {
    margin-left: 250px;
    width: calc(100% - 250px);
    max-width: calc(100% - 250px);
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    overflow: hidden;
}

.topbar,
.topbar > div,
.topbar .d-flex,
.topbar .ms-auto {
    min-width: 0;
}

.topbar h1,
.topbar h2,
.topbar h3,
.topbar h4,
.topbar h5,
.topbar small,
.topbar span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-content {
    padding: 24px;
    overflow-x: hidden;
}

/* Bootstrap row and columns should never force page overflow */
.row {
    min-width: 0;
}

[class*="col-"] {
    min-width: 0;
}

/* Dashboard/stat cards */
.stat-card,
.soft-card,
.card,
.module-card {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.stat-card {
    height: 100%;
}

.stat-value {
    overflow-wrap: anywhere;
}

/* Tables should scroll inside their card, not force the whole page */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    max-width: 100%;
}

.table td,
.table th {
    white-space: normal;
    overflow-wrap: anywhere;
}

.table .btn,
.table .badge {
    white-space: nowrap;
}

/* Forms */
.form-control,
.form-select,
textarea,
input {
    max-width: 100%;
}

/* Toolbars */
.module-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    min-width: 0;
}

.module-toolbar > * {
    min-width: 0;
}

.module-toolbar h1,
.module-toolbar h2,
.module-toolbar h3,
.module-toolbar h4,
.module-toolbar h5,
.module-toolbar p {
    overflow-wrap: anywhere;
}

/* Buttons wrap nicely */
.btn {
    max-width: 100%;
    white-space: normal;
}

/* Desktop dashboard cards: allow wrap */
.dashboard-cards,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 18px;
    width: 100%;
}

/* Prevent dashboard cards from creating horizontal page scroll */
.main-content > .row,
.main-content .row {
    margin-left: calc(var(--bs-gutter-x, 1.5rem) * -.5);
    margin-right: calc(var(--bs-gutter-x, 1.5rem) * -.5);
}

/* Sidebar backdrop */
.sidebar-backdrop {
    display: none;
}

/* Medium screens */
@media (max-width: 1199px) {
    .main-content {
        padding: 20px;
    }

    .stat-card {
        padding: 18px !important;
    }
}

/* Tablet and mobile */
@media (max-width: 991px) {
    .sidebar {
        width: min(86vw, 310px);
        max-width: min(86vw, 310px);
        transform: translateX(-105%);
        transition: transform .25s ease;
        box-shadow: 18px 0 40px rgba(15, 23, 42, .28);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .topbar,
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .main-content {
        padding: 18px;
        padding-bottom: 90px;
    }

    .topbar {
        min-height: 66px;
        height: auto;
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .52);
        z-index: 1035;
        opacity: 0;
        visibility: hidden;
        display: block;
        transition: .25s ease;
    }

    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

/* Small mobile */
@media (max-width: 575px) {
    .sidebar {
        width: min(92vw, 320px);
        max-width: min(92vw, 320px);
    }

    .sidebar .brand-box {
        min-height: auto;
        padding: 18px 16px 12px;
    }

    .sidebar .nav {
        padding: 0 12px 22px;
    }

    .sidebar .nav-link {
        padding: 11px 12px !important;
        font-size: 14px;
    }

    .topbar {
        padding: 10px 12px !important;
        gap: 10px;
    }

    .topbar h5 {
        font-size: 15px;
        max-width: 52vw;
    }

    .topbar small {
        display: none;
    }

    .main-content {
        padding: 14px;
    }

    .module-toolbar {
        align-items: flex-start;
    }

    .module-toolbar .btn {
        width: 100%;
    }

    .stat-card,
    .soft-card,
    .card {
        border-radius: 14px !important;
    }

    .table td,
    .table th {
        font-size: 13px;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .main-content {
        padding: 10px;
    }

    .topbar h5 {
        max-width: 45vw;
    }
}
