:root {
  --bg: #0a0f1e;
  --bg-2: #0e1528;
  --panel: #131d34;
  --panel-2: #17233f;
  --panel-soft: #1b2842;
  --border: #26334f;
  --border-soft: #1f2b45;
  --text: #e8eefc;
  --muted: #93a4c6;
  --muted-2: #6c7ea3;
  --indigo: #6366f1;
  --indigo-2: #818cf8;
  --cyan: #22d3ee;
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, .12);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, .12);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, .12);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 80% -10%, #16224180 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--indigo-2); }
button { font-family: inherit; }

/* ============ Login ============ */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 64px; height: 64px; border-radius: 16px;
  display: grid; place-items: center; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--indigo), var(--cyan));
  font-size: 30px;
}
.login-card h1 { text-align: center; font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 13px; }

/* ============ App shell ============ */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand .name { font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.brand .tag { font-size: 11px; color: var(--muted-2); }

.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted-2); padding: 12px 10px 6px; }

.acct-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  cursor: pointer; border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.acct-item:hover { background: var(--panel); }
.acct-item.active { background: var(--panel-2); border-color: var(--border); }
.acct-item .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted-2); flex: none; }
.acct-item .dot.running { background: var(--green); box-shadow: 0 0 0 4px var(--green-bg); }
.acct-item .dot.error { background: var(--red); box-shadow: 0 0 0 4px var(--red-bg); }
.acct-item .dot.starting { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-bg); }
.acct-item .meta { overflow: hidden; }
.acct-item .meta .nm { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-item .meta .st { font-size: 11.5px; color: var(--muted); }

.side-spacer { flex: 1; }
.side-foot { color: var(--muted-2); font-size: 11px; padding: 10px; border-top: 1px solid var(--border-soft); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: rgba(10, 15, 30, .6); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar .title { font-size: 16px; font-weight: 700; }
.topbar .right { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }

.content { padding: 22px 24px 40px; max-width: 1080px; width: 100%; }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.tab {
  padding: 10px 16px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; font-weight: 600; font-size: 13.5px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--indigo); }

/* ============ Cards ============ */
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .card-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .sidebar { display: none; } }

/* ============ Form ============ */
label.fld { display: block; margin-bottom: 14px; }
label.fld > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
label.fld .hint { font-weight: 400; color: var(--muted-2); font-size: 11.5px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px;
  font-size: 13.5px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(99, 102, 241, .18); }
textarea { resize: vertical; min-height: 90px; font-family: inherit; line-height: 1.5; }
textarea.mono { font-family: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.check { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; color: var(--text); font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--indigo); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel-soft); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13.5px;
  transition: transform .06s, filter .15s, background .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--indigo), #4f46e5); border-color: transparent; }
.btn-cyan { background: linear-gradient(135deg, #0891b2, var(--cyan)); border-color: transparent; color: #04121a; }
.btn-green { background: linear-gradient(135deg, #059669, var(--green)); border-color: transparent; color: #042a1f; }
.btn-danger { background: transparent; border-color: rgba(248,113,113,.5); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============ Badges / status ============ */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge .d { width: 7px; height: 7px; border-radius: 50%; }
.badge.on { background: var(--green-bg); color: var(--green); } .badge.on .d { background: var(--green); }
.badge.off { background: rgba(148,163,184,.12); color: var(--muted); } .badge.off .d { background: var(--muted); }
.badge.err { background: var(--red-bg); color: var(--red); } .badge.err .d { background: var(--red); }
.badge.warn { background: var(--amber-bg); color: var(--amber); } .badge.warn .d { background: var(--amber); }

/* ============ Overview stats ============ */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 720px) { .stat-row { grid-template-columns: 1fr; } }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 800; margin-top: 6px; }

/* ============ Log console ============ */
.console {
  background: #05080f; border: 1px solid var(--border); border-radius: var(--radius);
  height: 460px; overflow-y: auto; padding: 14px 16px;
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.55;
}
.console .ln { white-space: pre-wrap; word-break: break-word; }
.console .ln.info { color: #c7d3ee; }
.console .ln.warning { color: var(--amber); }
.console .ln.error { color: var(--red); }
.console .ln .ts { color: var(--muted-2); }

/* ============ Modal ============ */
.modal-back { position: fixed; inset: 0; background: rgba(4, 8, 16, .7); backdrop-filter: blur(4px); display: none; place-items: center; z-index: 50; padding: 20px; }
.modal-back.show { display: grid; }
.modal { width: 100%; max-width: 440px; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--border); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal p.sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.modal .step { display: none; } .modal .step.active { display: block; }

/* ============ Toast ============ */
.toasts { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); box-shadow: var(--shadow); font-size: 13.5px; max-width: 340px; animation: slidein .2s ease; }
.toast.success { border-color: rgba(52,211,153,.4); } .toast.error { border-color: rgba(248,113,113,.45); } .toast.info { border-color: var(--border); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.hide { display: none !important; }
