/* ===================================
   RADIUS Dashboard - Custom Styles
   Professional & Responsive Design
   =================================== */

:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --dark-color: #212529;
    --light-bg: #f8f9fa;
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;
}

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    font-size: 14px;
}

/* ===================================
   Cards & Containers
   =================================== */

.card {
    border: none;
    border-radius: 10px;
    overflow: visible;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 0.75rem;
}

.card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-header {
    border-bottom: none;
    padding: 0.75rem 1rem;
}

.card-body {
    padding: 1rem;
    min-height: auto;
}

/* ===================================
   Sidebar Navigation
   =================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e3c72 0%, #2a5298 100%);
    padding: 0 0 46px 0; /* bottom space for toggle bar */
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.sidebar .sidebar-menu {
    flex: 1;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-menu-link span {
    opacity: 0;
    width: 0;
    display: none;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 1.5rem 0.5rem;
}

.sidebar.collapsed .sidebar-menu-link {
    justify-content: center;
    padding: 0.875rem 0;
}

.sidebar.collapsed .sidebar-menu-link i {
    margin-right: 0;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.sidebar-header {
    padding: 1rem 0.75rem;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-menu {
    padding: 1rem 0;
    list-style: none;
    margin: 0;
}

.sidebar-menu-item {
    margin-bottom: 0.25rem;
}

/* ── Sidebar Submenu (dropdown inside sidebar) ── */
.sidebar-menu-item > ul {
    background: rgba(0,0,0,0.18);
    border-left: 3px solid rgba(255,255,255,0.2);
    margin: 0;
    padding: 0;
    list-style: none;
    /* smooth height animation via max-height */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.2s ease;
    opacity: 0;
    display: block !important; /* override inline style="display:none" */
}

.sidebar-menu-item > ul.submenu-open {
    max-height: 500px;
    opacity: 1;
    padding: 0.25rem 0;
}

.sidebar-menu-item > ul li a.sidebar-menu-link {
    font-size: 0.83rem !important;
    padding: 0.45rem 1.25rem 0.45rem 2.5rem !important;
    color: rgba(255,255,255,0.8);
    border-left: none;
    font-weight: 400;
}

.sidebar-menu-item > ul li a.sidebar-menu-link:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    padding-left: 2.75rem !important;
}

/* Chevron rotation when submenu open */
.sidebar-menu-link .fa-chevron-down {
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.sidebar-menu-item.submenu-expanded > .sidebar-menu-link .fa-chevron-down {
    transform: rotate(180deg);
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.25rem;
    color: rgba(255,255,255,0.92);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.88rem;
    border-left: 3px solid transparent;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.sidebar-menu-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: #fff;
}

.sidebar-menu-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left-color: #ffc107;
    font-weight: 600;
}

.sidebar-menu-link i {
    width: 24px;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed);
}

/* Generate Voucher Section Animation */
#generateVoucherSection,
#generateFormContainer {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reduce spacing for cleaner layout */
.container-fluid.py-4 {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
}

.container-fluid.py-2 {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

.main-content .bg-white.border-bottom {
    padding: 0.5rem 1rem !important;
}

.row.mb-3 {
    margin-bottom: 0.75rem !important;
}

.row.mb-2 {
    margin-bottom: 0.5rem !important;
}

/* Fix card spacing */
.card {
    margin-bottom: 0.75rem;
}

.card-body {
    padding: 0.875rem;
}

/* ===================================
   Top Utility Bar (Professional)
   =================================== */

.main-content > .bg-white.border-bottom {
    background: #fff !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-content > .bg-white.border-bottom .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
    border-radius: 6px;
    white-space: nowrap;
}

.main-content > .bg-white.border-bottom .btn-sm i {
    font-size: 0.75rem;
}

/* ===================================
   Analyzer Sub-menu Items
   =================================== */

.analyzer-menu .dropdown-item {
    padding: 0.45rem 1rem;
    font-size: 0.84rem;
    border-radius: 6px;
    margin: 1px 0.4rem;
    transition: background 0.15s;
}

.analyzer-menu .dropdown-item:hover {
    background: rgba(13, 110, 253, 0.08);
}

.analyzer-menu .dropdown-item i {
    width: 18px;
    text-align: center;
}

.analyzer-menu .dropdown-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    padding: 0.35rem 1rem 0.15rem;
}

/* ===================================
   Offcanvas Analyzer Panels
   =================================== */

.offcanvas {
    z-index: 1060;
}

.offcanvas-end {
    width: 480px;
}

.offcanvas-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    padding: 0.75rem 1rem;
}

.offcanvas-header .offcanvas-title {
    font-size: 0.92rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.offcanvas-body {
    padding: 1rem;
    font-size: 0.85rem;
}

/* ===================================
   Dropdown Menus (Responsive)
   =================================== */

.dropdown-menu {
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.08);
}

