:root {
  --bg: #080c14;
  --bg-2: #0c121d;
  --panel: #101a29;
  --panel-2: #152134;
  --line: rgba(148, 163, 184, 0.14);
  --line-2: rgba(148, 163, 184, 0.26);
  --text: #e8eefb;
  --muted: #93a4bb;
  --dim: #5f7189;
  --accent: #f97316;
  --accent-2: #fb923c;
  --accent-soft: rgba(249, 115, 22, 0.14);
  --green: #34d399;
  --red: #f87171;
  --blue: #60a5fa;
  --radius: 16px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(110% 80% at 100% -10%, rgba(249, 115, 22, 0.12), transparent 55%),
    radial-gradient(90% 70% at -10% 0%, rgba(96, 165, 250, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent-2); }
button, input, textarea, select { font: inherit; }

/* --- login --- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; padding: 28px; border-radius: 20px;
  background: linear-gradient(180deg, rgba(21, 33, 52, 0.95), rgba(12, 18, 29, 0.95));
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand strong { display: block; font-size: 18px; }
.login-brand span { color: var(--muted); font-size: 12px; }
.logo { width: 40px; height: 40px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { font-size: 12px; color: var(--muted); font-weight: 600; }
.login-foot { margin-top: 18px; text-align: center; color: var(--dim); font-size: 11.5px; }
.error { color: var(--red); font-size: 12.5px; min-height: 18px; }

/* --- layout --- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  display: flex; flex-direction: column; gap: 18px; padding: 20px 16px;
  border-right: 1px solid var(--line); background: rgba(8, 12, 20, 0.72);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; color: var(--dim); font-size: 11px; letter-spacing: 0.04em; }
.brand .logo { width: 34px; height: 34px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  appearance: none; border: 0; text-align: left; padding: 10px 12px; border-radius: 10px;
  background: transparent; color: var(--muted); font-weight: 600; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(148, 163, 184, 0.08); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-2); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.conn { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.dot.on { background: var(--green); box-shadow: 0 0 10px rgba(52, 211, 153, 0.7); }
.link { appearance: none; border: 0; background: none; color: var(--muted); text-align: left; padding: 0; cursor: pointer; font-size: 12px; }
.link:hover { color: var(--accent-2); }

.main { min-width: 0; padding: 22px clamp(16px, 3vw, 34px) 40px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topbar h1 { font-size: 20px; }
.topbar .muted { margin-top: 2px; font-size: 12.5px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.pill {
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-size: 11.5px; font-weight: 600;
}

/* --- cards / grids --- */
.view { display: flex; flex-direction: column; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.card {
  background: linear-gradient(180deg, rgba(21, 33, 52, 0.92), rgba(12, 18, 29, 0.92));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; }
.card-head .muted { font-size: 11.5px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value.accent { color: var(--accent-2); }
.stat-value.green { color: var(--green); }

/* --- tables --- */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-weight: 600; color: var(--dim); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; color: var(--muted); }
.table .empty { color: var(--dim); text-align: center; padding: 26px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
}
.badge.online { color: var(--green); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.badge.offline { color: var(--dim); }
.badge.warn { color: var(--accent-2); border-color: rgba(249, 115, 22, 0.4); background: var(--accent-soft); }

/* --- forms --- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #070b12; color: var(--text); outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus { border-color: rgba(249, 115, 22, 0.55); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; resize: vertical; }
textarea.code { min-height: 280px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* --- switch --- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 40px; height: 24px; border-radius: 999px; background: rgba(148, 163, 184, 0.24); transition: background 0.18s ease; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #e2e8f0; transition: transform 0.18s ease; }
.switch input:checked + .track { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.switch input:checked + .track .thumb { transform: translateX(16px); background: #fff; }

/* --- buttons --- */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: transparent; color: var(--text);
  padding: 9px 14px; border-radius: 10px; font-weight: 600; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}
.btn:hover:not(:disabled) { background: rgba(148, 163, 184, 0.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: #1b1206; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #fdba74, #f97316); }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.danger { border-color: rgba(248, 113, 113, 0.4); color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

/* --- network list --- */
.networks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.network {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(148, 163, 184, 0.04);
}
.network .name { font-size: 12.5px; font-weight: 600; }
.network .kind { color: var(--dim); font-size: 10.5px; }
.network.block .name { color: var(--muted); }

/* --- preview --- */
.preview-shell { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #070b12; }
.preview {
  min-height: 260px; padding: 20px;
  background-color: #0b1220;
  background-image: linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* --- jobs --- */
.job { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.job + .job { margin-top: 10px; }
.progress { height: 8px; border-radius: 999px; background: rgba(148, 163, 184, 0.16); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.job-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; }

/* --- misc --- */
.toast {
  position: fixed; right: 20px; bottom: 20px; padding: 11px 16px; border-radius: 10px;
  background: #0f1a2a; border: 1px solid var(--line-2); color: var(--text); font-size: 12.5px;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; max-width: 340px; z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }

.empty-state { padding: 30px; text-align: center; color: var(--dim); font-size: 12.5px; }
.tip { padding: 10px 12px; border-radius: 10px; background: rgba(96, 165, 250, 0.08); border: 1px solid rgba(96, 165, 250, 0.22); color: #bfdbfe; font-size: 12px; }
.warnbox { padding: 10px 12px; border-radius: 10px; background: rgba(249, 115, 22, 0.08); border: 1px solid rgba(249, 115, 22, 0.25); color: #fed7aa; font-size: 12px; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0; flex-direction: row; align-items: center; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .networks { grid-template-columns: 1fr; }
}
