:root {
  --bg-body: #0b1120;
  --bg-sidebar: #080d1a;
  --bg-card: #111827;
  --bg-card-hover: #162033;
  --bg-input: #0f172a;
  --border: #1e293b;
  --border-light: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.22);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.2);
  --violet: #8b5cf6;
  --violet-glow: rgba(139, 92, 246, 0.2);
  --blue: #3b82f6;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg-body); color: var(--text-main); font-family: var(--font-sans); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--cyan); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }

/* Login Page */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, rgba(6,182,212,0.12), transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(139,92,246,0.12), transparent 45%),
              var(--bg-body);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: 0 24px 64px rgba(0,0,0,0.45);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-logo-icon {
  width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(6,182,212,0.22), rgba(139,92,246,0.22));
  border: 1px solid rgba(6,182,212,0.4); color: var(--cyan);
}
.login-logo h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.login-logo p { font-size: 12px; color: var(--text-muted); }

/* App Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
  transition: transform 0.2s ease;
}
.sidebar-brand {
  height: 64px; padding: 0 20px; display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid var(--border);
}
.brand-badge {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(6,182,212,0.24), rgba(16,185,129,0.18));
  border: 1px solid rgba(6,182,212,0.45); color: var(--cyan);
}
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-radius: 9px;
  color: var(--text-muted); cursor: pointer; border: 1px solid transparent; background: transparent;
  width: 100%; text-align: left; font-weight: 500; transition: all 0.15s ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(30,41,59,0.55); color: var(--text-main); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(6,182,212,0.16), rgba(6,182,212,0.04));
  border-color: rgba(6,182,212,0.32); color: #67e8f9;
}
.nav-item.active svg { color: var(--cyan); opacity: 1; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.lang-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--bg-input); padding: 3px; border-radius: 8px; border: 1px solid var(--border); }
.lang-btn { border: none; background: transparent; color: var(--text-muted); padding: 5px 0; border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: 600; }
.lang-btn.active { background: var(--cyan); color: #04131c; }

/* Main Content */
.main-area { flex: 1; margin-left: 244px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; padding: 0 24px; background: rgba(11,17,32,0.88); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between;
  gap: 16px; position: sticky; top: 0; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.menu-toggle { display: none; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 7px; cursor: pointer; color: var(--text-main); }
.page-title { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.vps-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7;
  font-size: 12px; font-weight: 600;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.dot-gray { background: #475569; }
.dot-red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot-amber { background: var(--amber); }

.sys-mini { display: flex; align-items: center; gap: 10px; padding: 5px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; font-size: 12px; color: var(--text-muted); }
.sys-mini b { color: var(--text-main); font-family: var(--font-mono); }

.content-pad { padding: 22px 24px 36px; display: flex; flex-direction: column; gap: 20px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: 9px; font-weight: 600; font-size: 13px;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s ease; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: linear-gradient(135deg, #06b6d4, #0891b2); color: #03151e; border-color: rgba(103,232,249,0.4); box-shadow: 0 4px 16px rgba(6,182,212,0.22); }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-emerald { background: linear-gradient(135deg, #10b981, #059669); color: #021a12; border-color: rgba(110,231,183,0.4); }
.btn-emerald:hover { filter: brightness(1.08); }
.btn-outline { background: var(--bg-card); border-color: var(--border-light); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-card-hover); border-color: var(--cyan); }
.btn-danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,0.22); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-icon { padding: 6px; border-radius: 7px; background: rgba(30,41,59,0.5); border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { color: var(--cyan); border-color: rgba(6,182,212,0.5); background: rgba(6,182,212,0.1); }
.btn-icon.danger:hover { color: #fca5a5; border-color: rgba(239,68,68,0.5); background: rgba(239,68,68,0.12); }

/* Cards & Grids */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 12px; color: var(--text-muted); font-weight: 400; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: 12px; font-weight: 500; }
.kpi-val { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 8px; }
.kpi-foot { font-size: 12px; color: var(--text-dim); }

.grid-main { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-routing { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, 1fr); gap: 18px; align-items: start; }
.grid-qos { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(290px, 1fr); gap: 18px; align-items: start; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid rgba(30,41,59,0.65); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: rgba(30,41,59,0.35); }
tbody tr.selected { background: rgba(6,182,212,0.09); }

/* Badges / Tags */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-cyan { background: rgba(6,182,212,0.12); color: #67e8f9; border-color: rgba(6,182,212,0.35); }
.badge-emerald { background: rgba(16,185,129,0.12); color: #6ee7b7; border-color: rgba(16,185,129,0.35); }
.badge-violet { background: rgba(139,92,246,0.16); color: #c4b5fd; border-color: rgba(139,92,246,0.4); }
.badge-blue { background: rgba(59,130,246,0.16); color: #93c5fd; border-color: rgba(59,130,246,0.38); }
.badge-amber { background: rgba(245,158,11,0.14); color: #fcd34d; border-color: rgba(245,158,11,0.35); }
.badge-red { background: rgba(239,68,68,0.14); color: #fca5a5; border-color: rgba(239,68,68,0.35); }
.badge-gray { background: rgba(100,116,139,0.16); color: #cbd5e1; border-color: rgba(100,116,139,0.32); }

/* Tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab-btn {
  padding: 10px 14px; background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { color: var(--cyan); border-bottom-color: var(--cyan); }

.seg-tabs { display: inline-flex; background: var(--bg-input); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg-btn { border: none; background: transparent; color: var(--text-muted); padding: 6px 11px; border-radius: 7px; font-size: 12px; font-weight: 600; cursor: pointer; }
.seg-btn.active { background: rgba(6,182,212,0.18); color: #67e8f9; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-hint { font-size: 11px; color: var(--text-dim); }
.input, .select, .textarea {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: 8px; padding: 9px 12px; color: var(--text-main); outline: none; transition: border-color 0.15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(6,182,212,0.12); }
.input-sm { padding: 6px 9px; font-size: 12px; width: 88px; text-align: right; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: #334155; border-radius: 999px; transition: 0.2s;
}
.slider:before {
  position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--emerald); }
.switch input:checked + .slider:before { transform: translateX(18px); }
.switch.cyan input:checked + .slider { background: var(--cyan); }

/* Progress Bar */
.progress-track { height: 7px; background: #1e293b; border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }

/* Code / Script Box */
.code-box {
  background: #060b14; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; font-family: var(--font-mono); font-size: 12px; line-height: 1.55;
  color: #a5f3fc; overflow-x: auto; white-space: pre; max-height: 360px; overflow-y: auto;
}
.qr-wrap {
  background: #ffffff; padding: 14px; border-radius: 12px; display: inline-flex;
  align-items: center; justify-content: center; margin: 0 auto;
}
.qr-wrap svg { width: 200px; height: 200px; display: block; }

/* Topology Canvas */
.topology-box {
  background: radial-gradient(circle, rgba(51,65,85,0.45) 1px, transparent 1px), #070d19;
  background-size: 20px 20px; border: 1px solid var(--border); border-radius: 12px;
  min-height: 410px; position: relative; overflow: hidden;
}
.topology-box svg { width: 100%; height: 420px; display: block; }

/* Slide-Over Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,0.68); backdrop-filter: blur(4px); z-index: 60; display: flex; justify-content: flex-end; }
.drawer-panel {
  width: 100%; max-width: 560px; background: #0d1424; border-left: 1px solid var(--border-light);
  height: 100%; display: flex; flex-direction: column; overflow: hidden; box-shadow: -20px 0 60px rgba(0,0,0,0.5);
}
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-body { padding: 20px 22px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,0.72); backdrop-filter: blur(4px); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box {
  width: 100%; max-width: 540px; background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: 14px; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,0.6); max-height: 92vh; display: flex; flex-direction: column;
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* Banner & Alerts */
.banner { padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.banner-emerald { background: rgba(16,185,129,0.09); border-color: rgba(16,185,129,0.32); color: #a7f3d0; }
.banner-amber { background: rgba(245,158,11,0.09); border-color: rgba(245,158,11,0.32); color: #fde68a; }
.banner-cyan { background: rgba(6,182,212,0.09); border-color: rgba(6,182,212,0.32); color: #a5f3fc; }

/* Matrix Row */
.matrix-item {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}

/* Range Slider */
input[type="range"] { -webkit-appearance: none; width: 100%; height: 6px; background: #1e293b; border-radius: 4px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--cyan); cursor: pointer; box-shadow: 0 0 8px var(--cyan-glow); }

/* Toast */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast {
  padding: 12px 16px; border-radius: 10px; background: #162033; border: 1px solid var(--border-light);
  color: var(--text-main); font-size: 13px; font-weight: 500; box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  display: flex; align-items: center; gap: 10px; animation: slideIn 0.2s ease;
}
.toast.ok { border-color: rgba(16,185,129,0.55); }
.toast.err { border-color: rgba(239,68,68,0.55); color: #fecaca; }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Responsive */
@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-routing, .grid-qos, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .sys-mini { display: none; }
  .form-row { grid-template-columns: 1fr; }
}
