/* ============================================================
   MMTM - Multi Mikrotik Traffic Monitor
   Main Stylesheet - Elegant Dark/Light Theme
   ============================================================ */

:root {
    --primary: #00d4ff;
    --primary-dark: #0098cc;
    --primary-light: #66e3ff;
    --success: #00e676;
    --warning: #ffc107;
    --danger: #ff5252;
    --info: #40c4ff;

    --bg-primary: #0a192f;
    --bg-secondary: #112240;
    --bg-tertiary: #1a2d4a;
    --bg-card: #152a45;
    --bg-hover: #1d3557;
    --bg-input: #1a2d4a;

    --text-primary: #e6f1ff;
    --text-secondary: #8892b0;
    --text-muted: #5a6a8a;
    --text-inverse: #0a192f;

    --border: #1d3557;
    --border-light: #26466d;

    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px rgba(0,212,255,0.15);
    --shadow-card: 0 4px 24px rgba(0,0,0,0.2);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-hover: #e8eaed;
    --bg-input: #f0f2f5;

    --text-primary: #1a1a2e;
    --text-secondary: #555770;
    --text-muted: #8e90a6;
    --text-inverse: #ffffff;

    --border: #e0e2e8;
    --border-light: #c4c7d0;

    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
    --shadow-glow: 0 0 20px rgba(0,212,255,0.1);
    --shadow-card: 0 2px 16px rgba(0,0,0,0.06);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: var(--transition);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    border: none;
}

/* ============================================================
   PRELOADER
   ============================================================ */
#preloader {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.5s, visibility 0.5s;
}

#preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-ring {
    width: 60px;
    height: 60px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0d1f3c 100%);
    padding: 20px;
}

.auth-container {
    display: flex;
    max-width: 1000px;
    width: 100%;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.auth-left {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--bg-primary) 100%);
    padding: 60px 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-left::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(0,212,255,0.1) 0%, transparent 70%);
    top: -50px;
    right: -50px;
    border-radius: 50%;
}

.auth-left::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(0,212,255,0.08) 0%, transparent 70%);
    bottom: -30px;
    left: -30px;
    border-radius: 50%;
}

.auth-brand {
    text-align: center;
    position: relative;
    z-index: 1;
}

.brand-icon {
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 2.5rem;
    color: var(--primary);
    border: 2px solid rgba(0,212,255,0.3);
    box-shadow: var(--shadow-glow);
}

.auth-brand h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.brand-subtitle {
    color: rgba(255,255,255,0.7);
    font-size: 1rem;
    margin-bottom: 32px;
}

.brand-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.brand-features span {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
}

.brand-features i {
    color: var(--primary);
    width: 20px;
    text-align: center;
}

.auth-right {
    flex: 1;
    padding: 60px 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-form-wrapper {
    width: 100%;
    max-width: 380px;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 32px;
}

.auth-tab {
    flex: 1;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
    font-size: 0.9rem;
}

.auth-tab.active {
    background: var(--primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-glow);
}

.auth-form { display: none; }
.auth-form.active { display: block; }

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group label i {
    margin-right: 6px;
    color: var(--primary);
}

.form-group input, .form-input, .select-styled {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-group input:focus, .form-input:focus, .select-styled:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,212,255,0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 44px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    padding: 4px;
    transition: var(--transition);
}

.toggle-password:hover { color: var(--primary); }

.form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(255,82,82,0.1);
    border-radius: var(--radius-sm);
    display: none;
}

.form-error.show { display: block; }

.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    border: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-full { width: 100%; }

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-danger {
    background: rgba(255,82,82,0.15);
    color: var(--danger);
    border: 1px solid transparent;
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}

.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-link span { display: none; }
.sidebar.collapsed .sidebar-user { padding: 12px; justify-content: center; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
}

.sidebar-logo i { font-size: 1.5rem; }

.sidebar-toggle {
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px;
    transition: var(--transition);
}

.sidebar-toggle:hover { color: var(--primary); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 16px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,212,255,0.3);
}

.logout-link {
    color: var(--danger);
}

