/* ==================== RESET & BASE ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg-primary: #1a1d23;
    --bg-secondary: #22262e;
    --bg-tertiary: #2a2f38;
    --bg-hover: #323842;
    --bg-active: #3a4150;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #6b7280;
    --accent: #00b4d8;
    --accent-hover: #0096c7;
    --accent-dim: rgba(0, 180, 216, 0.15);
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #ef4444;
    --border: #363b44;
    --shadow: rgba(0,0,0,0.3);
    --radius: 6px;
    --sidebar-width: 260px;
    --panel-width: 320px;
}
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); height: 100vh; overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
input, textarea, select { font-family: inherit; }

/* ==================== LOGIN ==================== */
.login-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(135deg, #1a1d23 0%, #0d1117 100%); }
.login-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px; padding: 40px; width: 400px; box-shadow: 0 20px 60px var(--shadow); }
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo i { font-size: 48px; color: var(--accent); margin-bottom: 12px; }
.login-logo h1 { font-size: 24px; font-weight: 600; }
.login-logo p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.form-group input { width: 100%; padding: 10px 14px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-primary); font-size: 14px; outline: none; transition: border-color 0.2s; }
.form-group input:focus { border-color: var(--accent); }
.btn-primary { width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { width: 100%; padding: 12px; background: var(--danger); color: #fff; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; }
.login-toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-secondary); }
.error-msg { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; }

/* ==================== DASHBOARD LAYOUT ==================== */
.dashboard { display: flex; height: 100vh; }

/* ==================== SIDEBAR ==================== */
.sidebar { width: var(--sidebar-width); background: var(--bg-secondary); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 10px; }
.logo i { font-size: 24px; color: var(--accent); }
.logo span { font-size: 18px; font-weight: 700; }
.sidebar-nav { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); color: var(--text-secondary); font-size: 14px; transition: all 0.15s; cursor: pointer; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item i { width: 20px; text-align: center; }
.sidebar-section { padding: 12px 10px; border-bottom: 1px solid var(--border); }
.build-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; background: var(--accent); color: #fff; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.build-btn:hover { background: var(--accent-hover); }

/* ==================== SIDEBAR FILTERS ==================== */
.sidebar-filters { flex: 1; overflow-y: auto; padding: 8px 0; }
.filter-group { border-bottom: 1px solid var(--border); }
.filter-header { display: flex; align-items: center; gap: 8px; padding: 10px 16px; cursor: pointer; font-size: 13px; color: var(--text-secondary); transition: background 0.15s; }
.filter-header:hover { background: var(--bg-hover); }
.filter-header i { font-size: 10px; transition: transform 0.2s; width: 12px; }
.filter-header.open i { transform: rotate(90deg); }
.filter-count { margin-left: auto; background: var(--bg-tertiary); padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.filter-items { display: none; padding: 0 10px 8px 36px; }
.filter-items.open { display: block; }
.filter-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; font-size: 13px; color: var(--text-secondary); cursor: pointer; transition: background 0.15s; }
.filter-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.filter-item.active-filter { color: var(--accent); background: var(--accent-dim); }
.filter-sub-item { padding: 6px 12px; font-size: 12px; color: var(--text-muted); cursor: pointer; border-radius: 4px; }
.filter-sub-item:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ==================== SIDEBAR FOOTER ==================== */
.sidebar-footer { border-top: 1px solid var(--border); padding: 8px 10px; }
.user-info { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-radius: var(--radius); }
.user-info:hover { background: var(--bg-hover); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-dim); display: flex; align-items: center; justify-content: center; color: var(--accent); }

