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

/* ═══════════════════════════════════════════════════════════════
   CSS VARIABLES
═══════════════════════════════════════════════════════════════ */
:root {
    --primary-color:    #2563EB;
    --primary-hover:    #1d4ed8;
    --primary-light:    #EFF6FF;
    --primary-soft:     rgba(37, 99, 235, 0.08);
    --bg-color:         #F8FAFC;
    --card-bg:          #ffffff;
    --border-color:     #E5E7EB;
    --text-dark:        #1e293b;
    --text-muted:       #64748b;
    --text-body:        #374151;
    --sidebar-width:    260px;
    --topbar-height:    64px;
    --radius-sm:        8px;
    --radius-md:        10px;
    --radius-lg:        12px;
    --shadow-sm:        0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:        0 4px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
    --shadow-lg:        0 10px 30px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
    --transition-fast:  all 0.18s ease;
    --transition-base:  all 0.25s ease;
}

/* ═══════════════════════════════════════════════════════════════
   BASE
═══════════════════════════════════════════════════════════════ */
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-body);
    overflow-x: hidden;
    font-size: 0.875rem;
    
    /* Native App Feel */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

/* Allow text selection in inputs and textareas */
input, textarea {
    -webkit-user-select: auto;
    user-select: auto;
}

/* Hide scrollbar for native app feel */
::-webkit-scrollbar {
    display: none;
}

/* ─── Bootstrap Overrides ─────────────────────────── */
.text-primary     { color: var(--primary-color)  !important; }
.bg-primary       { background-color: var(--primary-color) !important; }
.border-primary   { border-color: var(--primary-color) !important; }

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 500;
    transition: var(--transition-base);
}
.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.btn-primary:active { transform: translateY(0); }

/* ─── Page Animation ─────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in-up { animation: fadeInUp 0.45s ease-out forwards; }

/* ─── Card ────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.25s ease;
}
.card:hover { box-shadow: var(--shadow-md); }

/* ─── Form Controls ──────────────────────────────── */
.form-control,
.form-select {
    font-family: 'Poppins', sans-serif;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 0.55rem 0.875rem;
    color: var(--text-dark);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    height: 42px;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    outline: none;
}
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%232563EB' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-size: 14px 10px;
    background-position: right 0.875rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}
.form-select option { padding: 8px 12px; }
.form-control::placeholder { color: #9ca3af; }
.form-control.is-invalid,
.form-select.is-invalid { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239,68,68,0.1) !important; }
.invalid-feedback { font-size: 0.78rem; }

/* ─── Input Group ─────────────────────────────────── */
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important; }
.input-group .btn          { border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important; }

/* ═══════════════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════════════ */
.d-flex.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR — New Accordion Design
═══════════════════════════════════════════════════════════════ */
#sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    overflow: hidden;
    box-shadow: 2px 0 20px rgba(0,0,0,0.04);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

/* ─── Sidebar Menu Container (Scrollable) ────────── */
.sidebar-menu-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}
.sidebar-menu-container::-webkit-scrollbar {
    width: 4px;
}
.sidebar-menu-container::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-menu-container::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}
.sidebar-menu-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

/* ─── Sidebar Footer (Fixed) ─────────────────────── */
.sidebar-footer {
    flex-shrink: 0;
    background: var(--card-bg);
    z-index: 2;

}

/* ─── Sidebar Header ─────────────────────────────── */
.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 2;
}
.sidebar-header h4 { font-size: 1rem; font-weight: 700; white-space: nowrap; }
.sidebar-logo      { height: 30px; width: auto; object-fit: contain; margin-right: 10px; }
.sidebar-brand-icon { font-size: 1.25rem; color: var(--primary-color); margin-right: 10px; }
.sidebar-brand-text { color: var(--primary-color); transition: opacity 0.2s; }

/* ─── Sidebar Menu ───────────────────────────────── */
.sidebar-menu {
    list-style: none;
    padding: 1rem 0.75rem;
    margin: 0;
    flex: 1;
}
.sidebar-item { margin-bottom: 2px; }

