/* ==========================================================================
   MikroTik SNMP Bandwidth Monitor - Enterprise Dark + Green NMS Theme
   ========================================================================== */

:root, [data-theme="dark"] {
    --bg-base: #000000;
    --bg-surface: #0a0e13;
    --bg-surface-elevated: #111822;
    --bg-surface-hover: #192330;
    --border-subtle: #1e2936;
    --border-highlight: #00ff88;

    --primary-green: #10b981;
    --primary-neon: #00ff88;
    --primary-glow: rgba(0, 255, 136, 0.25);
    --cyan-accent: #06b6d4;
    --cyan-glow: rgba(6, 182, 212, 0.25);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #64748b;

    --status-online: #10b981;
    --status-warning: #f59e0b;
    --status-offline: #ef4444;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.8), 0 0 1px 1px var(--border-subtle);
    --topbar-bg: #0a0e13;
    --sidebar-bg: #0a0e13;
    --modal-bg: #0d131a;
}

[data-theme="light"] {
    --bg-base: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f8fafc;
    --bg-surface-hover: #e2e8f0;
    --border-subtle: #e2e8f0;
    --border-highlight: #059669;

    --primary-green: #059669;
    --primary-neon: #008800;
    --primary-glow: rgba(5, 150, 105, 0.2);
    --cyan-accent: #0284c7;
    --cyan-glow: rgba(2, 132, 199, 0.2);

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dark: #94a3b8;

    --status-online: #059669;
    --status-warning: #d97706;
    --status-offline: #dc2626;

    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
    --topbar-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --modal-bg: #ffffff;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-subtle);
    min-height: 72px;
    position: relative;
}

.brand-logo-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-decoration: none;
}

.brand-logo-img {
    width: 100%;
    max-width: 215px;
    height: auto;
    max-height: 52px;
    object-fit: contain;
    display: block;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), filter 0.25s ease;
    filter: drop-shadow(0 2px 8px rgba(0, 255, 136, 0.2));
}

.brand-logo-img:hover {
    transform: scale(1.02);
    filter: drop-shadow(0 4px 16px rgba(0, 255, 136, 0.45));
}

.login-logo-img {
    width: 100%;
    max-width: 320px;
    height: auto;
    max-height: 80px;
    object-fit: contain;
    display: block;
    margin: 0 auto 14px auto;
    filter: drop-shadow(0 4px 20px rgba(0, 255, 136, 0.35));
    transition: transform 0.25s ease;
}

.login-logo-img:hover {
    transform: scale(1.02);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #059669, #00ff88);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 800;
    font-size: 18px;
    box-shadow: 0 0 15px var(--primary-glow);
}

.brand-text h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #fff;
}

.brand-text span {
    font-size: 11px;
    color: var(--primary-neon);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    padding: 20px 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background-color: var(--bg-surface-hover);
    color: #fff;
}

.nav-link.active {
    background-color: var(--bg-surface-elevated);
    color: var(--primary-neon);
    border-left: 3px solid var(--primary-neon);
    font-weight: 600;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(0, 0, 0, 0.2);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--primary-green);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-neon);
    font-weight: 700;
    font-size: 13px;
}

.user-info .user-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
}

.user-info .user-role {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.btn-logout {
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}

.btn-logout:hover {
    color: var(--status-offline);
}

/* Main Content Area */
.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.topbar {
    height: 64px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.topbar-title h1 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.clock-display {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--primary-neon);
    background: rgba(0, 255, 136, 0.08);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 255, 136, 0.2);
}

.poller-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--status-online);
    box-shadow: 0 0 8px var(--status-online);
    animation: pulse-dot 2s infinite;
}

.status-dot.warning { background-color: var(--status-warning); box-shadow: 0 0 8px var(--status-warning); }
.status-dot.offline { background-color: var(--status-offline); box-shadow: 0 0 8px var(--status-offline); }

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.6; }
}

.content-body {
    padding: 28px;
    flex-grow: 1;
}

/* Metric Cards Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s;
}

.metric-card:hover {
    border-color: var(--border-highlight);
}

.metric-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-neon), transparent);
    opacity: 0.5;
}

.metric-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-value {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    font-family: var(--font-mono);
}

.metric-value.rx { color: var(--primary-neon); }
.metric-value.tx { color: var(--cyan-accent); }

.metric-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Cards & Tables */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 0.01);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 20px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

table.data-table th {
    background-color: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
}

table.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 13px;
    color: var(--text-main);
}