/* ==================== MAIN CONTENT ==================== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ==================== TOOLBAR ==================== */
.toolbar { display: flex; align-items: center; padding: 12px 20px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); gap: 16px; }
.toolbar-left { display: flex; align-items: baseline; gap: 12px; }
.toolbar-left h2 { font-size: 18px; font-weight: 600; }
.toolbar-subtitle { font-size: 13px; color: var(--text-secondary); }
.toolbar-actions { display: flex; gap: 4px; margin-left: 20px; }
.toolbar-btn { display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: transparent; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: all 0.15s; }
.toolbar-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); border-color: var(--text-muted); }
.toolbar-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.toolbar-search { margin-left: auto; display: flex; align-items: center; gap: 8px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; }
.toolbar-search i { color: var(--text-muted); font-size: 13px; }
.toolbar-search input { background: transparent; border: none; color: var(--text-primary); padding: 8px 0; font-size: 13px; outline: none; width: 200px; }

/* ==================== DEVICE LIST ==================== */
.device-list { flex: 1; overflow-y: auto; padding: 0; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); }
.empty-state i { font-size: 64px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* Device Row */
.device-row { display: flex; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; user-select: none; }
.device-row:hover { background: var(--bg-hover); }
.device-row.selected { background: var(--accent-dim); }
.device-row.offline { opacity: 0.6; }
.device-checkbox { width: 20px; height: 20px; margin-right: 12px; accent-color: var(--accent); cursor: pointer; }
.device-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; margin-right: 14px; color: var(--text-secondary); font-size: 16px; }
.device-info { flex: 1; min-width: 0; }
.device-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; display: flex; gap: 8px; }
.device-session { font-size: 12px; color: var(--text-muted); min-width: 100px; text-align: right; }
.device-status-indicators { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; }
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--text-muted); }
.device-bars { display: flex; gap: 3px; align-items: flex-end; height: 20px; }
.device-bar { width: 4px; border-radius: 2px; transition: height 0.3s, background 0.3s; }
.device-bar.cpu { background: var(--accent); }
.device-bar.ram { background: var(--success); }
.device-bar.disk { background: var(--warning); }
.device-monitor { width: 28px; height: 22px; border: 2px solid var(--success); border-radius: 3px; position: relative; }
.device-monitor.offline-monitor { border-color: var(--text-muted); }
.device-monitor::after { content: ''; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%); width: 12px; height: 3px; background: inherit; border-radius: 0 0 2px 2px; }

/* ==================== RIGHT PANEL ==================== */
.right-panel { width: var(--panel-width); background: var(--bg-secondary); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-header h3 { font-size: 16px; font-weight: 600; }
.panel-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 4px; }
.panel-close:hover { color: var(--text-primary); }
.panel-tabs { display: flex; border-bottom: 1px solid var(--border); }
.panel-tab { flex: 1; padding: 10px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: all 0.15s; }
.panel-tab:hover { color: var(--text-primary); }
.panel-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.panel-content { padding: 16px 20px; }
.panel-field { margin-bottom: 14px; }
.panel-field label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.panel-field span { font-size: 14px; }
.panel-field.editable input { width: 100%; padding: 6px 10px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 4px; color: var(--text-primary); font-size: 13px; outline: none; }
.panel-field.editable input:focus { border-color: var(--accent); }
.panel-actions { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.action-btn { flex: 1; min-width: calc(50% - 4px); padding: 8px 12px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-primary); font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.15s; }
.action-btn:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.action-btn.danger { color: var(--danger); }
.action-btn.danger:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); }

/* System Meters */
.system-meters { display: flex; flex-direction: column; gap: 16px; }
.meter { display: flex; align-items: center; gap: 10px; }
.meter label { font-size: 12px; color: var(--text-secondary); width: 40px; }
.meter-bar { flex: 1; height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.5s; }
.meter span { font-size: 12px; color: var(--text-secondary); width: 40px; text-align: right; }
#panelNotes textarea { width: 100%; height: 200px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-primary); padding: 10px; font-size: 13px; resize: vertical; outline: none; }