.dropdown-menu .dropdown-header {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--dark-color);
}

.dropdown-menu .progress {
    height: 5px;
    border-radius: 3px;
}

.dropdown-menu .table {
    font-size: 0.8rem;
    margin-bottom: 0;
}

.dropdown-menu .table td {
    padding: 0.3rem 0.25rem;
    vertical-align: middle;
    border: none;
}

.dropdown-menu .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
}

.sidebar-toggle {
    position: fixed;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    z-index: 1001;
    background: rgba(10, 24, 64, 0.97);
    color: rgba(255,255,255,0.88);
    border: none;
    height: 46px;
    border-radius: 0;
    cursor: pointer;
    box-shadow: 0 -3px 10px rgba(0,0,0,0.25);
    transition: width 0.3s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 1.25rem;
    gap: 0.6rem;
    font-size: 0.85rem;
    border-top: 1px solid rgba(255,255,255,0.12);
}

.sidebar-toggle:hover {
    background: rgba(30, 60, 114, 1);
    color: #fff;
}

.sidebar-toggle.collapsed {
    width: var(--sidebar-collapsed);
    padding: 0;
    justify-content: center;
}

.sidebar-toggle .sidebar-toggle-label {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-toggle.collapsed .sidebar-toggle-label {
    display: none;
}

/* ===================================
   Mobile Responsive (≤768px)
   =================================== */
@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
    
    .sidebar {
        width: 240px;
        transform: translateX(-240px);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        z-index: 1200;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        overflow-y: auto;
        max-height: 100vh;
    }

    .sidebar.collapsed {
        width: 240px;
        transform: translateX(-240px);
    }

    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed .sidebar-brand span,
    .sidebar.collapsed .sidebar-menu-link span {
        opacity: 1;
        width: auto;
        display: inline;
    }

    .sidebar.collapsed .sidebar-brand {
        justify-content: flex-start;
        padding: 1rem 0.75rem;
    }

    .sidebar.collapsed .sidebar-menu-link {
        justify-content: flex-start;
        padding: 0.65rem 1.25rem;
    }

    .sidebar.collapsed .sidebar-menu-link i {
        margin-right: 0.75rem;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .main-content.expanded {
        margin-left: 0 !important;
    }
    
    .sidebar-toggle {
        bottom: 16px !important;
        top: auto !important;
        left: 12px !important;
        width: 42px !important;
        height: 42px !important;
        border-radius: 50% !important;
        padding: 0 !important;
        justify-content: center !important;
        box-shadow: 0 4px 14px rgba(0,0,0,0.4) !important;
        border-top: none !important;
        z-index: 1201 !important;
    }

    .sidebar-toggle .sidebar-toggle-label {
        display: none !important;
    }

    .sidebar-toggle.collapsed {
        left: 12px !important;
        width: 42px !important;
        padding: 0 !important;
        justify-content: center !important;
    }

    /* Overlay backdrop */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1199;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Page header compact */
    .main-content .bg-white.border-bottom,
    .main-content > .bg-white.border-bottom {
        padding: 0.4rem 0.5rem !important;
    }

    .main-content .bg-white.border-bottom h5 {
        font-size: 0.85rem;
    }

    /* ---- TOP UTILITY BAR on mobile ---- */
    .main-content > .bg-white.border-bottom .d-flex {
        flex-wrap: nowrap;
        gap: 6px !important;
        justify-content: flex-end !important;
    }

    .main-content > .bg-white.border-bottom .btn-sm {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Keep button text visible — only 2 buttons now */

    /* ---- OFFCANVAS on mobile ---- */
    .offcanvas-end {
        width: 100% !important;
    }

    /* ---- DROPDOWN MENUS on mobile ---- */
    .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
        width: 100vw !important;
        max-height: 75vh !important;
        border-radius: 16px 16px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.2) !important;
        overflow-y: auto !important;
        padding: 0.75rem !important;
        animation: slideUpMobile 0.25s ease-out;
        margin: 0 !important;
    }

    @keyframes slideUpMobile {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    /* Cards inside dropdowns */
    .dropdown-menu .card {
        margin-bottom: 0.5rem;
    }

    .dropdown-menu .card-header {
        padding: 0.4rem 0.6rem;
        font-size: 0.78rem;
    }

    .dropdown-menu .card-body {
        padding: 0.5rem;
        font-size: 0.78rem;
    }

    .dropdown-menu .table {
        font-size: 0.72rem;
    }

    .dropdown-menu .table td,
    .dropdown-menu .table th {
        padding: 0.2rem 0.3rem;
    }

    .dropdown-menu h6.dropdown-header {
        font-size: 0.82rem;
        padding: 0 0 0.3rem 0;
    }

    .dropdown-menu h6:not(.dropdown-header) {
        font-size: 0.75rem;
    }

    /* Container fluid less padding */
    .container-fluid {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Stat cards compact */
    .card.bg-primary .card-body,
    .card.bg-success .card-body,
    .card.bg-danger .card-body,
    .card.bg-warning .card-body,
    .card.bg-info .card-body {
        padding: 0.6rem !important;
        min-height: auto !important;
    }

    .card.bg-primary h2,
    .card.bg-success h2,
    .card.bg-danger h2,
    .card.bg-warning h2,
    .card.bg-info h2 {
        font-size: 1.4rem;
    }

    .card.bg-primary h6,
    .card.bg-success h6,
    .card.bg-danger h6,
    .card.bg-warning h6,
    .card.bg-info h6 {
        font-size: 0.7rem;
    }

    .card.bg-primary .fs-1,
    .card.bg-success .fs-1,
    .card.bg-danger .fs-1,
    .card.bg-warning .fs-1,
    .card.bg-info .fs-1 {
        font-size: 1.5rem !important;
        opacity: 0.7;
    }

    /* Cards - responsive grid */
    .row > [class*="col-md-2"] {
        flex: 0 0 50%;
        max-width: 50%;
        padding-left: 4px;
        padding-right: 4px;
    }
    
    .row > .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .card-header {
        padding: 0.5rem 0.75rem;
    }

    .card-body {
        padding: 0.6rem;
        min-height: auto;
    }

    /* Tables scroll horizontal */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        position: relative;
        overflow-x: auto !important;
        overflow-y: hidden;
    }

    /* Ensure tables inside cards always scroll */
    .card-body > .table-responsive,
    .card > .table-responsive,
    .modal-body .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Wrap bare tables in horizontal scroll */
    .card-body > table,
    .modal-body > table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        font-size: 0.75rem;
    }

    .table thead th {
        padding: 0.3rem 0.35rem;
        white-space: nowrap;
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.3px;
    }

    .table tbody td {
        padding: 0.3rem 0.35rem;
        white-space: normal;
        word-break: break-word;
        max-width: 120px;
    }

    /* Forms */
    .form-control-sm, .form-select-sm {
        font-size: 0.8rem;
    }

    /* Modals - fullscreen on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        min-height: 100vh;
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        margin: 0;
        max-width: 100%;
    }

    .modal-content {
        border: none;
        border-radius: 0;
        min-height: 100vh;
    }

    .modal-header {
        padding: 0.6rem 0.75rem;
    }

    .modal-header .modal-title {
        font-size: 0.9rem;
    }

    .modal-body {
        padding: 0.6rem;
        overflow-x: auto;
    }

    .modal-body .table {
        font-size: 0.72rem;
    }

    .modal-body .card {
        margin-bottom: 0.5rem;
    }

    .modal-body .card-header {
        padding: 0.4rem 0.6rem;
        font-size: 0.78rem;
    }

    .modal-body .card-body {
        padding: 0.5rem;
        font-size: 0.78rem;
    }

    /* Buttons */
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .d-flex.gap-2 {
        gap: 0.25rem !important;
    }

    /* Toast */
    .toast {
        min-width: 250px;
        max-width: calc(100vw - 20px);
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.75rem;
    }

    /* Row columns to stack */
    .row > .col-lg-5,
    .row > .col-lg-7 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Search input */
    .input-group-lg .form-control {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }

    .input-group-lg .input-group-text {
        padding: 0.5rem 0.75rem;
    }

    /* Server select */
    #singleServerSelect {
        width: 100% !important;
        margin-top: 0.5rem;
    }

    h5.text-primary, h5.text-success {
        font-size: 0.95rem;
    }

    /* Firewall modal tables */
    .modal-body .row > .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* All inputs/selects with inline widths - override on mobile */
    input[style*="width"],
    select[style*="width"] {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Card header actions wrap properly on mobile */
    .card-header .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    /* Toolbar controls stack on mobile */
    .d-flex.align-items-center.gap-2,
    .d-flex.gap-2 {
        flex-wrap: wrap !important;
        gap: 0.3rem !important;
    }

    /* ---- SESI AKTIF TABLE mobile ---- */
    #sesiAktifSection .card-header {
        padding: 0.35rem 0.5rem;
    }

    #sesiAktifSection .card-header h6 {
        font-size: 0.78rem;
        flex: 1;
        min-width: 0;
    }

    #sesiAktifSection .card-header .btn-group {
        flex-direction: row !important;
    }

    #sesiAktifSection .card-header .btn-group .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.68rem;
    }

    #sesiAktifSection .card-header .btn-group .btn span.ms-1 {
        display: none;
    }

    /* Sesi Aktif: hide COMMENT column (6th) on mobile */
    #sesiAktifSection .table th:nth-child(6),
    #sesiAktifSection .table td:nth-child(6) {
        display: none;
    }

    /* ---- LOG PAGE FIXES ---- */
    /* Nav tabs horizontal scroll on mobile */
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tabs .nav-item {
        flex-shrink: 0;
    }

    .nav-tabs .nav-link {
        font-size: 0.72rem;
        padding: 0.35rem 0.5rem;
        white-space: nowrap;
    }

    .nav-tabs .nav-link.active {
        font-weight: 700;
    }

    /* Log hotspot: hide less-essential columns on mobile */
    /* Hide: Password(3), Total Durasi(6), Login Terakhir(10) */
    #hotspotTable th:nth-child(3),
    #hotspotTable td:nth-child(3),
    #hotspotTable th:nth-child(6),
    #hotspotTable td:nth-child(6),
    #hotspotTable th:nth-child(10),
    #hotspotTable td:nth-child(10) {
        display: none;
    }

    /* Log hotspot stats cards */
    #statsRow .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Log hotspot action buttons compact */
    #hotspotTable .btn {
        padding: 0.1rem 0.25rem;
        font-size: 0.65rem;
    }

    /* Log hotspot detail panel */
    #hotspotDetailPanel .card-header {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    #hotspotDetailPanel .card-header h6 {
        font-size: 0.78rem;
        flex: 1 1 100%;
    }

    #hotspotDetailPanel .card-header .btn {
        font-size: 0.65rem;
        padding: 0.15rem 0.35rem;
    }

    #hotspotDetailPanel .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Server history tables in detail panel */
    #hotspotDetailPanel .table {
        font-size: 0.68rem;
    }

    /* Log viewer controls row */
    .log-container {
        font-size: 0.7rem;
        max-height: 55vh;
    }

    /* Radpostauth table */
    #radpostauthPanel .table {
        font-size: 0.72rem;
    }

    /* Page titles compact */
    .main-content h4 {
        font-size: 1rem;
    }
}