table.data-table tr:hover td {
    background-color: var(--bg-surface-hover);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-green);
    color: #000;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--primary-neon);
    box-shadow: 0 0 12px var(--primary-glow);
}

.btn-secondary {
    background-color: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--border-highlight);
}

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

.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.btn-danger:hover {
    background-color: var(--status-offline);
    color: #fff;
}

/* Form inputs */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    background-color: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 13.5px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 95%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toast-in 0.3s ease;
}

.toast.success { border-left: 4px solid var(--primary-neon); }
.toast.error { border-left: 4px solid var(--status-offline); }

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-online { background-color: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background-color: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-offline { background-color: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-info { background-color: rgba(6, 182, 212, 0.15); color: #38bdf8; border: 1px solid rgba(6, 182, 212, 0.3); }

/* Progress bars */
.progress-bar-bg {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #059669, #00ff88);
}

.progress-bar-fill.warning { background: linear-gradient(90deg, #d97706, #f59e0b); }
.progress-bar-fill.danger { background: linear-gradient(90deg, #dc2626, #ef4444); }

/* ==========================================================================
   Theme Switcher Button & Transitions
   ========================================================================== */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 13px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

[data-theme="dark"] .theme-toggle-btn {
    background: #111822;
    border: 1px solid #1e2936;
    color: #fbbf24;
}

[data-theme="dark"] .theme-toggle-btn:hover {
    background: #192330;
    border-color: #fbbf24;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.25);
}

[data-theme="light"] .theme-toggle-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
}

[data-theme="light"] .theme-toggle-btn:hover {
    background: #e2e8f0;
    border-color: #059669;
    color: #059669;
}

/* ==========================================================================
   Light Theme Comprehensive Overrides
   ========================================================================== */
[data-theme="light"] .brand-text h2,
[data-theme="light"] .topbar-title h1,
[data-theme="light"] .user-info .user-name,
[data-theme="light"] .card-title,
[data-theme="light"] .metric-value,
[data-theme="light"] .nav-link:hover,
[data-theme="light"] table.data-table td strong {
    color: #0f172a !important;
}

[data-theme="light"] .sidebar-footer {
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

[data-theme="light"] .nav-link.active {
    background-color: #ecfdf5;
    color: #059669;
    border-left: 3px solid #059669;
}

[data-theme="light"] .card-header {
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] table.data-table th {
    background-color: #f8fafc;
    color: #475569;
    border-bottom: 1px solid #cbd5e1;
}

[data-theme="light"] table.data-table td {
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b;
}

[data-theme="light"] table.data-table tr:hover td {
    background-color: #f1f5f9;
}

[data-theme="light"] .clock-display {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

[data-theme="light"] .poller-status-badge {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #334155;
}

[data-theme="light"] .form-control {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
}

[data-theme="light"] .form-control:focus {
    border-color: #059669;
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

[data-theme="light"] .modal-overlay {
    background-color: rgba(15, 23, 42, 0.6);
}

[data-theme="light"] .modal-card {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .toast {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Transform inline white-text in light mode */
[data-theme="light"] [style*="color: #fff"],
[data-theme="light"] [style*="color:#fff"],
[data-theme="light"] [style*="color: #ffffff"],
[data-theme="light"] [style*="color:#ffffff"],
[data-theme="light"] [style*="color: white"],
[data-theme="light"] [style*="color:white"] {
    color: #0f172a !important;
}

[data-theme="light"] [style*="background: rgba(0, 0, 0, 0.3)"],
[data-theme="light"] [style*="background:rgba(0,0,0,0.3)"],
[data-theme="light"] [style*="background: rgba(0,0,0,0.3)"],
[data-theme="light"] [style*="background: rgba(0, 0, 0, 0.2)"] {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

/* ==========================================================================
   Mobile Navigation Controls & Drawer
   ========================================================================== */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4.5px;
    width: 38px;
    height: 38px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    border-color: var(--primary-neon);
    background: var(--bg-surface-hover);
}

.mobile-menu-toggle span {
    display: block;
    width: 19px;
    height: 2px;
    background-color: var(--text-main);
    border-radius: 2px;
    transition: all 0.2s ease;
}

.mobile-sidebar-close {
    display: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mobile-sidebar-close:hover {
    color: #fff;
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.25s ease;
}

/* ==========================================================================
   Responsive Breakpoints: Desktop, Tablets, Phones & Small Screens
   ========================================================================== */
html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

.app-container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.main-wrapper {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.content-body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.card {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Tablet & Smaller Screens (<= 900px) */
@media (max-width: 900px) {
    .mobile-menu-toggle {
        display: flex !important;
    }

    .mobile-sidebar-close {
        display: flex !important;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        width: 275px;
        max-width: 85vw;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: none;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 15px 0 50px rgba(0, 0, 0, 0.9);
    }

    .sidebar-backdrop.active {
        display: block;
        opacity: 1;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .main-wrapper {
        width: 100%;
        min-width: 0;
    }

    .topbar {
        padding: 0 16px;
        height: 60px;
    }

    .content-body {
        padding: 18px 14px;
    }
}

/* Phablets & Mobile Screens (<= 768px) */
@media (max-width: 768px) {
    .dash-interface-select {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .live-throughput-strip {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .live-throughput-strip > div {
        flex-wrap: wrap !important;
        gap: 8px 14px !important;
    }

    .pv-summary-strip {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        padding: 10px 12px !important;
    }
}

/* Phones (<= 640px) */
@media (max-width: 640px) {
    .topbar {
        padding: 0 12px;
        height: 56px;
        gap: 8px;
    }

    .topbar-left {
        gap: 8px !important;
        min-width: 0;
        flex: 1;
    }

    .topbar-title h1 {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 140px;
    }

    .topbar-actions {
        gap: 6px;
        flex-shrink: 0;
    }

    .clock-display {
        display: none !important;
    }

    .poller-status-badge span:last-child {
        display: none;
    }

    .poller-status-badge {
        padding: 6px 8px;
        gap: 0;
    }

    .theme-toggle-btn #theme-toggle-label {
        display: none;
    }

    .theme-toggle-btn {
        padding: 6px 10px;
    }

    #btn-quick-poll {
        padding: 6px 9px;
        font-size: 12px;
    }

    .content-body {
        padding: 12px 10px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 14px;
    }

    .metric-card {
        padding: 12px 14px;
    }

    .metric-value {
        font-size: 19px;
    }

    .metric-title {
        font-size: 11px;
    }

    .card {
        margin-bottom: 16px;
        border-radius: var(--radius-sm);
    }

    .card-header {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .card-header .topbar-actions,
    .card-header .card-actions,
    .card-header .btn-group {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .card-header .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .card-body {
        padding: 12px;
    }

    .table-responsive {
        margin: -4px -12px;
        padding: 0 12px;
        width: calc(100% + 24px);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
    }

    .table-responsive::-webkit-scrollbar {
        height: 5px;
    }
    .table-responsive::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.2);
    }
    .table-responsive::-webkit-scrollbar-thumb {
        background: var(--border-subtle);
        border-radius: 3px;
    }

    table.data-table th,
    table.data-table td {
        padding: 8px 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    /* Modals on Mobile */
    .modal-card {
        width: calc(100% - 20px) !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        margin: 10px auto !important;
        border-radius: 12px !important;
        display: flex;
        flex-direction: column;
    }

    .modal-card .card-header {
        padding: 14px 16px !important;
        flex-shrink: 0;
    }

    .modal-card .card-body {
        padding: 16px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .modal-card .card-footer {
        padding: 12px 16px !important;
        flex-shrink: 0;
    }

    .form-control {
        font-size: 16px !important; /* Prevents auto-zoom in iOS Safari */
        padding: 8px 12px;
    }

    input.form-control, select.form-control {
        height: 40px;
    }

    textarea.form-control {
        height: auto;
        min-height: 80px;
    }

    .btn {
        min-height: 38px;
        font-size: 13px;
    }

    .report-filter-field {
        min-width: 100% !important;
    }
}

/* Small Phones (<= 400px) */
@media (max-width: 400px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .topbar-title h1 {
        max-width: 110px;
        font-size: 14px;
    }

    .brand-logo-img {
        max-width: 175px;
    }
}

/* ==========================================================================
   Instant SPA Navigation & Progress Bar
   ========================================================================== */
#spa-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #10b981, #00ff88, #38bdf8);
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.8), 0 0 4px rgba(56, 189, 248, 0.6);
    z-index: 999999;
    pointer-events: none;
    transition: width 0.18s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.25s ease;
    opacity: 0;
}

#spa-progress-bar.active {
    opacity: 1;
}

.content-body {
    transition: opacity 0.12s ease;
}

.content-body.spa-swapping {
    opacity: 0.92;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}