/* ─── Sidebar Header Section ─────────────────────── */
.sidebar-header-section {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 1.25rem 0.875rem 0.5rem 0.875rem;
    margin-top: 0.5rem;
}

/* ─── Sidebar Link (Level 1) ─────────────────────── */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.6875rem 0.875rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    transition: all 0.3s ease;
    white-space: nowrap;
    user-select: none;
}
.sidebar-link:hover {
    background: var(--primary-soft);
    color: var(--primary-color);
    transform: translateX(3px);
}
.sidebar-item.active > .sidebar-link,
.sidebar-link.active {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    font-weight: 600;
}
.sidebar-item.active > .sidebar-link:hover { background: var(--primary-hover); transform: none; }

/* ─── Sidebar Icon ───────────────────────────────── */
.sidebar-icon {
    width: 20px;
    text-align: center;
    font-size: 0.9375rem;
    flex-shrink: 0;
}

/* ─── Sidebar Arrow (chevron) ────────────────────── */
.sidebar-arrow {
    font-size: 0.625rem;
    margin-left: auto !important;
    transition: transform 0.22s ease;
    color: inherit;
    opacity: 0.7;
    flex-shrink: 0;
}
.sidebar-has-submenu.open > .sidebar-link > .sidebar-arrow,
.sidebar-has-submenu.open > .sidebar-sublink > .sidebar-arrow {
    transform: rotate(90deg);
}

/* ─── Sidebar Submenu (Level 2) ──────────────────── */
.sidebar-submenu {
    list-style: none;
    padding: 0.25rem 0 0.25rem 0;
    margin: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}
.sidebar-submenu.show { max-height: 600px; }

/* ─── Sidebar Sublink (Level 2) ──────────────────── */
.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5625rem 0.875rem 0.5625rem 2rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 400;
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    transition: all 0.3s ease;
    white-space: nowrap;
    user-select: none;
}
.sidebar-sublink:hover { background: var(--primary-soft); color: var(--primary-color); transform: translateX(3px); }
.sidebar-sublink.active { background: var(--primary-soft); color: var(--primary-color); font-weight: 600; box-shadow: inset 3px 0 0 0 var(--primary-color); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.sidebar-sub-icon { width: 18px; text-align: center; font-size: 0.8125rem; flex-shrink: 0; }

/* ─── Sidebar Leaf Links (Level 3) ──────────────── */
.sidebar-leaf {
    padding-left: 2.75rem;
}
.sidebar-leaf-dot {
    font-size: 0.3rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.5;
}
.sidebar-leaf.active .sidebar-leaf-dot { opacity: 1; color: var(--primary-color); }
.sidebar-leaf.active { background: var(--primary-soft); color: var(--primary-color); font-weight: 600; box-shadow: inset 3px 0 0 0 var(--primary-color); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ─── Sidebar Logout ─────────────────────────────── */
.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.6875rem 0.875rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    transition: var(--transition-fast);
}
.sidebar-logout-btn:hover { background: rgba(239, 68, 68, 0.08); }

/* ─── Sidebar Collapsed State (Desktop) ───────────── */
body.sidebar-collapsed #sidebar  { width: 72px; }
body.sidebar-collapsed #content-wrapper { margin-left: 72px; }

body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .menu-text,
body.sidebar-collapsed .sidebar-arrow,
body.sidebar-collapsed .sidebar-submenu,
body.sidebar-collapsed .sidebar-header-section,
body.sidebar-collapsed .sidebar-user-profile { display: none !important; }

body.sidebar-collapsed .sidebar-link,
body.sidebar-collapsed .sidebar-sublink,
body.sidebar-collapsed .sidebar-logout-btn {
    justify-content: center;
    padding: 0.75rem;
    gap: 0;
}
body.sidebar-collapsed .sidebar-icon,
body.sidebar-collapsed .sidebar-sub-icon { width: auto; font-size: 1.125rem; margin: 0; }
body.sidebar-collapsed .sidebar-logo { margin-right: 0; }
body.sidebar-collapsed .sidebar-brand-icon { margin-right: 0; }

/* ═══════════════════════════════════════════════════════════════
   TOPBAR / NAVBAR
═══════════════════════════════════════════════════════════════ */
#content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.28s ease;
}

