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

:root {
  --bg: #131a20;
  --bg2: #0e1621;
  --card: #1b2a38;
  --card2: #162030;
  --border: #1e3a4a;
  --border2: #1a2535;
  --text: #f1f5f9;
  --muted: #8fa3b1;
  --muted2: #4a6380;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --blue-glow: rgba(59,130,246,0.15);
  --purple: #8b5cf6;
  --amber: #f59e0b;
  --green: #1fab89;
  --red: #ef4444;
  --green-bg: rgba(31,171,137,0.1);
  --red-bg: rgba(239,68,68,0.1);
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

.hidden { display: none !important; }

/* ── LOGIN ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 60% 30%, rgba(37,99,235,0.12) 0%, transparent 60%), var(--bg); }
.login-card { width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 40px 36px; }
.login-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 8px; }
.login-brand { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); }
.login-subtitle { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.login-server { text-align: center; color: var(--muted2); font-size: 12px; margin-bottom: 28px; background: var(--bg2); border: 1px solid var(--border2); border-radius: 6px; padding: 6px 12px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.form-group input { width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-size: 14px; outline: none; transition: border-color 0.15s; }
.form-group input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.login-error { color: var(--red); font-size: 13px; margin-bottom: 12px; background: var(--red-bg); border: 1px solid rgba(239,68,68,0.2); border-radius: 6px; padding: 8px 12px; }
.btn-full { width: 100%; }

/* ── PANEL LAYOUT ── */
.panel { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── TOPBAR ── */
.topbar { background: var(--bg2); border-bottom: 1px solid var(--border2); height: 52px; display: flex; align-items: center; padding: 0 20px; gap: 24px; flex-shrink: 0; z-index: 100; }
.topbar-left { display: flex; align-items: center; gap: 20px; flex: 1; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--text); flex-shrink: 0; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted2); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .active { color: var(--blue); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.server-badge { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; font-size: 12px; color: var(--muted); }
.topbar-meta { display: flex; gap: 8px; }
.topbar-meta span { background: var(--bg); border: 1px solid var(--border2); border-radius: 5px; padding: 4px 9px; font-size: 11px; color: var(--muted2); font-family: 'JetBrains Mono', monospace; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse-green 2s infinite; }
.status-dot.red { background: var(--red); }
@keyframes pulse-green { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* ── MAIN LAYOUT ── */
.layout { display: flex; flex: 1; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar { width: 220px; background: var(--bg2); border-right: 1px solid var(--border2); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; padding-bottom: 16px; }
.server-card { margin: 12px; background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.server-card-name { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.server-card-ip { font-size: 11px; color: var(--muted2); margin-bottom: 12px; font-family: 'JetBrains Mono', monospace; }
.server-ctrl-btns { display: flex; gap: 6px; }
.ctrl-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid transparent; border-radius: 6px; padding: 6px 4px; font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.ctrl-btn.green { background: rgba(31,171,137,0.12); border-color: rgba(31,171,137,0.3); color: var(--green); }
.ctrl-btn.green:hover { background: rgba(31,171,137,0.22); }
.ctrl-btn.red { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.25); color: var(--red); }
.ctrl-btn.red:hover { background: rgba(239,68,68,0.2); }
.ctrl-btn.gray { flex: 0 0 36px; background: var(--card); border-color: var(--border); color: var(--muted); }
.ctrl-btn.gray:hover { background: var(--border); color: var(--text); }

.nav { padding: 4px 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted2); font-size: 13px; cursor: pointer; transition: all 0.15s; text-decoration: none; border-left: 2px solid transparent; margin-bottom: 2px; }
.nav-item:hover { background: var(--card2); color: var(--muted); }
.nav-item.active { background: var(--blue-glow); border-left-color: var(--blue); color: var(--text); font-weight: 500; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-divider { height: 1px; background: var(--border2); margin: 8px 4px; }

/* ── CONTENT ── */
.content { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ── PAGES ── */
.page { display: none; }
.page.active { display: block; }

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted2); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 12px; display: flex; align-items: baseline; gap: 3px; }
.stat-unit { font-size: 14px; font-weight: 400; color: var(--muted); }
.stat-bar { height: 4px; background: rgba(255,255,255,0.06); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.stat-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.stat-bar-fill.blue { background: var(--blue); }
.stat-bar-fill.purple { background: var(--purple); }
.stat-bar-fill.amber { background: var(--amber); }
.stat-bar-fill.green { background: var(--green); }
.stat-sub { font-size: 11px; color: var(--muted2); }

/* ── TERMINAL ── */
.terminal-card { background: #0a1628; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.terminal-header { background: var(--bg2); padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border2); }
.terminal-dots { display: flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }
.terminal-title { font-size: 12px; color: var(--muted2); margin-left: 10px; }
.terminal-actions { display: flex; gap: 6px; }
#terminal-container { padding: 12px; min-height: 380px; }
#terminal-container .xterm { height: 380px; }
.terminal-input-row { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border2); background: var(--bg2); }
.terminal-prompt { color: var(--green); font-family: 'JetBrains Mono', monospace; font-size: 12px; white-space: nowrap; }
#cmd-input { flex: 1; background: transparent; border: none; color: var(--text); font-size: 12px; font-family: 'JetBrains Mono', monospace; outline: none; }
#cmd-input::placeholder { color: var(--muted2); }

/* ── FILES ── */
.files-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.breadcrumb-path { background: var(--card2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; font-size: 12px; font-family: 'JetBrains Mono', monospace; color: var(--muted); flex: 1; }
.files-toolbar-right { display: flex; gap: 8px; }
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table-header { display: grid; grid-template-columns: 1fr 90px 120px 100px; padding: 10px 18px; background: var(--bg2); border-bottom: 1px solid var(--border2); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted2); }
.services-header { grid-template-columns: 180px 80px 80px 1fr 130px; }
.file-row, .service-row { display: grid; padding: 12px 18px; border-bottom: 1px solid var(--border2); align-items: center; transition: background 0.1s; cursor: pointer; }
.file-row { grid-template-columns: 1fr 90px 120px 100px; }
.service-row { grid-template-columns: 180px 80px 80px 1fr 130px; cursor: default; }
.file-row:last-child, .service-row:last-child { border-bottom: none; }
.file-row:hover { background: rgba(59,130,246,0.04); }
.file-name { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text); }
.file-name.dir { color: var(--blue); }
.file-icon { width: 18px; flex-shrink: 0; opacity: 0.7; }
.file-meta { font-size: 12px; color: var(--muted2); }
.row-actions { display: flex; gap: 5px; }

/* ── SERVICES ── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge.active { background: var(--green-bg); color: var(--green); }
.badge.inactive { background: var(--red-bg); color: var(--red); }
.badge.other { background: rgba(255,255,255,0.05); color: var(--muted); }
.service-name { font-size: 12px; font-family: 'JetBrains Mono', monospace; color: var(--text); }
.service-desc { font-size: 12px; color: var(--muted2); }

/* ── NETWORK / INFO ── */
.page-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.page-title { font-size: 18px; font-weight: 600; color: var(--text); }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.info-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.info-card-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted2); margin-bottom: 14px; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border2); }
.info-row:last-child { border-bottom: none; }
.info-key { font-size: 12px; color: var(--muted); }
.info-val { font-size: 12px; color: var(--text); font-family: 'JetBrains Mono', monospace; }
.info-val.tag { background: var(--blue-glow); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); border-radius: 4px; padding: 1px 8px; }
.logs-service-sel { display: flex; gap: 8px; align-items: center; }
.select { background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 6px 10px; font-size: 13px; font-family: inherit; outline: none; cursor: pointer; }
.log-card { background: #0a1628; border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.log-card pre { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); white-space: pre-wrap; word-break: break-all; max-height: 500px; overflow-y: auto; }

/* ── SETTINGS ── */
.settings-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.quick-cmds { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.quick-cmds .btn.full { justify-content: flex-start; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 7px; padding: 8px 14px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; font-family: inherit; white-space: nowrap; }
.btn-primary { background: var(--blue-dark); color: #fff; }
.btn-primary:hover { background: var(--blue); }
.btn-ghost { background: var(--card); border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ── MODAL ── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(3px); }
.modal-card { position: relative; z-index: 1; background: var(--card); border: 1px solid var(--border); border-radius: 12px; width: 520px; max-height: 80vh; display: flex; flex-direction: column; }
.modal-card.wide { width: 760px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border2); font-weight: 600; font-size: 14px; }
.modal-actions { display: flex; gap: 8px; }
.modal-body { padding: 18px; }
.modal-footer { padding: 14px 18px; border-top: 1px solid var(--border2); display: flex; gap: 8px; justify-content: flex-end; }
.code-editor { width: 100%; min-height: 420px; background: #0a1628; border: none; color: #e2e8f0; font-family: 'JetBrains Mono', monospace; font-size: 12px; padding: 14px; resize: vertical; outline: none; border-radius: 0 0 12px 12px; }

/* ── TOAST ── */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 18px; font-size: 13px; color: var(--text); z-index: 9999; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