/* ==================== CONTEXT MENU ==================== */
.context-menu { position: fixed; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 6px 0; min-width: 220px; box-shadow: 0 8px 30px var(--shadow); z-index: 1000; }
.context-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 13px; color: var(--text-primary); cursor: pointer; transition: background 0.1s; }
.context-item:hover { background: var(--accent-dim); color: var(--accent); }
.context-item.danger { color: var(--danger); }
.context-item.danger:hover { background: rgba(239,68,68,0.1); }
.context-item i { width: 16px; text-align: center; font-size: 12px; }
.context-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ==================== MODALS ==================== */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 900; }
.modal-content { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px; width: 500px; max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 4px; }
.modal-close:hover { color: var(--text-primary); }

/* Terminal Modal */
.terminal-modal { width: 800px; max-height: 600px; }
.terminal-body { background: #0d1117; padding: 12px; height: 400px; overflow-y: auto; font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace; font-size: 13px; line-height: 1.5; color: #c9d1d9; white-space: pre-wrap; word-wrap: break-word; }
.terminal-input-row { display: flex; align-items: center; padding: 8px 12px; background: #0d1117; border-top: 1px solid var(--border); }
.terminal-prompt { color: var(--accent); font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 13px; margin-right: 8px; }
.terminal-input-row input { flex: 1; background: transparent; border: none; color: #c9d1d9; font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 13px; outline: none; }

/* File Manager Modal */
.file-modal { width: 700px; max-height: 600px; }
.file-path-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-tertiary); border-bottom: 1px solid var(--border); }
.file-path-bar button { background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--text-secondary); padding: 6px 10px; cursor: pointer; }
.file-path-bar button:hover { background: var(--bg-hover); }
.file-path-bar input { flex: 1; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 4px; color: var(--text-primary); padding: 6px 10px; font-size: 13px; outline: none; }
.file-list-container { height: 400px; overflow-y: auto; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; font-size: 13px; transition: background 0.1s; }
.file-row:hover { background: var(--bg-hover); }
.file-row i { width: 20px; text-align: center; }
.file-row .file-name { flex: 1; }
.file-row .file-size { color: var(--text-muted); font-size: 12px; width: 80px; text-align: right; }
.file-row .file-date { color: var(--text-muted); font-size: 12px; width: 140px; text-align: right; }

/* Deploy Modal */
.deploy-modal { width: 500px; }
.deploy-body { padding: 20px; }
.deploy-device-list { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.deploy-device-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
.deploy-device-item:last-child { border-bottom: none; }

/* Remote Desktop - now uses inline styles on #remoteOverlay */

/* Build Modal */
.build-body, .settings-body { padding: 20px; }
.token-display { display: flex; align-items: center; gap: 8px; background: var(--bg-tertiary); padding: 12px; border-radius: var(--radius); margin: 12px 0; }
.token-display code { flex: 1; font-family: 'Consolas', monospace; font-size: 13px; color: var(--accent); word-break: break-all; }
.token-display button { background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--text-secondary); padding: 6px 10px; cursor: pointer; }
.token-display button:hover { background: var(--bg-hover); }
.help-text { font-size: 13px; color: var(--text-muted); }

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius); font-size: 13px; color: #fff; animation: slideIn 0.3s ease; box-shadow: 0 4px 12px var(--shadow); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Remote Desktop overlay styles handled inline */

/* ==================== SYSTEM INFO SECTIONS ==================== */
.info-section { background: var(--bg-primary); border-radius: var(--radius); padding: 8px 12px; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; min-width: 80px; }
.info-value { font-size: 12px; color: var(--text-primary); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }

/* Settings Tabs */
.settings-tab { background: none; border: none; color: #888; padding: 10px 16px; cursor: pointer; font-size: 13px; font-weight: 500; border-bottom: 2px solid transparent; transition: all 0.2s; }
.settings-tab:hover { color: #ccc; }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-panel { padding: 16px 20px 20px; }
.btn-secondary { padding: 10px 16px; background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.crypto-select.active { background: var(--accent); color: #fff; border-color: var(--accent); }