/* ===================================
   Small Phones (≤576px)
   =================================== */
@media (max-width: 576px) {
    body {
        font-size: 12px;
    }
    
    .sidebar-toggle {
        width: 36px !important;
        height: 36px !important;
        bottom: 12px !important;
        top: auto !important;
        font-size: 0.8rem;
    }

    /* Stack form fields */
    .row.g-2 > .col-4,
    .row.g-2 > .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .main-content .bg-white.border-bottom h5 {
        font-size: 0.8rem;
    }

    .main-content .bg-white.border-bottom small {
        display: none;
    }

    /* Card header buttons wrap */
    .card-header .d-flex {
        flex-wrap: wrap;
        gap: 0.2rem;
    }

    /* Profile cards grid - 2 per row */
    .col-md-3, .col-sm-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Even smaller stat cards */
    .row > [class*="col-md-2"] {
        flex: 0 0 50%;
        max-width: 50%;
        padding-left: 3px;
        padding-right: 3px;
        margin-bottom: 6px !important;
    }

    .card.bg-primary .card-body,
    .card.bg-success .card-body,
    .card.bg-danger .card-body,
    .card.bg-warning .card-body,
    .card.bg-info .card-body {
        padding: 0.5rem !important;
    }

    .card.bg-primary h2,
    .card.bg-success h2,
    .card.bg-danger h2,
    .card.bg-warning h2,
    .card.bg-info h2 {
        font-size: 1.2rem;
    }

    .card.bg-primary h6,
    .card.bg-success h6,
    .card.bg-danger h6,
    .card.bg-warning h6,
    .card.bg-info h6 {
        font-size: 0.62rem;
    }

    .card.bg-primary .fs-1,
    .card.bg-success .fs-1,
    .card.bg-danger .fs-1,
    .card.bg-warning .fs-1,
    .card.bg-info .fs-1 {
        font-size: 1.2rem !important;
    }

    /* Smaller badges */
    .badge {
        font-size: 0.68rem;
        padding: 0.2rem 0.4rem;
    }

    /* Table even smaller */
    .table {
        font-size: 0.65rem;
    }

    .table thead th {
        padding: 0.2rem 0.25rem;
        font-size: 0.62rem;
    }

    .table tbody td {
        padding: 0.2rem 0.25rem;
        max-width: 90px;
    }

    /* Sesi Aktif: also hide USER INFO (5th) on very small */
    #sesiAktifSection .table th:nth-child(5),
    #sesiAktifSection .table td:nth-child(5) {
        display: none;
    }

    /* Log hotspot: hide more columns on small phones */
    /* Also hide: Profile(4), Session(5) */
    #hotspotTable th:nth-child(4),
    #hotspotTable td:nth-child(4),
    #hotspotTable th:nth-child(5),
    #hotspotTable td:nth-child(5) {
        display: none;
    }

    /* Nav tabs even smaller */
    .nav-tabs .nav-link {
        font-size: 0.65rem;
        padding: 0.3rem 0.4rem;
    }

    /* Log container smaller */
    .log-container {
        font-size: 0.65rem;
        max-height: 50vh;
    }

    /* Utility bar - even more compact */
    .main-content > .bg-white.border-bottom .btn-sm {
        padding: 0.15rem 0.3rem;
        font-size: 0.65rem;
    }

    /* Dropdown max-height lower */
    .dropdown-menu {
        max-height: 65vh !important;
    }

    /* Sesi Aktif table columns */
    .card-header .btn-group .btn span.ms-1 {
        display: none;
    }

    /* Search box */
    .input-group-lg .form-control {
        font-size: 0.82rem;
        padding: 0.4rem 0.6rem;
    }

    .input-group-lg .input-group-text {
        padding: 0.4rem 0.6rem;
        font-size: 0.82rem;
    }
}

