/* ============================================================
   MECC Trust CRM - crm-styles.css
   Fully Responsive | All Screen Sizes
   ============================================================ */

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

/* ---- Design Tokens ---- */
:root {
    --primary:         #091A7A;
    --primary-light:   #182B99;
    --primary-dark:    #05104D;
    --primary-soft:    rgba(9,26,122,0.10);
    --secondary:       #1E293B;
    --success:         #10B981;
    --success-soft:    rgba(16,185,129,0.12);
    --warning:         #F59E0B;
    --warning-soft:    rgba(245,158,11,0.12);
    --danger:          #EF4444;
    --danger-soft:     rgba(239,68,68,0.12);
    --info:            #06B6D4;
    --info-soft:       rgba(6,182,212,0.12);
    --purple:          #8B5CF6;
    --purple-soft:     rgba(139,92,246,0.12);

    --bg-body:         #F1F5F9;
    --bg-card:         #FFFFFF;
    --bg-sidebar:      #0F172A;
    --border-color:    #E2E8F0;

    --text-primary:    #0F172A;
    --text-secondary:  #64748B;
    --text-muted:      #94A3B8;

    --radius:          12px;
    --radius-sm:       8px;
    --radius-lg:       16px;
    --radius-xl:       24px;

    --shadow-sm:       0 1px 3px rgba(0,0,0,0.06);
    --shadow:          0 4px 16px rgba(0,0,0,0.08);
    --shadow-md:       0 8px 32px rgba(0,0,0,0.10);
    --shadow-lg:       0 16px 48px rgba(0,0,0,0.14);
    --shadow-primary:  0 8px 24px rgba(9,26,122,0.28);
    --shadow-success:  0 8px 24px rgba(16,185,129,0.28);
    --shadow-danger:   0 8px 24px rgba(239,68,68,0.28);

    --sidebar-w:       260px;
    --sidebar-coll:    72px;
    --navbar-h:        64px;
    --ease:            all 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ============================================================ BASE */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.3; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

/* ============================================================ LAYOUT */
.crm-wrapper { display: block; min-height: 100vh; position: relative; }

/* ============================================================ SIDEBAR */
.crm-sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sidebar);
    position: fixed;
    top: 0; left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width 0.28s cubic-bezier(0.4,0,0.2,1), transform 0.28s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
}
.crm-sidebar.collapsed { width: var(--sidebar-coll); }

/* Logo */
.sidebar-logo {
    display: flex; align-items: center; gap: 12px;
    padding: 0 18px;
    height: var(--navbar-h);
    min-height: var(--navbar-h);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    text-decoration: none;
    overflow: hidden; white-space: nowrap; flex-shrink: 0;
}
.sidebar-logo-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #fff);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(9,26,122,0.4);
}
.sidebar-logo-text { opacity: 1; transition: opacity 0.2s; overflow: hidden; }
.brand-name  { display: block; font-size: 15px; font-weight: 700; color: #fff; }
.brand-sub   { display: block; font-size: 10px; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 1px; }
.crm-sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

/* Nav */
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
.sidebar-section-label {
    display: block; font-size: 10px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: rgba(255,255,255,0.3);
    padding: 14px 20px 5px; white-space: nowrap; overflow: hidden;
    transition: opacity 0.2s;
}
.crm-sidebar.collapsed .sidebar-section-label { opacity: 0; }
.sidebar-nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; margin: 2px 8px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.58);
    text-decoration: none; white-space: nowrap; overflow: hidden;
    transition: var(--ease); cursor: pointer;
}
.sidebar-nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; text-decoration: none; }
.sidebar-nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 4px 14px rgba(9,26,122,0.4);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-text  { font-size: 13.5px; font-weight: 500; transition: opacity 0.2s; }
.nav-badge {
    margin-left: auto; background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700; padding: 2px 6px;
    border-radius: 20px; flex-shrink: 0;
}
.crm-sidebar.collapsed .nav-text,
.crm-sidebar.collapsed .nav-badge { opacity: 0; width: 0; overflow: hidden; }
.crm-sidebar.collapsed .sidebar-nav-item { justify-content: center; padding: 12px 0; margin: 2px 8px; }