.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

/* ─── Sidebar Toggle Button ──────────────────────── */
.nav-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 1rem;
    flex-shrink: 0;
}
.nav-icon:hover { background: var(--primary-soft); color: var(--primary-color); }

/* ─── Topbar Avatar ──────────────────────────────── */
.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #60a5fa);
    color: #fff;
    font-weight: 700;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.topbar-avatar-lg { width: 44px; height: 44px; font-size: 1rem; }

/* ─── Topbar User Button ─────────────────────────── */
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.75rem 0.375rem 0.375rem;
    border: 1.5px solid transparent;
    border-radius: 40px;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}
.topbar-user-btn:hover { background: var(--primary-soft); border-color: var(--primary-soft); }
.topbar-user-btn::after { display: none !important; }

.topbar-user-info { line-height: 1.2; }
.topbar-user-name { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--text-dark); }
.topbar-user-role { display: block; font-size: 0.6875rem; color: var(--text-muted); }
.topbar-chevron   { font-size: 0.625rem; color: var(--text-muted); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); flex-shrink: 0; }
.topbar-user-btn[aria-expanded="true"] { background: var(--primary-soft); }
.topbar-user-btn[aria-expanded="true"] .topbar-chevron { transform: rotate(180deg); }

/* ═══════════════════════════════════════════════════════════════
   GLOBAL DROPDOWN — Shared Styles
═══════════════════════════════════════════════════════════════ */
.dropdown-menu {
    border: 1.5px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08) !important;
    padding: 0.5rem !important;
    background: var(--card-bg) !important;
    font-family: 'Poppins', sans-serif !important;
    font-size: 0.8125rem !important;
    min-width: 200px;
    animation: dropdownFade 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1055;
    border-radius: 12px !important;
}

@keyframes dropdownFade {
    0% { opacity: 0; transform: translateY(10px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    padding: 0.5625rem 0.875rem !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-body) !important;
    font-size: 0.8125rem !important;
    font-weight: 400 !important;
    cursor: pointer;
    transition: var(--transition-fast) !important;
    text-decoration: none !important;
    white-space: nowrap;
    line-height: 1.4;
}
.dropdown-item i,
.dropdown-item .fas,
.dropdown-item .far,
.dropdown-item .fab {
    width: 18px !important;
    text-align: center !important;
    font-size: 0.8125rem !important;
    flex-shrink: 0;
}
.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--primary-soft) !important;
    color: var(--primary-color) !important;
}
.dropdown-item.active,
.dropdown-item:active {
    background: var(--primary-color) !important;
    color: #fff !important;
}
.dropdown-item.text-danger:hover { background: rgba(239,68,68,0.08) !important; color: #ef4444 !important; }
.dropdown-item.text-danger:active { background: rgba(239,68,68,0.15) !important; }

.dropdown-divider { border-color: var(--border-color) !important; margin: 0.25rem 0 !important; }
.dropdown-header  { font-size: 0.6875rem !important; font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.05em !important; color: var(--text-muted) !important; padding: 0.375rem 0.875rem !important; }

/* ─── Topbar Dropdown ────────────────────────────── */
.topbar-dropdown {
    min-width: 220px !important;
    right: 0 !important;
    left: auto !important;
}
.dropdown-header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR BACKDROP
═══════════════════════════════════════════════════════════════ */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1035;
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.sidebar-backdrop.show { display: block; opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════════════════ */
.table {
    font-size: 0.875rem;
}
.table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    padding: 0.875rem 1rem;
}
.table tbody td { padding: 0.75rem 1rem; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.table tbody tr:hover > td { background: #f8fafc; }
.table tbody tr:last-child > td { border-bottom: none; }

/* ─── Table Action Buttons ───────────────────────── */
.btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: 0.75rem;
    border-radius: 6px;
    line-height: 1.4;
}
.btn-action-group { display: flex; gap: 0.25rem; justify-content: flex-end; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════════════ */
.badge { font-weight: 500; font-size: 0.6875rem; letter-spacing: 0.02em; }

/* ═══════════════════════════════════════════════════════════════
   LOADING OVERLAY
═══════════════════════════════════════════════════════════════ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════════════ */
footer {
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border-color);
}

/* ═══════════════════════════════════════════════════════════════
   AUTH PAGES
═══════════════════════════════════════════════════════════════ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-color);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}
.auth-title {
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1.75rem;
}

/* ═══════════════════════════════════════════════════════════════
   QUICK ACTION HOVER & ANIMATIONS
═══════════════════════════════════════════════════════════════ */
.custom-hover {
    transition: var(--transition-base);
    cursor: pointer;
}
.custom-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md) !important;
}

