
:root {
    --primary: #2563eb; --primary-dark: #1d4ed8; --primary-light: #3b82f6;
    --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --info: #06b6d4;
    --bg: #f8fafc; --bg-card: #ffffff; --bg-sidebar: #0f172a;
    --text: #1e293b; --text-secondary: #64748b; --text-muted: #94a3b8;
    --border: #e2e8f0; --shadow: 0 1px 3px rgba(0,0,0,.1);
    --radius: 8px; --sidebar-width: 260px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
[data-theme="dark"] {
    --bg: #0f172a; --bg-card: #1e293b; --bg-sidebar: #020617;
    --text: #f1f5f9; --text-secondary: #94a3b8; --text-muted: #64748b;
    --border: #334155; --shadow: 0 1px 3px rgba(0,0,0,.3);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-width); background: var(--bg-sidebar); color: #e2e8f0; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; transition: transform .3s; }
.sidebar-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 12px; }
.sidebar-header svg { width: 32px; height: 32px; color: var(--primary-light); }
.sidebar-header h1 { font-size: 18px; font-weight: 700; color: #fff; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section { padding: 8px 20px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 20px; color: #94a3b8; cursor: pointer; transition: all .15s; font-size: 14px; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.nav-item.active { background: rgba(37,99,235,.15); color: #60a5fa; border-left-color: var(--primary-light); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 10px; }

/* Main Content */
.main { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }

/* Topbar */
.topbar { height: 64px; background: var(--bg-card); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 40; }
.topbar-search { flex: 1; max-width: 480px; position: relative; }
.topbar-search input { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); font-size: 14px; }
.topbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; color: var(--text-secondary); }
.topbar-btn:hover { background: var(--border); }
.topbar-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid var(--bg-card); }
.user-menu { display: flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: var(--radius); cursor: pointer; }
.user-menu:hover { background: var(--bg); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.user-info { display: none; }
@media(min-width:768px) { .user-info { display: block; } }
.user-info .name { font-size: 13px; font-weight: 600; }
.user-info .role { font-size: 11px; color: var(--text-muted); }

/* Content */
.content { padding: 24px; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 24px; font-weight: 700; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { padding: 20px; }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.stat-card .stat-change { font-size: 12px; margin-top: 8px; }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { padding: 10px 16px; text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); border-bottom: 2px solid var(--border); background: var(--bg); }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: rgba(37,99,235,.03); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-online, .badge-success { background: rgba(16,185,129,.1); color: #059669; }
.badge-offline, .badge-danger { background: rgba(239,68,68,.1); color: #dc2626; }
.badge-warning { background: rgba(245,158,11,.1); color: #d97706; }
.badge-critical { background: rgba(239,68,68,.15); color: #dc2626; font-weight: 600; }
.badge-info { background: rgba(6,182,212,.1); color: #0891b2; }
.badge-pending { background: rgba(107,114,128,.1); color: #6b7280; }
.badge-maintenance { background: rgba(139,92,246,.1); color: #7c3aed; }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; }
.badge-dot.online { background: var(--success); }
.badge-dot.offline { background: var(--danger); }
.badge-dot.warning { background: var(--warning); }
.badge-dot.critical { background: var(--danger); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1;}50%{opacity:.5;} }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text-secondary); }
.form-input, .form-select, .form-textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; background: var(--bg-card); color: var(--text); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; display: none; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-card); border-radius: 12px; width: 90%; max-width: 560px; max-height: 90vh; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--bg); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.modal-body { padding: 20px; overflow-y: auto; max-height: 60vh; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media(max-width:1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media(max-width:768px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .sidebar { transform: translateX(-100%); } .sidebar.open { transform: translateX(0); } .main { margin-left: 0; } }

/* Charts container */
.chart-container { position: relative; height: 280px; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 16px; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; color: var(--text-secondary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Toast */
.toast-container { position: fixed; top: 80px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: slideIn .3s; display: flex; align-items: center; gap: 8px; }
.toast-success { background: #065f46; color: #d1fae5; }
.toast-error { background: #991b1b; color: #fee2e2; }
.toast-info { background: #1e40af; color: #dbeafe; }
@keyframes slideIn { from{transform:translateX(100%);opacity:0;}to{transform:translateX(0);opacity:1;} }

/* Loading */
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: absolute; inset: 0; background: rgba(255,255,255,.8); display: flex; align-items: center; justify-content: center; z-index: 10; }
[data-theme="dark"] .loading-overlay { background: rgba(15,23,42,.8); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: .5; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; top: 100%; right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.1); min-width: 180px; z-index: 50; display: none; }
.dropdown-menu.show { display: block; }
.dropdown-item { display: block; padding: 8px 16px; font-size: 14px; color: var(--text); cursor: pointer; }
.dropdown-item:hover { background: var(--bg); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* Drawer */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; display: none; }
.drawer-overlay.active { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 90vw; background: var(--bg-card); z-index: 95; transform: translateX(100%); transition: transform .3s; overflow-y: auto; }
.drawer.active { transform: translateX(0); }
.drawer-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

/* Confirmation dialog */
.confirm-dialog { text-align: center; }
.confirm-dialog .icon { width: 48px; height: 48px; margin: 0 auto 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.confirm-dialog .icon.danger { background: rgba(239,68,68,.1); color: var(--danger); }
.confirm-dialog .icon.warning { background: rgba(245,158,11,.1); color: var(--warning); }

/* Remote Desktop viewer */
.rd-version-badge { font-size: 11px; font-weight: 600; color: #22c55e; background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.25); border-radius: 999px; padding: 2px 8px; }
.rd-toolbar-shell, .rd-toolbar-card { padding: 10px 12px; background: #0f172a; border-bottom: 1px solid #1e293b; }
.rd-toolbar { display: flex; flex-direction: column; gap: 8px; }
.rd-toolbar-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.rd-group { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); border-radius: 8px; min-height: 36px; }
.rd-group-label { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #64748b; white-space: nowrap; }
.rd-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #cbd5e1; white-space: nowrap; margin-right: 8px; }
.rd-select { min-width: 180px; height: 32px; }
.rd-select-sm { width: 92px; height: 32px; }
.rd-range { width: 90px; vertical-align: middle; }
.rd-val { font-size: 12px; color: #94a3b8; min-width: 36px; }
.rd-toolbar-spacer { flex: 1; min-width: 12px; }
.rd-metric { color: #10b981; font-family: ui-monospace, monospace; font-size: 11px; white-space: nowrap; }
.rd-metric.muted { color: #64748b; }
.rd-status { color: #94a3b8; font-size: 12px; min-width: 120px; text-align: right; }
.rd-footer { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 6px 12px; background: #0a0f1a; border-top: 1px solid #1e293b; color: #64748b; font-size: 10px; }
.rd-viewport-card { height: calc(100vh - 260px); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
#remote-desktop-overlay .rd-toolbar-shell { flex-shrink: 0; }
#remote-desktop-overlay .rd-footer { flex-shrink: 0; }
#remote-desktop-overlay [id$="Viewport"] { flex: 1; min-height: 0; }
.rd-canvas-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #000; position: relative; z-index: 2; }
.rd-canvas { display: block; cursor: crosshair; position: relative; z-index: 2; touch-action: none; }