/* Sidebar Footer */
.sidebar-footer { padding: 10px 8px; border-top: 1px solid rgba(255,255,255,0.07); flex-shrink: 0; }
.sidebar-footer-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 8px; border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.5); text-decoration: none;
    white-space: nowrap; overflow: hidden;
    transition: var(--ease); cursor: pointer;
}
.sidebar-footer-item:hover { background: rgba(255,255,255,0.07); color: #fff; text-decoration: none; }
.crm-sidebar.collapsed .sidebar-footer-item { justify-content: center; }

/* ============================================================ NAVBAR */
.crm-navbar {
    position: fixed; top: 0; z-index: 1030;
    left: var(--sidebar-w); right: 0;
    height: var(--navbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center;
    padding: 0 20px; gap: 10px;
    box-shadow: var(--shadow-sm);
    transition: left 0.28s cubic-bezier(0.4,0,0.2,1);
}
.crm-sidebar.collapsed ~ .crm-main .crm-navbar { left: var(--sidebar-coll); }

.navbar-toggle-btn {
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 18px; cursor: pointer;
    width: 38px; height: 38px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    transition: var(--ease); flex-shrink: 0;
}
.navbar-toggle-btn:hover { background: var(--primary-soft); color: var(--primary); }

.navbar-search {
    flex: 1; max-width: 340px;
    position: relative;
}
.navbar-search input {
    width: 100%; border: 1.5px solid var(--border-color);
    border-radius: 9px; padding: 8px 14px 8px 36px;
    font-size: 13.5px; font-family: inherit;
    color: var(--text-primary); background: var(--bg-body);
    transition: var(--ease);
}
.navbar-search input:focus {
    outline: none; border-color: var(--primary);
    background: #fff; box-shadow: 0 0 0 3px var(--primary-soft);
}
.navbar-search input::placeholder { color: var(--text-muted); }
.navbar-search .search-icon {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted); font-size: 13px; pointer-events: none;
}
.navbar-spacer { flex: 1; }
.navbar-actions { display: flex; align-items: center; gap: 6px; }

.navbar-icon-btn {
    position: relative; width: 38px; height: 38px;
    border-radius: 9px;
    background: var(--bg-body); border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; cursor: pointer; text-decoration: none;
    transition: var(--ease);
}
.navbar-icon-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.badge-dot {
    position: absolute; top: 7px; right: 7px;
    width: 7px; height: 7px;
    background: var(--danger); border-radius: 50%;
    border: 2px solid #fff;
}

/* Profile button */
.navbar-profile {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 9px; border: 1.5px solid var(--border-color);
    background: #fff; cursor: pointer; text-decoration: none;
    transition: var(--ease);
}
.navbar-profile:hover { border-color: var(--primary); background: var(--primary-soft); text-decoration: none; }
.profile-avatar {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff; font-size: 13px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    object-fit: cover; flex-shrink: 0;
    overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-info { display: flex; flex-direction: column; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.profile-role { font-size: 11px; color: var(--text-muted); }
.profile-caret { font-size: 11px; color: var(--text-muted); }

/* ============================================================ MAIN */
.crm-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-left 0.28s cubic-bezier(0.4,0,0.2,1);
}
.crm-sidebar.collapsed ~ .crm-main { margin-left: var(--sidebar-coll); }
.crm-content {
    padding: calc(var(--navbar-h) + 24px) 24px 32px;
    flex: 1;
}

/* Breadcrumb */
.crm-breadcrumb { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.breadcrumb-link { color: var(--text-muted); font-size: 13px; }
.breadcrumb-link:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--text-muted); font-size: 11px; }
.breadcrumb-current { color: var(--text-primary); font-size: 13px; font-weight: 500; }

/* Page Header */
.page-header {
    display: flex; align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title  { font-size: 22px; font-weight: 800; margin: 0; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ============================================================ CARDS */
.crm-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--ease); overflow: hidden;
}
.crm-card:hover { box-shadow: var(--shadow); }
.crm-card .card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}
.crm-card .card-title { font-size: 14px; font-weight: 600; margin: 0; }
.crm-card .card-body  { padding: 20px; }

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    display: flex; align-items: flex-start; gap: 14px;
    transition: var(--ease); position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card.primary::before { background: linear-gradient(90deg, #091A7A, #182B99); }
.stat-card.success::before { background: linear-gradient(90deg, #10B981, #34D399); }
.stat-card.warning::before { background: linear-gradient(90deg, #F59E0B, #FCD34D); }
.stat-card.danger::before  { background: linear-gradient(90deg, #EF4444, #F87171); }
.stat-card.purple::before  { background: linear-gradient(90deg, #8B5CF6, #A78BFA); }
.stat-icon {
    width: 50px; height: 50px; flex-shrink: 0;
    border-radius: var(--radius); font-size: 20px;
    display: flex; align-items: center; justify-content: center;
}
.stat-icon.primary { background: var(--primary-soft); color: var(--primary); }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-soft);  color: var(--danger); }
.stat-icon.purple  { background: var(--purple-soft);  color: var(--purple); }
.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1; margin-bottom: 8px; color: var(--text-primary); }
.stat-change {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
}
.stat-change.up   { color: var(--success); background: var(--success-soft); }
.stat-change.down { color: var(--danger);  background: var(--danger-soft); }

/* ============================================================ BUTTONS */
.btn { border-radius: var(--radius-sm); font-family: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: var(--ease); padding: 7px 16px; font-size: 13.5px !important; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none; color: #fff;
    box-shadow: 0 4px 14px rgba(9,26,122,0.35);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    box-shadow: 0 6px 20px rgba(9,26,122,0.45);
    transform: translateY(-1px); color: #fff;
}
.btn-success { background: linear-gradient(135deg, #059669, var(--success)); border: none; color: #fff; }
.btn-success:hover { transform: translateY(-1px); color: #fff; }
.btn-icon {
    width: 34px; height: 34px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: 14px;
}

/* ============================================================ TABLE */
.crm-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.crm-table thead th {
    background: var(--bg-body); color: var(--text-secondary);
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
    padding: 12px 16px; border-bottom: 2px solid var(--border-color); white-space: nowrap;
}
.crm-table tbody tr { transition: background 0.15s; }
.crm-table tbody tr:hover { background: var(--bg-body); }
.crm-table tbody td {
    padding: 13px 16px; border-bottom: 1px solid var(--border-color);
    color: var(--text-primary); vertical-align: middle; font-size: 13.5px;
}
.crm-table tbody tr:last-child td { border-bottom: none; }

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1.5px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 7px 12px; font-size: 13px; font-family: inherit; color: var(--text-primary);
}
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 8px !important; padding: 6px 12px !important; font-size: 13px !important; font-family: inherit !important; margin: 0 2px !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-light)) !important;
    border-color: var(--primary) !important; color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-soft) !important; border-color: var(--primary) !important; color: var(--primary) !important;
}
.dataTables_wrapper .dataTables_info { font-size: 13px; color: var(--text-muted); }

/* ============================================================ BADGES */
.status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; line-height: 1.4;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.status-badge.active   { color: var(--success); background: var(--success-soft); }
.status-badge.active::before { background: var(--success); }
.status-badge.inactive { color: var(--danger);  background: var(--danger-soft); }
.status-badge.inactive::before { background: var(--danger); }
.status-badge.pending  { color: var(--warning); background: var(--warning-soft); }
.status-badge.pending::before { background: var(--warning); }
.status-badge.info-bd  { color: var(--info);    background: var(--info-soft); }
.status-badge.info-bd::before { background: var(--info); }
.role-badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 6px; font-size: 11px; font-weight: 600;
    background: var(--primary-soft); color: var(--primary);
}

/* ============================================================ FORMS */
.form-control, .form-select {
    border: 1.5px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 10px 14px; font-size: 13.5px; font-family: inherit;
    color: var(--text-primary); transition: var(--ease); background: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: none;
}
.form-control::placeholder { color: var(--text-muted); }
.form-floating > .form-control,
.form-floating > .form-select {
    border: 1.5px solid var(--border-color); border-radius: var(--radius-sm); font-size: 13.5px; font-family: inherit;
}
.form-floating > .form-control:focus,
.form-floating > .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-floating > label { color: var(--text-muted); font-size: 13.5px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-check-input[type=checkbox].status-toggle { width: 38px; height: 20px; border-radius: 20px; cursor: pointer; }
.form-check-input[type=checkbox].status-toggle:checked { background-color: var(--success); border-color: var(--success); }

/* ============================================================ AVATAR */
.user-avatar {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff; font-size: 14px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    object-fit: cover; overflow: hidden;
}
.user-avatar.sm  { width: 28px; height: 28px; font-size: 11px; border-radius: 7px; }
.user-avatar.lg  { width: 48px; height: 48px; font-size: 18px; border-radius: 12px; }
.user-avatar.xl  { width: 80px; height: 80px; font-size: 28px; border-radius: 18px; }
.user-avatar.xxl { width: 110px; height: 110px; font-size: 40px; border-radius: 24px; }

/* ============================================================ FILTER BAR */
.filter-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 18px; background: var(--bg-card);
    border-radius: var(--radius); border: 1px solid var(--border-color);
    margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.filter-search { position: relative; flex: 1; min-width: 180px; }
.filter-search input {
    width: 100%; padding: 9px 14px 9px 36px;
    border: 1.5px solid var(--border-color); border-radius: var(--radius-sm);
    font-size: 13.5px; font-family: inherit; color: var(--text-primary);
    transition: var(--ease); background: #fff;
}
.filter-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.filter-search input::placeholder { color: var(--text-muted); }
.filter-search .search-icon {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%); color: var(--text-muted); font-size: 13px;
}

/* ============================================================ MODAL */
.modal-content { border: none; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header  { border-bottom: 1px solid var(--border-color); padding: 18px 22px; }
.modal-title   { font-size: 16px; font-weight: 700; }
.modal-body    { padding: 22px; }
.modal-footer  { border-top: 1px solid var(--border-color); padding: 14px 22px; }

/* ============================================================ DROPDOWN */
.dropdown-menu { border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 6px; font-family: inherit; }
.dropdown-item { border-radius: var(--radius-sm); font-size: 13.5px; padding: 8px 12px; display: flex; align-items: center; gap: 8px; color: var(--text-primary); transition: background 0.15s; }
.dropdown-item:hover { background: var(--primary-soft); color: var(--primary); }
.dropdown-item.text-danger:hover { background: var(--danger-soft); color: var(--danger); }
.dropdown-divider { border-color: var(--border-color); margin: 4px 0; }

/* ============================================================ NOTIFICATION */
.notification-dropdown { width: 320px; padding: 0; max-height: 400px; overflow-y: auto; }
.notification-header {
    padding: 12px 16px; border-bottom: 1px solid var(--border-color);
    font-weight: 600; font-size: 14px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; background: #fff;
}
.notification-item {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 11px 14px; border-bottom: 1px solid var(--border-color);
    cursor: pointer; transition: background 0.15s; position: relative;
}
.notification-item:hover { background: var(--bg-body); }
.notification-item.unread { background: rgba(9,26,122,0.03); }
.notification-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.notification-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.notification-desc  { font-size: 12px; color: var(--text-secondary); }
.notification-time  { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ============================================================ TIMELINE */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 0; bottom: 0; width: 2px; background: var(--border-color); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before {
    content: ''; position: absolute; left: -22px; top: 5px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary);
}
.timeline-item.success::before { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-item.warning::before { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-item.danger::before  { background: var(--danger);  box-shadow: 0 0 0 2px var(--danger); }
.timeline-date  { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-bottom: 3px; }
.timeline-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.timeline-desc  { font-size: 13px; color: var(--text-secondary); }

/* ============================================================ PROGRESS */
.crm-progress { height: 6px; border-radius: 10px; background: var(--border-color); overflow: hidden; }
.crm-progress-bar { height: 100%; border-radius: 10px; transition: width 1s ease; }

/* ============================================================ SKELETON */
.skeleton {
    background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: 6px; display: block;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================ ANIMATIONS */
@keyframes fadeInUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
.animate-fade-up  { animation: fadeInUp 0.4s ease both; }
.animate-fade-in  { animation: fadeIn  0.3s ease both; }
.delay-1 { animation-delay: 0.06s; }
.delay-2 { animation-delay: 0.12s; }
.delay-3 { animation-delay: 0.18s; }
.delay-4 { animation-delay: 0.24s; }

/* ============================================================ SCROLL-TOP */
.scroll-top-btn {
    position: fixed; bottom: 24px; right: 24px;
    width: 42px; height: 42px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; cursor: pointer;
    box-shadow: var(--shadow-primary);
    transition: var(--ease); opacity: 0; pointer-events: none; z-index: 999;
}
.scroll-top-btn.show { opacity: 1; pointer-events: all; }
.scroll-top-btn:hover { transform: translateY(-3px); }

/* ============================================================ SIDEBAR OVERLAY */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ============================================================ LOGIN PAGE */
.auth-page {
    min-height: 100vh; display: flex;
    background: var(--bg-body); overflow: hidden;
}
.auth-brand {
    width: 44%; min-height: 100vh;
    background: linear-gradient(145deg, #0F172A 0%, #1E3A8A 55%, #05104D 100%);
    padding: 50px; display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
.auth-brand::before {
    content: ''; position: absolute; top: -100px; right: -100px;
    width: 380px; height: 380px; border-radius: 50%;
    background: rgba(9,26,122,0.18);
}
.auth-brand::after {
    content: ''; position: absolute; bottom: -80px; left: -60px;
    width: 300px; height: 300px; border-radius: 50%;
    background: rgba(139,92,246,0.13);
}
.auth-brand-content { position: relative; z-index: 1; }
.auth-brand-logo {
    width: 54px; height: 54px;
    background: #fff;
    border-radius: 14px; border: 1px solid rgba(255,255,255,0.14);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: #fff; margin-bottom: 28px;
}
.auth-brand-title { font-size: 30px; font-weight: 800; color: #fff; line-height: 1.2; margin-bottom: 14px; }
.auth-brand-desc  { font-size: 14px; color: rgba(255,255,255,0.62); line-height: 1.7; margin-bottom: 36px; }
.auth-brand-list  { list-style: none; }
.auth-brand-list li {
    display: flex; align-items: center; gap: 12px;
    color: rgba(255,255,255,0.75); font-size: 14px; font-weight: 500; padding: 7px 0;
}
.auth-brand-list li .li-icon {
    width: 28px; height: 28px; border-radius: 8px;
    background: rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: #60A5FA; flex-shrink: 0;
}
.auth-form-side {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 40px; overflow-y: auto;
}
.auth-card {
    width: 100%; max-width: 420px;
    background: rgba(255,255,255,0.97);
    border-radius: var(--radius-xl); padding: 38px 36px;
    box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,0.8);
}
.auth-card-logo {
    width: 50px; height: 50px; margin: 0 auto 16px;
    background: linear-gradient(135deg, #fff);
    border-radius: 14px; display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: #fff; box-shadow: 0 8px 24px rgba(9,26,122,0.35);
}
.auth-card-title { font-size: 22px; font-weight: 800; color: var(--text-primary); text-align: center; margin-bottom: 5px; }
.auth-card-sub   { font-size: 13.5px; color: var(--text-muted); text-align: center; margin-bottom: 26px; }

/* ============================================================ PROFILE */
.profile-avatar-wrap { position: relative; display: inline-block; }
.avatar-upload-btn {
    position: absolute; bottom: -5px; right: -5px;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; cursor: pointer; border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
}

/* ============================================================ IMG UPLOAD */
.img-upload-box {
    width: 100px; height: 100px; border-radius: var(--radius);
    border: 2px dashed var(--border-color); background: var(--bg-body);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted); font-size: 26px;
    overflow: hidden; transition: var(--ease);
}
.img-upload-box:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ============================================================ CLIENT CARDS */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(275px,1fr)); gap: 16px; }
.client-card-item {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1.5px solid var(--border-color); padding: 20px;
    transition: var(--ease); position: relative; overflow: hidden;
}
.client-card-item::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}
.client-card-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.client-card-actions { position: absolute; top: 12px; right: 12px; opacity: 0; transition: opacity 0.2s; }
.client-card-item:hover .client-card-actions { opacity: 1; }

/* View toggle */
.view-btn {
    width: 36px; height: 36px; border-radius: 8px;
    border: 1.5px solid var(--border-color); background: #fff;
    color: var(--text-muted); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--ease); font-size: 14px;
}
.view-btn.active, .view-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* Permission matrix */
.perm-check { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

/* ============================================================ TOASTR */
#toast-container > div {
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-md) !important;
    font-family: inherit !important;
    font-size: 13.5px !important;
}

/* ============================================================ UTILS */
.text-primary-crm { color: var(--primary) !important; }
.text-success-crm { color: var(--success) !important; }
.text-warning-crm { color: var(--warning) !important; }
.text-danger-crm  { color: var(--danger)  !important; }
.bg-primary-soft  { background: var(--primary-soft) !important; }
.bg-success-soft  { background: var(--success-soft) !important; }
.bg-warning-soft  { background: var(--warning-soft) !important; }
.bg-danger-soft   { background: var(--danger-soft)  !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.section-divider {
    display: flex; align-items: center; gap: 10px; margin: 18px 0;
}
.section-divider::before, .section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-color); }
.section-divider span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); white-space: nowrap; }

/* ============================================================ SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

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

/* Large desktop (≥1400px) */
@media (min-width: 1400px) {
    .stat-value { font-size: 30px; }
}

/* Desktop (992px – 1399px) */
@media (max-width: 1399px) {
    .stat-value { font-size: 24px; }
}

/* Tablet Landscape (768px – 991px) */
@media (max-width: 991.98px) {
    /* Sidebar becomes off-canvas on mobile */
    .crm-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        z-index: 1045;
        width: var(--sidebar-w) !important; /* always full width when open */
    }
    .crm-sidebar.mobile-show {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0,0,0,0.25);
    }
    /* Main takes full width */
    .crm-main  { margin-left: 0 !important; }
    .crm-navbar { left: 0 !important; }
    /* Hide auth brand on small screens */
    .auth-brand { display: none; }
    .auth-form-side { padding: 28px 20px; }
    .auth-card { padding: 28px 22px; }
    /* Navbar search hidden */
    .navbar-search { display: none !important; }
    .profile-info, .profile-caret { display: none !important; }
    /* Content padding reduction */
    .crm-content { padding: calc(var(--navbar-h) + 16px) 16px 24px; }
}