/* ===================================
   Very Small Phones (≤400px)
   =================================== */
@media (max-width: 400px) {
    .row > [class*="col-md-2"] {
        flex: 0 0 50%;
        max-width: 50%;
        padding-left: 2px;
        padding-right: 2px;
    }

    .container-fluid {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    .card.bg-primary h2,
    .card.bg-success h2,
    .card.bg-danger h2,
    .card.bg-warning h2,
    .card.bg-info h2 {
        font-size: 1rem;
    }

    .card.bg-primary .fs-1,
    .card.bg-success .fs-1,
    .card.bg-danger .fs-1,
    .card.bg-warning .fs-1,
    .card.bg-info .fs-1 {
        display: none;
    }

    /* Search box smaller */
    .input-group-lg .form-control {
        font-size: 0.78rem;
    }
}

/* ===================================
   Safe Area — Modern Phones
   (handles notch + home indicator)
   =================================== */
@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .sidebar {
            padding-bottom: calc(46px + env(safe-area-inset-bottom));
        }
        .sidebar-toggle {
            bottom: calc(16px + env(safe-area-inset-bottom)) !important;
        }
        .main-content {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

/* ===================================
   PPPoE Cards — mobile compact
   =================================== */
@media (max-width: 768px) {
    /* PPPoE stat cards full row → 2 per row */
    .row > [class*="col-md-3"] {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* PPPoE summary numbers */
    #multiPPPTotal, #multiPPPOnline, #multiPPPOffline, #multiPPPDisabled {
        font-size: 1.6rem;
        font-weight: 700;
    }

    /* Main content needs bottom padding so last card is above toggle btn */
    .main-content .container-fluid:last-child {
        padding-bottom: 70px !important;
    }

    /* Sidebar submenu items tap-target bigger on mobile */
    .sidebar-menu-item > ul li a.sidebar-menu-link {
        padding-top: 0.6rem !important;
        padding-bottom: 0.6rem !important;
        font-size: 0.88rem !important;
    }

    /* Sidebar parent links tap-target */
    .sidebar-menu-link {
        padding: 0.75rem 1.25rem;
        min-height: 44px;
    }

    /* Sidebar itself: hide scrollbar visually but allow scroll */
    .sidebar {
        scrollbar-width: none;
    }
    .sidebar::-webkit-scrollbar {
        display: none;
    }

    /* Sticky top bar on mobile: full width */
    #topUtilityBar {
        position: sticky;
        top: 0;
        z-index: 100;
        background: #fff !important;
        padding: 0.3rem 0.5rem !important;
    }
}

/* Statistics Cards */
.card.bg-primary,
.card.bg-success,
.card.bg-danger,
.card.bg-warning {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* ===================================
   Navbar
   =================================== */

.navbar {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.3rem;
}

/* ===================================
   Forms
   =================================== */

.form-label {
    font-size: 0.9rem;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.form-label.fw-bold {
    font-weight: 600 !important;
}

.form-control,
.form-select {
    border-radius: 6px;
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-size: 0.875rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.input-group .form-control,
.input-group .form-select {
    border-radius: 0;
}

.input-group .form-control:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.input-group .form-select:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.form-text {
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

/* Button Groups */
.btn-group .btn-check:checked + .btn-outline-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-group .btn-check:checked + .btn-outline-secondary {
    background-color: #6c757d;
    color: white;
}

/* ===================================
   Buttons
   =================================== */

.btn {
    border-radius: 6px;
    padding: 0.4rem 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.6rem 1.25rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    border: none;
}

.btn-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    border: none;
}

.btn-warning {
    background: linear-gradient(135deg, #f46b45 0%, #eea849 100%);
    border: none;
}

/* ===================================
   Table
   =================================== */

.table-responsive {
    border-radius: 8px;
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead {
    background-color: var(--light-bg);
}

.table thead th {
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.78rem;
    padding: 0.6rem 0.5rem;
    letter-spacing: 0.3px;
}

.table tbody tr {
    transition: background-color 0.2s;
}

.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.025);
}

.table tbody td {
    padding: 0.5rem 0.5rem;
    vertical-align: middle;
}

.table code {
    background-color: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #d63384;
}

/* ===================================
   Badges
   =================================== */

.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.85rem;
}

.badge.bg-success {
    background-color: var(--success-color) !important;
}

.badge.bg-danger {
    background-color: var(--danger-color) !important;
}

/* ===================================
   Toast Notifications
   =================================== */

.toast {
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-width: 300px;
}

.toast-body {
    padding: 1rem;
    font-size: 0.95rem;
}

.toast-body i {
    font-size: 1.2rem;
}

/* ===================================
   Form Switch (Auto-refresh toggle)
   =================================== */

.form-check-input {
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

/* ===================================
   Footer
   =================================== */

footer {
    margin-top: auto;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

/* ===================================
   Animations
   =================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card,
.table-responsive {
    animation: fadeIn 0.4s ease-in-out;
}

/* ===================================
   Loading Spinner
   =================================== */

.fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ===================================
   Search Results Dropdown
   =================================== */

.search-results-dropdown {
    position: relative;
    margin-top: 0.5rem;
}

.search-results-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-height: 450px;
    overflow-y: auto;
    overflow-x: hidden;
}

.search-results-content .list-group {
    margin: 0;
    border-radius: 8px;
}

.search-results-content .list-group-item {
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: white;
}

.search-results-content .list-group-item:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.search-results-content .list-group-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.search-results-content .list-group-item:hover {
    background-color: #f8f9fa;
    border-left: 3px solid var(--primary-color);
    padding-left: calc(1rem - 3px);
}

.search-results-content .list-group-item.active {
    background-color: #e7f1ff;
    border-left: 3px solid var(--primary-color);
}

/* Search result item styling */
.search-result-username {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1rem;
}

.search-result-info {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.search-result-status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.search-result-status.online {
    background-color: #d1e7dd;
    color: #0f5132;
}

.search-result-status.offline {
    background-color: #f8d7da;
    color: #842029;
}

/* Loading state */
.search-results-content .search-loading {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
}

/* No results state */
.search-results-content .search-no-results {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
}

/* ===================================
   Responsive Adjustments (768px)
   =================================== */

@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: 6px !important;
        margin-bottom: 0.3rem;
    }
}

/* ===================================
   Utility Classes
   =================================== */

.text-muted {
    color: #6c757d !important;
}

.shadow {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.bg-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

/* ===================================
   Custom Scrollbar
   =================================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* ===================================
   Print Styles
   =================================== */

@media print {
    body {
        background: white;
    }
    
    .navbar,
    footer,
    .btn,
    #toastContainer {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* ===================================
   Dark Mode Support (Optional)
   =================================== */

@media (prefers-color-scheme: dark) {
    /* Uncomment to enable dark mode */
    /*
    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        color: #e0e0e0;
    }
    
    .card {
        background-color: #2a2a3e;
        color: #e0e0e0;
    }
    
    .table {
        color: #e0e0e0;
    }
    
    .table thead {
        background-color: #1a1a2e;
    }
    
    .form-control,
    .form-select {
        background-color: #2a2a3e;
        color: #e0e0e0;
        border-color: #4a4a5e;
    }
    */
}

/* ===================================
   SMOOTH UPDATE ANIMATIONS
   =================================== */

/* Pulse animation for updating numbers */
@keyframes pulseUpdate {
    0%, 100% {
        transform: scale(1);
        color: inherit;
    }
    50% {
        transform: scale(1.1);
        color: #0d6efd;
        font-weight: 700;
    }
}

.updating {
    animation: pulseUpdate 0.3s ease-in-out;
}

/* Smooth transition for all numeric displays */
.stat-value,
.active-users-count,
#totalServers,
#connectedServers,
#disconnectedServers,
#totalActiveUsers {
    transition: all 0.3s ease;
    display: inline-block;
}

/* Smooth badge transitions */
.server-status-badge {
    transition: all 0.3s ease;
}

/* Prevent layout shift during updates */
.card-body {
    min-height: auto;
}

/* Smooth alert transitions */
.alert {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.alert.alert-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* Loading overlay - non-intrusive refresh indicator */
.loading-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Smooth table updates */
.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* New row fade-in animation */
@keyframes slideInRow {
    from {
        opacity: 0;
        transform: translateX(-10px);
        background-color: rgba(40, 167, 69, 0.1);
    }
    to {
        opacity: 1;
        transform: translateX(0);
        background-color: transparent;
    }
}

.new-row-animation {
    animation: slideInRow 0.5s ease;
}

/* Removed row fade-out animation */
@keyframes fadeOutRow {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(10px);
        background-color: rgba(220, 53, 69, 0.1);
    }
}

.removed-row-animation {
    animation: fadeOutRow 0.3s ease forwards;
}

/* Smooth cell updates */
.user-download.updating,
.user-upload.updating {
    animation: pulseUpdate 0.3s ease-in-out;
    font-weight: 600;
}

/* Compact spacing utilities for MikroTik page */
.container-fluid.py-2 {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

.row.mb-2 {
    margin-bottom: 0.5rem !important;
}

/* Adjust min-height for metric cards */
.metric-card .card-body {
    min-height: auto;
}

/* Ensure main content doesn't overlap with sidebar */
.main-content {
    padding-left: 0;
    padding-right: 0;
}

/* Responsive card columns for MikroTik */
@media (max-width: 768px) {
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* Metric cards compact */
    .metric-card .card-body,
    .card.bg-gradient .card-body {
        padding: 0.5rem !important;
        min-height: auto !important;
    }

    .metric-card h3,
    .card.bg-gradient h3 {
        font-size: 1.1rem;
    }

    .metric-card h6,
    .card.bg-gradient h6 {
        font-size: 0.68rem;
    }

    .metric-card .fs-1,
    .card.bg-gradient .fs-1 {
        font-size: 1.2rem !important;
    }

    /* ---- WIDE TABLE COLUMN HIDING (Global) ---- */
    /* For any table with many columns, ensure table-responsive scroll works */
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 6px;
    }

    /* Generic: hide checkbox columns on mobile (first col if checkbox) */
    .table th:first-child input[type="checkbox"],
    .table td:first-child input[type="checkbox"] {
        transform: scale(0.8);
    }

    /* Accounting page: active sessions table - hide MAC(5), start(6) */
    #activeSessionsBody ~ thead th:nth-child(5),
    #activeSessionsBody td:nth-child(5) {
        display: none;
    }

    /* NAS page: table - hide Port(7), Desc(9) on mobile */
    #nasTableBody ~ thead th:nth-child(7),
    #nasTableBody td:nth-child(7),
    #nasTableBody ~ thead th:nth-child(9),
    #nasTableBody td:nth-child(9) {
        display: none;
    }

    /* Code elements in tables - prevent overflow */
    .table code {
        font-size: 0.68rem;
        word-break: break-all;
        max-width: 100px;
        display: inline-block;
    }

    /* Badge in tables - compact */
    .table .badge {
        font-size: 0.62rem;
        padding: 0.15rem 0.3rem;
    }

    /* Action buttons in tables - compact */
    .table .btn-sm {
        padding: 0.1rem 0.2rem;
        font-size: 0.62rem;
    }

    .table .text-nowrap {
        white-space: normal !important;
    }
}

@media (max-width: 576px) {
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .metric-card h3,
    .card.bg-gradient h3 {
        font-size: 0.95rem;
    }
}

/* ===================================
   TEXT LEGIBILITY FIXES
   Ensure all text is crisp and not blurred
   =================================== */

/* Fix blurry/faded text in colored containers */
.text-success {
    color: #0d7a3e !important;
    font-weight: 600;
}

.text-danger {
    color: #c92a3e !important;
    font-weight: 600;
}

.text-muted {
    color: #5a6268 !important;
}

.text-info {
    color: #0c7da8 !important;
}

.text-warning {
    color: #b87a00 !important;
}

/* Badge text always crisp */
.badge {
    font-weight: 600;
    letter-spacing: 0.2px;
    -webkit-font-smoothing: antialiased;
}

.badge.bg-info {
    background-color: #0ca8c9 !important;
    color: #fff !important;
}

.badge.bg-primary {
    background-color: #0b5ed7 !important;
}

.badge.bg-success {
    background-color: #157347 !important;
}

/* Progress bar text legibility */
.progress-bar {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Table text - never faded */
.table td,
.table th {
    color: #212529;
}

.table thead th {
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.table-dark td,
.table-dark th {
    color: #fff !important;
    font-weight: 600;
}

.table-dark th {
    font-weight: 700;
    letter-spacing: 0.4px;
}

.table-light th {
    color: #1a1a1a !important;
    font-weight: 700;
    background-color: #e9ecef !important;
}

/* Opacity fix - remove opacity on important text */
.card h6.opacity-75 {
    opacity: 0.85 !important;
}

.card .opacity-50 {
    opacity: 0.6 !important;
}

/* Server card in mikrotik page */
.server-card .card-body {
    min-height: auto;
}

/* MikroTik quota table text fix */
#quotaTableBody .text-success,
#quotaTableBody .text-danger {
    font-weight: 700 !important;
}

#quotaTableBody strong {
    font-weight: 700;
    color: #1a1a1a;
}

/* ===================================
   DESKTOP LAYOUT IMPROVEMENTS
   Compact & Professional
   =================================== */

@media (min-width: 769px) {
    /* Compact stat cards on desktop */
    .card.bg-primary .card-body,
    .card.bg-success .card-body,
    .card.bg-danger .card-body,
    .card.bg-warning .card-body,
    .card.bg-info .card-body {
        padding: 0.75rem 1rem;
    }

    .card.bg-primary h6,
    .card.bg-success h6,
    .card.bg-danger h6,
    .card.bg-warning h6,
    .card.bg-info h6 {
        font-size: 0.75rem;
        margin-bottom: 0.15rem !important;
    }

    .card.bg-primary h2,
    .card.bg-success h2,
    .card.bg-danger h2,
    .card.bg-warning h2,
    .card.bg-info h2 {
        font-size: 1.6rem;
    }

    .card.bg-primary .fs-1,
    .card.bg-success .fs-1,
    .card.bg-danger .fs-1,
    .card.bg-warning .fs-1,
    .card.bg-info .fs-1 {
        font-size: 1.8rem !important;
        opacity: 0.75;
    }

    /* Top utility bar - compact & aligned */
    .main-content > .bg-white.border-bottom {
        padding: 0.4rem 0.75rem !important;
    }

    .main-content > .bg-white.border-bottom .btn-sm {
        padding: 0.25rem 0.6rem;
        font-size: 0.78rem;
    }

    /* Offcanvas width on desktop */
    .offcanvas-end {
        width: 480px;
    }
    
    /* Container padding */
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* ===================================
   DARK MODE
   Toggle via [data-theme="dark"] on <html>
   =================================== */

[data-theme="dark"] {
    --primary-color: #4dabf7;
    --dark-color: #e9ecef;
    --light-bg: #1a1d23;
}

[data-theme="dark"] body {
    background: #12151a;
    color: #d0d4dc;
}

[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #141821 0%, #1b2030 100%);
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
}

[data-theme="dark"] .main-content {
    background: #12151a;
}

[data-theme="dark"] .card {
    background: #1e222a;
    border-color: #2a2f3a;
    color: #d0d4dc;
}

[data-theme="dark"] .card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

[data-theme="dark"] .card-header {
    background: #242830 !important;
    border-color: #2a2f3a;
    color: #d0d4dc;
}

[data-theme="dark"] .table {
    color: #d0d4dc;
    --bs-table-bg: #1e222a;
    --bs-table-striped-bg: #242830;
    --bs-table-hover-bg: #2a2f3a;
    --bs-table-border-color: #2a2f3a;
}

[data-theme="dark"] .table thead th {
    background: #242830;
    border-color: #2a2f3a;
    color: #a0a6b4;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #1e222a;
    border-color: #2a2f3a;
    color: #d0d4dc;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: #242830;
    border-color: #4dabf7;
    color: #e9ecef;
}

[data-theme="dark"] .bg-white {
    background-color: #1e222a !important;
    color: #d0d4dc;
}

[data-theme="dark"] .border-bottom {
    border-color: #2a2f3a !important;
}

[data-theme="dark"] .modal-content {
    background: #1e222a;
    border-color: #2a2f3a;
    color: #d0d4dc;
}

[data-theme="dark"] .modal-header {
    border-color: #2a2f3a;
}

[data-theme="dark"] .modal-footer {
    border-color: #2a2f3a;
}

[data-theme="dark"] .dropdown-menu {
    background: #1e222a;
    border-color: #2a2f3a;
}

[data-theme="dark"] .dropdown-item {
    color: #d0d4dc;
}

[data-theme="dark"] .dropdown-item:hover {
    background: #2a2f3a;
}

[data-theme="dark"] .alert-info {
    background: #1a2332;
    border-color: #2a3f5a;
    color: #6cb4ee;
}

[data-theme="dark"] .text-muted {
    color: #808898 !important;
}

[data-theme="dark"] .sidebar-toggle {
    background: #1e222a;
    border-color: #2a2f3a;
    color: #d0d4dc;
}

/* Dark mode toggle button */
.dark-mode-toggle {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid #e2e8f0;
    background: #fff;
    color: #555;
    font-size: 18px;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transition: all 0.3s;
}

.dark-mode-toggle:hover {
    transform: scale(1.1);
}

[data-theme="dark"] .dark-mode-toggle {
    background: #2a2f3a;
    border-color: #3a3f4a;
    color: #ffc107;
}