.logout-link:hover {
    background: rgba(255,82,82,0.1);
    color: var(--danger);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.sidebar.collapsed + .main-content,
.sidebar.collapsed ~ .main-content {
    margin-left: 72px;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu-btn {
    display: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    padding: 4px;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.server-time {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.theme-switch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.theme-switch:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================================
   PAGES CONTAINER
   ============================================================ */
.pages-container {
    padding: 24px 32px;
}

.page-content { display: none; }
.page-content.active { display: block; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.header-search {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.header-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.header-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,212,255,0.1);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), transparent);
}

.stat-card:hover {
    box-shadow: var(--shadow-card);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 16px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card.loading .stat-loader {
    height: 100px;
    background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--bg-hover) 50%, var(--bg-tertiary) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Color variants */
.stat-card.primary::before { background: var(--primary); }
.stat-card.primary .stat-icon { background: rgba(0,212,255,0.15); color: var(--primary); }
.stat-card.primary .stat-value { color: var(--primary); }

.stat-card.success::before { background: var(--success); }
.stat-card.success .stat-icon { background: rgba(0,230,118,0.15); color: var(--success); }
.stat-card.success .stat-value { color: var(--success); }

.stat-card.warning::before { background: var(--warning); }
.stat-card.warning .stat-icon { background: rgba(255,193,7,0.15); color: var(--warning); }
.stat-card.warning .stat-value { color: var(--warning); }

.stat-card.danger::before { background: var(--danger); }
.stat-card.danger .stat-icon { background: rgba(255,82,82,0.15); color: var(--danger); }
.stat-card.danger .stat-value { color: var(--danger); }

/* ============================================================
   SERVER CARDS
   ============================================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header h3 i { color: var(--primary); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.select-sm {
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
}

.last-update {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.server-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.server-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.server-card:hover {
    box-shadow: var(--shadow-card);
    border-color: var(--primary);
}

.server-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.server-card-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.server-card-name i { color: var(--primary); }

.server-card-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.server-card-status.online { background: var(--success); box-shadow: 0 0 8px rgba(0,230,118,0.5); }
.server-card-status.offline { background: var(--danger); box-shadow: 0 0 8px rgba(255,82,82,0.5); }

.server-card-traffic {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.traffic-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.traffic-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.traffic-item .value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}

.traffic-item.tx .value { color: var(--warning); }

.server-card-interfaces {
    margin-top: 16px;
}

.interface-mini {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.interface-mini:last-child { border-bottom: none; }

.interface-mini .name { color: var(--text-secondary); }
.interface-mini .speed { font-family: var(--font-mono); font-size: 0.8rem; }
.interface-mini .speed.rx { color: var(--primary); }
.interface-mini .speed.tx { color: var(--warning); }

.server-card-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* ============================================================
   DATA TABLES
   ============================================================ */
.table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-tertiary);
}

.data-table th {
    padding: 14px 20px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 20px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(0,230,118,0.15); color: var(--success); }
.badge-danger { background: rgba(255,82,82,0.15); color: var(--danger); }
.badge-warning { background: rgba(255,193,7,0.15); color: var(--warning); }
.badge-info { background: rgba(0,212,255,0.15); color: var(--primary); }

.action-btns {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
    font-size: 0.85rem;
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.action-btn.danger:hover {
    background: rgba(255,82,82,0.1);
    color: var(--danger);
}

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.chart-lg { height: 400px; }

.monitor-controls, .history-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.monitor-selects, .history-selects {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.monitor-interfaces {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
}

.monitor-interface-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.monitor-interface-card .iface-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.monitor-interface-card .iface-stats {
    display: flex;
    gap: 16px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.monitor-interface-card .iface-rx { color: var(--primary); }
.monitor-interface-card .iface-tx { color: var(--warning); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.1rem; font-weight: 600; }

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.modal-body .form-group input,
.modal-body .form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.modal-body .form-group input:focus,
.modal-body .form-group select:focus {
    border-color: var(--primary);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
    font-size: 0.9rem;
}

.toast i { font-size: 1.1rem; }
.toast.success { border-left: 3px solid var(--success); }
.toast.success i { color: var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.error i { color: var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.warning i { color: var(--warning); }
.toast.info { border-left: 3px solid var(--primary); }
.toast.info i { color: var(--primary); }

.toast.hiding {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.settings-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
}

.settings-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-card h3 i { color: var(--primary); }

.db-stats {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.stat-item:last-child { border-bottom: none; }

.stat-item span { color: var(--text-secondary); font-size: 0.9rem; }
.stat-item strong { color: var(--text-primary); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.page-btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    transition: var(--transition);
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 992px) {
    :root { --sidebar-width: 72px; }
    .logo-text, .user-info, .nav-link span { display: none; }
    .sidebar-user { padding: 12px; justify-content: center; }
    .nav-link { justify-content: center; padding: 12px; }
    
    .auth-container { flex-direction: column; max-width: 480px; }
    .auth-left { padding: 40px 30px; }
    .auth-right { padding: 40px 30px; }
    .brand-features { display: none; }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.mobile-open .logo-text,
    .sidebar.mobile-open .user-info,
    .sidebar.mobile-open .nav-link span,
    .sidebar.mobile-open .sidebar-user { display: flex; }
    
    .sidebar.mobile-open .nav-link { justify-content: flex-start; padding: 10px 20px; }
    .sidebar.mobile-open .sidebar-user { padding: 16px 20px; justify-content: flex-start; }
    
    .main-content { margin-left: 0; }
    
    .mobile-menu-btn { display: block; }
    
    .topbar { padding: 0 16px; }
    .pages-container { padding: 16px; }
    
    .stats-grid { grid-template-columns: 1fr; gap: 12px; }
    .server-cards { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    
    .page-header { flex-direction: column; align-items: stretch; }
    .header-search { max-width: 100%; }
    
    .monitor-controls, .history-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .monitor-selects, .history-selects {
        flex-direction: column;
    }
    
    .data-table {
        font-size: 0.8rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 12px;
    }
    
    .action-btns { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .auth-container { border-radius: var(--radius); }
    .auth-right { padding: 30px 20px; }
    .auth-left { padding: 30px 20px; }
    .auth-brand h1 { font-size: 2rem; }
    .brand-icon { width: 60px; height: 60px; font-size: 2rem; }
    
    .stat-card .stat-value { font-size: 1.4rem; }
    .server-cards { grid-template-columns: 1fr; }
    .monitor-interfaces { grid-template-columns: 1fr; }
}

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    vertical-align: middle;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 24px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-slider.active {
    background: var(--success);
    border-color: var(--success);
}

.toggle-slider.active::before {
    transform: translateX(20px);
    background: #fff;
}

.toggle-slider.inactive {
    background: var(--danger);
    border-color: var(--danger);
    opacity: 0.4;
}

.toggle-slider.inactive::before {
    background: #fff;
}

/* ============================================================
   INTERFACE CHECKBOX LIST
   ============================================================ */
.interface-checklist {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    background: var(--bg-input);
}

.interface-checklist::-webkit-scrollbar { width: 3px; }
.interface-checklist::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.iface-check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    transition: var(--transition);
    cursor: pointer;
}

.iface-check-item:hover {
    background: var(--bg-hover);
}

.iface-check-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.iface-check-item label {
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
}

.iface-check-item .iface-status {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.iface-check-item .iface-status.running {
    background: var(--success);
}

.iface-check-item .iface-status.stopped {
    background: var(--danger);
}

.iface-mini-bar {
    display: flex;
    gap: 2px;
    margin-top: 6px;
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    background: var(--bg-primary);
}

.bar-mini {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.bar-mini.rx {
    background: var(--primary);
}

.bar-mini.tx {
    background: var(--warning);
}

/* ============================================================
   BAR CHART TRAFFIC
   ============================================================ */
.chart-container.bar-mode {
    min-height: 300px;
}

.traffic-speed-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.speed-bar-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.speed-bar-item .label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.speed-bar-item .speed-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
}

.speed-bar-item.download .speed-value { color: var(--primary); }
.speed-bar-item.upload .speed-value { color: var(--warning); }

.speed-bar-item .bar-track {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    margin-top: 12px;
    overflow: hidden;
}

.speed-bar-item .bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.speed-bar-item.download .bar-fill {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.speed-bar-item.upload .bar-fill {
    background: linear-gradient(90deg, var(--warning), #ff9800);
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--border-light);
}

.empty-state p {
    font-size: 1rem;
}

.empty-state a {
    color: var(--primary);
    text-decoration: underline;
}

.code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
}

.text-center {
    text-align: center;
}

::selection {
    background: var(--primary);
    color: var(--text-inverse);
}
