/* Modern CSS for Proxy Panel */
:root {
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.3);
    --secondary: #1d4ed8;
    --background: #0b1021;
    --surface: rgba(22, 27, 48, 0.65);
    --surface-hover: rgba(30, 41, 59, 0.8);
    --text: #ffffff;
    --text-muted: #94a3b8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: rgba(255, 255, 255, 0.08);
    --glass: rgba(255, 255, 255, 0.02);
    --blur: blur(24px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: radial-gradient(circle at top left, #1c2642, #0b1021 60%);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #ffffff, var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

/* Glass Card */
.card {
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.08);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-item {
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
}

/* Table Design */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th {
    text-align: left;
    padding: 0.6rem 0.8rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.th-content {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

th:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.02);
}

th .sort-icon {
    display: inline-flex;
    align-items: center;
    opacity: 0.2;
    transition: opacity 0.2s ease;
}

th .sort-icon i {
    width: 12px;
    height: 12px;
}

th.active {
    color: #ffffff;
}

th.active .sort-icon {
    opacity: 1;
    color: var(--primary);
}

#clientsTable th:first-child,
#clientsTable td:first-child {
    width: 40%; /* Minimum 40%, will grow */
}

#clientsTable th:not(:first-child),
#clientsTable td:not(:first-child) {
    width: 1%;
    white-space: nowrap;
}

td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    vertical-align: middle;
    transition: background 0.1s ease;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

tr:hover td:first-child {
    box-shadow: inset 3px 0 0 0 var(--primary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(239, 68, 68, 0.2); /* Red when OFF */
    border-radius: 22px;
    border: 1px solid rgba(239, 68, 68, 0.4);
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: #ef4444; /* Circle red when OFF */
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: rgba(59, 130, 246, 0.25); /* Blue when ON */
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: #3b82f6; /* Circle blue when ON */
    box-shadow: 0 0 6px #3b82f6;
}

/* Status Badge (now used alongside toggle) */
.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.status-badge.active {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.3);
}

.status-badge.active::before {
    content: "";
    width: 5px;
    height: 5px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 6px #4ade80;
}

/* Warning indicator for IP violations */
.ip-warning {
    display: inline-flex;
    align-items: center;
    color: var(--warning);
    margin-left: 0.4rem;
    animation: warningPulse 1.5s infinite;
}

.ip-warning i {
    width: 14px;
    height: 14px;
}

@keyframes warningPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Health Status Badges */
.health-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.3rem;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    vertical-align: middle;
}

.health-dead {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.health-unstable {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    animation: warningPulse 1.5s infinite;
}

.health-inactive {
    color: #64748b;
    background: rgba(100, 116, 139, 0.15);
    border: 1px solid rgba(100, 116, 139, 0.3);
}

/* Inline editable input */
.inline-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.3rem 0.5rem;
    width: 60px;
    text-align: center;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
    appearance: none;
}

.inline-input::-webkit-outer-spin-button,
.inline-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    border: none;
}

.inline-input:hover {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.inline-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Buttons */
.btn {
    padding: 0.7rem 1.4rem;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--primary-glow);
    filter: brightness(1.1);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border);
    color: var(--text-muted);
    padding: 0.35rem;
    border-radius: 6px;
}

.btn-icon:hover {
    background: var(--surface-hover);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-success {
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}
.btn-success:hover { background: rgba(96, 165, 250, 0.2); }

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
    animation: warningBtnPulse 2s infinite;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

@keyframes warningBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 10px 0 rgba(239, 68, 68, 0.1); }
}

/* Inputs & Selects */
.form-input,
.form-select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem 1.1rem;
    color: white;
    width: 100%;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

/* Styled select dropdown */
.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.form-select option {
    background: #1a1f36;
    color: white;
    padding: 0.5rem;
}

/* Custom Select Component for rounded corners dropdown */
.custom-select {
    position: relative;
    width: auto;
    min-width: 140px;
    user-select: none;
}