/* Tablet Portrait (576px – 767px) */
@media (max-width: 767.98px) {
    .page-header { flex-direction: column; align-items: stretch; }
    .page-title  { font-size: 18px; }
    .page-header .d-flex { justify-content: flex-start; }
    .stat-card   { padding: 14px; }
    .stat-icon   { width: 42px; height: 42px; font-size: 17px; }
    .stat-value  { font-size: 22px; }
    .filter-bar  { flex-direction: column; }
    .filter-search { min-width: 100%; }
    .client-grid { grid-template-columns: 1fr 1fr; }
}

/* Mobile (≤575px) */
@media (max-width: 575.98px) {
    :root { --navbar-h: 58px; }
    .crm-content { padding: calc(var(--navbar-h) + 12px) 12px 20px; }
    .crm-navbar  { padding: 0 12px; }
    .stat-card   { flex-direction: column; gap: 10px; padding: 14px; }
    .stat-icon   { width: 38px; height: 38px; font-size: 16px; }
    .stat-value  { font-size: 20px; }
    .client-grid { grid-template-columns: 1fr; }
    .auth-card   { padding: 24px 18px; border-radius: var(--radius-lg); }
    .auth-form-side { padding: 20px 14px; align-items: flex-start; padding-top: 40px; }
    .page-header .btn { font-size: 12px; padding: 6px 10px; }
    .crm-card .card-header { flex-direction: column; align-items: flex-start; }
    .modal-dialog { margin: 8px; }
    .auth-brand-title { font-size: 22px; }
    .notification-dropdown { width: calc(100vw - 24px); }
    .scroll-top-btn { bottom: 16px; right: 16px; }
}

/* Very small mobile (≤400px) */
@media (max-width: 400px) {
    .crm-table thead th { font-size: 10px; padding: 10px 10px; }
    .crm-table tbody td { padding: 10px 10px; font-size: 12.5px; }
    .btn-icon { width: 30px; height: 30px; font-size: 12px; }
}

/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox */
input[type=number] {
    -moz-appearance: textfield;
}