@keyframes pulse-badge {
    0% { transform: scale(1) translate(-50%, -50%); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.1) translate(-45%, -45%); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(1) translate(-50%, -50%); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.nav-notification-btn .badge {
    animation: pulse-badge 2s infinite;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile First, 4 Breakpoints
═══════════════════════════════════════════════════════════════ */

/* --- XL / TV / Smart Display (≥ 1400px) --------------------- */
@media (min-width: 1400px) {
    .container-fluid { max-width: 1600px; margin: 0 auto; }
    .page-title { font-size: 1.75rem; }
}

/* --- Tablet / Small Laptop (≤ 991px) — Offcanvas Sidebar ---- */
@media (max-width: 991.98px) {
    #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        width: var(--sidebar-width) !important;
    }
    #sidebar.mobile-toggled { margin-left: 0; }
    #content-wrapper { margin-left: 0 !important; }

    /* Reset collapsed state on mobile */
    body.sidebar-collapsed .sidebar-brand-text,
    body.sidebar-collapsed .menu-text,
    body.sidebar-collapsed .sidebar-arrow { display: inline !important; }
    body.sidebar-collapsed .sidebar-link,
    body.sidebar-collapsed .sidebar-sublink,
    body.sidebar-collapsed .sidebar-logout-btn {
        justify-content: flex-start;
        padding: 0.6875rem 0.875rem;
        gap: 0.625rem;
    }
    body.sidebar-collapsed .sidebar-icon,
    body.sidebar-collapsed .sidebar-sub-icon { width: 20px; font-size: 0.9375rem; }
    body.sidebar-collapsed .sidebar-brand-icon { margin-right: 10px; }
    body.sidebar-collapsed .sidebar-submenu { display: block !important; }

    /* Forms: max 2 columns */
    .col-md-3 { flex: 0 0 50%; max-width: 50%; }
}

/* --- Tablet Portrait (≤ 767px) ------------------------------ */
@media (max-width: 767.98px) {
    .page-title { font-size: 1.15rem; }
    .breadcrumb { font-size: 0.75rem; }

    /* Page header: stack vertically */
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    /* Card columns: 2 per row */
    .col-md-3 { flex: 0 0 50%; max-width: 50%; }

    /* Modal: full-width on tablet */
    .modal-dialog { max-width: 95%; margin: 1rem auto; }

    /* Table: ensure horizontal scroll */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 600px; }
}