.select-trigger {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.select-trigger::after {
    content: "";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    transition: transform 0.3s ease;
}

.custom-select.open .select-trigger {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.custom-select.open .select-trigger::after {
    transform: translateY(-50%) rotate(180deg);
}

.select-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #161b30;
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.custom-select.open .select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.select-option {
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-option:hover {
    background: rgba(59, 130, 246, 0.1);
    color: white;
}

.select-option.selected {
    background: var(--primary);
    color: white;
}

/* Modals */
.modal {
    padding: 1.5rem;
}

/* Logs Table */
.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.logs-table th {
    cursor: default;
    font-size: 0.65rem;
    padding: 0.6rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.logs-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.logs-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.log-status {
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}
.log-status.success { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.log-status.failed { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

#otpCountdown {
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
    letter-spacing: 1px;
}

/* Toast Notifications */
#toastContainer {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none; /* Let clicks pass through if covered */
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: toastSlideDown 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards,
               toastFadeOut 0.4s 2.6s forwards;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-success i { color: #10b981; }
.toast-info i { color: #3b82f6; }
.toast-error i { color: #ef4444; }

@keyframes toastSlideDown {
    from { transform: translateY(-40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastFadeOut {
    to { transform: translateY(-20px); opacity: 0; }
}

/* btop style charts */
.chart-container {
    background: #0f172a !important;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 15px;
    position: relative;
    overflow: hidden;
}

.chart-container::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Chart Controls */
.chart-controls {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.range-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.range-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.range-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate {
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--background);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Status cell with toggle */
.status-cell {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* User name cell */
.user-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-name-main {
    font-weight: 600;
}

.user-comment {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Action buttons group */
.actions-cell {
    display: flex;
    gap: 0.2rem;
    justify-content: flex-end;
    align-items: center;
}

/* Logs container max height */
.logs-container {
    max-height: 400px;
    overflow-y: auto;
}

/* ── Mobile User Cards (hidden by default, shown on mobile) ─── */
#mobileUserList {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
}

.mobile-user-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    -webkit-tap-highlight-color: transparent;
}

.mobile-user-card:active {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.3);
    transform: scale(0.98);
}

.mobile-user-card .card-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1;
}

.mobile-user-card .card-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-user-card .card-comment {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-user-card .card-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.mobile-user-card .card-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.mobile-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mobile-online-dot.online {
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
}

.mobile-online-dot.offline {
    background: #64748b;
}

/* ── User Detail Modal (mobile) ───────────────────────────── */
.user-detail-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.user-detail-row:last-child {
    border-bottom: none;
}

.user-detail-label {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
}

.user-detail-value {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-detail-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.user-detail-actions .btn {
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.user-detail-actions .btn:active {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}

.user-detail-actions .btn i {
    width: 20px;
    height: 20px;
}

.user-detail-actions .btn-danger-action {
    color: var(--danger) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
}

.user-detail-actions .btn-danger-action:active {
    background: rgba(239, 68, 68, 0.15) !important;
}

/* ── Mobile Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    /* Header */
    header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        margin-bottom: 1.5rem;
    }

    .header-actions {
        display: flex;
        gap: 0.5rem;
    }

    .header-actions .btn-primary {
        flex: 1;
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }

    /* Logo */
    .logo {
        font-size: 1.25rem;
        text-align: center;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .stat-item {
        padding: 1rem;
    }

    .stat-label {
        font-size: 0.65rem;
        margin-bottom: 0.35rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* Cards */
    .card {
        padding: 1rem;
        border-radius: 10px;
    }

    .card:hover {
        transform: none;
    }

    /* Dashboard chart header */
    .card > div:first-child {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .card h3 {
        font-size: 0.85rem !important;
    }

    .chart-controls {
        gap: 0.25rem;
        flex-wrap: wrap;
    }

    .range-btn {
        font-size: 0.6rem;
        padding: 0.2rem 0.45rem;
    }

    #liveSpeedText {
        font-size: 0.85rem !important;
        width: 100%;
        text-align: right;
    }

    /* Table — HIDDEN on mobile */
    .table-container {
        display: none !important;
    }

    /* Mobile cards — SHOWN on mobile */
    #mobileUserList {
        display: flex !important;
    }

    /* Card header (Ваши клиенты) */
    .card-header {
        flex-direction: column !important;
        gap: 0.75rem !important;
        align-items: stretch !important;
    }

    .card-header h2 {
        font-size: 1.1rem !important;
    }

    .card-header > div {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }

    .card-header .search-container {
        flex: 1;
        min-width: 0;
    }

    .card-header .search-container input {
        width: 100% !important;
    }

    .card-header .form-select {
        width: auto !important;
        min-width: 90px !important;
        flex-shrink: 0;
    }

    /* Server chart card */
    .stats-grid .card[style*="grid-column: span 2"] {
        grid-column: span 2;
    }

    /* Modals */
    .modal {
        padding: 0.75rem !important;
        align-items: flex-end !important;
    }

    .modal > .card {
        max-width: 100% !important;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        padding: 1.5rem 1.2rem 2rem;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }

    .modal h2 {
        font-size: 1.15rem;
    }

    .modal .form-input,
    .modal .form-select,
    .modal textarea {
        font-size: 1rem;
        padding: 0.9rem 1rem;
    }

    .modal .btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    /* Logs table mobile */
    .logs-container {
        max-height: 60vh;
    }

    .logs-table td,
    .logs-table th {
        font-size: 0.65rem;
        padding: 0.4rem 0.3rem;
    }

    /* QR Modal */
    #qrModal .card {
        text-align: center;
    }

    /* Traffic Modal chart */
    #trafficModal .card div[style*="height: 300px"] {
        height: 200px !important;
    }

    /* Toast */
    #toastContainer {
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
    }

    .toast {
        padding: 12px 20px;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    /* Custom select */
    .custom-select {
        min-width: 100px;
    }

    /* IP stepper in create modal */
    .ip-stepper-create {
        flex-wrap: nowrap;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    .container {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .mobile-user-card {
        padding: 0.75rem;
    }

    .mobile-user-card .card-name {
        font-size: 0.85rem;
    }

    .user-detail-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Force QR code sharpness */
#qrcode canvas, #qrcode img {
    width: 256px !important;
    height: 256px !important;
    display: block;
    image-rendering: optimizeSpeed;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
}
/* Tabs System */
.tabs-header {
    display: flex;
    gap: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.8rem 0;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: chartFadeIn 0.4s ease;
}

@keyframes chartFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