/* --- Mobile (≤ 575px) --------------------------------------- */
@media (max-width: 575.98px) {
    .topbar { padding: 0 0.75rem; }
    .container-fluid { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .topbar-user-info { display: none !important; }
    .topbar-user-btn { padding: 0.25rem; border-radius: 50%; }
    .topbar-chevron { display: none; }
    .page-title { font-size: 1.05rem; }

    /* Card columns: 1 per row (full width) */
    .col-md-3, .col-sm-6 { flex: 0 0 100%; max-width: 100%; }
    .col-md-6, .col-md-4, .col-md-8 { flex: 0 0 100%; max-width: 100%; }

    /* Table responsive improvements */
    .table-responsive { border-radius: var(--radius-lg); }
    .table { font-size: 0.8rem; }
    .table thead th { padding: 0.625rem 0.5rem; font-size: 0.7rem; }
    .table tbody td { padding: 0.5rem; }
    .btn-sm { padding: 0.2rem 0.4rem; font-size: 0.7rem; }
    .btn-action { width: 28px; height: 28px; font-size: 0.75rem; }

    /* Dropdown: fit screen */
    .dropdown-menu { font-size: 0.8rem !important; min-width: 160px; }
    .topbar-dropdown { width: 280px !important; }

    /* Modal: truly full width on phone */
    .modal-dialog { max-width: 100%; margin: 0.5rem; }
    .modal-body { padding: 1rem; }

    /* Form controls: smaller for mobile */
    .form-control, .form-select { font-size: 0.8125rem; height: 38px; padding: 0.4rem 0.75rem; }

    /* Cards: tighter padding */
    .card .card-body { padding: 1rem; }
    .card .card-header { padding: 0.75rem 1rem; }

    /* Welcome card text */
    .card h4 { font-size: 1rem; }
    .card .fa-4x { font-size: 2rem !important; }

    /* Notification bell dropdown */
    .topbar-dropdown.dropdown-menu-end { right: -40px !important; }
}

/* ─── App Identity Text Truncation ──────────────── */
.sidebar-brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    display: inline-block;
    vertical-align: middle;
}
.sidebar-collapsed .sidebar-brand-text {
    display: none;
}

/* ---------------------------------------------------------------
   GLOBAL UI STANDARDS (STANDARDIZATION)
--------------------------------------------------------------- */
.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0;
}

.card-header-standard {
    background: var(--card-bg) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1rem 1.25rem !important;
}

/* --- Action Buttons in Tables ------------------------- */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-action-view {
    background: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
}
.btn-action-view:hover {
    background: #0ea5e9;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.3);
}

.btn-action-edit {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}
.btn-action-edit:hover {
    background: #f59e0b;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

.btn-action-delete {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
.btn-action-delete:hover {
    background: #ef4444;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

/* --- APP MOBILE-FIRST LAYOUT --- */
.bottom-nav-bar {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    z-index: 1040;
    padding: 10px 15px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.bottom-nav-item {
    text-align: center;
    color: var(--text-muted);
    text-decoration: none;
    flex: 1;
    font-size: 0.75rem;
    font-weight: 500;
    transition: color 0.2s;
}

.bottom-nav-item i {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 6px;
}

.bottom-nav-item.active {
    color: var(--primary-color);
}
.bottom-nav-item.active i {
    font-weight: 900; /* Make solid */
}

.app-card {
    background: white;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
    margin-bottom: 24px;
    transition: transform 0.2s;
}
.app-card:active {
    transform: scale(0.98);
}

.app-list-item {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
}
.app-list-item:hover {
    color: inherit;
}
.app-list-item:last-child {
    border-bottom: none;
}

.app-list-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 1.4rem;
}

.app-search-wrapper {
    background: #f1f5f9;
    border-radius: 999px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    flex-grow: 1;
    margin-right: 15px;
}

.app-search-input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    margin-left: 10px;
    font-size: 1rem;
    color: var(--text-dark);
}

/* --- GLOBAL MOBILE APP FORCING --- */
body {
    background-color: #000 !important; /* Dark background for desktop outer area */
}

.mobile-app-container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: #f8fafc;
    position: relative;
    box-shadow: 0 0 40px rgba(255,255,255,0.05);
    overflow-x: hidden;
}

.bottom-nav-bar {
    display: flex !important;
    justify-content: space-around;
    align-items: center;
    max-width: 480px; /* Constrain to match container */
    margin: 0 auto;
}

#sidebar {
    display: none !important; /* Hide standard sidebar everywhere */
}

#content-wrapper {
    margin-left: 0 !important;
    padding-bottom: 80px; /* Space for bottom nav */
}

.topbar {
    border-bottom: none !important;
    background: transparent !important;
    box-shadow: none !important;
    margin-top: 10px;
}

.container-fluid {
    padding-top: 0 !important;
}
