:root {
  --bg: #0d1117;
  --card: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.mono, code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.error { color: var(--bad); margin: 8px 0; font-size: 13px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: #010409;
}

.brand { font-weight: 700; font-size: 17px; }
.top-right { display: flex; align-items: center; gap: 12px; }
.pill {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--muted);
}

main { padding: 20px 24px 48px; max-width: 1240px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-head h2 { margin: 0; font-size: 16px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat { display: flex; align-items: center; gap: 14px; margin: 0; }
.stat-icon { font-size: 26px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.conn-name { font-weight: 600; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.ok { background: rgba(63, 185, 80, .15); color: var(--ok); }
.badge.warn { background: rgba(210, 153, 34, .15); color: var(--warn); }
.badge.bad { background: rgba(248, 81, 73, .15); color: var(--bad); }
.badge.off { background: rgba(139, 148, 158, .15); color: var(--muted); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }

.btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s, filter .15s, opacity .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; margin-right: 4px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.block { width: 100%; margin-top: 8px; }
.btn.primary:disabled { opacity: .72; cursor: default; filter: none; }

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  overflow-y: auto;
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(47, 111, 237, .30), transparent 60%),
    radial-gradient(900px 520px at 110% 110%, rgba(210, 153, 34, .16), transparent 55%),
    radial-gradient(760px 520px at 95% -5%, rgba(63, 185, 80, .10), transparent 50%),
    #05080f;
}

.overlay::before,
.overlay::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .55;
  pointer-events: none;
  z-index: 0;
}

.overlay::before {
  width: 480px;
  height: 480px;
  left: -120px;
  top: -120px;
  background: radial-gradient(circle, rgba(47, 111, 237, .55), transparent 70%);
  animation: drift 12s ease-in-out infinite alternate;
}
.overlay::after {
  width: 420px;
  height: 420px;
  right: -110px;
  bottom: -110px;
  background: radial-gradient(circle, rgba(210, 153, 34, .32), transparent 70%);
  animation: drift 16s ease-in-out infinite alternate-reverse;
}

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(36px, 24px) scale(1.08); }
}

/* ---------- Login modern ---------- */
.login-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  width: 100%;
  max-width: 880px;
  min-height: 520px;
  background: rgba(15, 20, 29, .74);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, .6),
    inset 0 0 0 1px rgba(255, 255, 255, .02);
}

.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 46px 42px;
  color: #fff;
  background:
    radial-gradient(360px 260px at 85% 12%, rgba(255, 255, 255, .14), transparent 65%),
    linear-gradient(150deg, #081f47 0%, #142e63 52%, #1d4ed8 120%);
  overflow: hidden;
}

.login-brand::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -90px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .13), transparent 70%);
}

.brand-badge {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  margin-bottom: 26px;
}

.login-brand h1 {
  margin: 0 0 10px;
  font-size: 30px;
  letter-spacing: .3px;
}

.login-brand > p {
  margin: 0 0 30px;
  color: rgba(255, 255, 255, .72);
  font-size: 14px;
  line-height: 1.55;
}

.brand-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand-points li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  color: rgba(255, 255, 255, .86);
}

.brand-points svg {
  width: 19px;
  height: 19px;
  flex: none;
  color: #9ecbff;
}

.brand-footer {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding-top: 30px;
  font-size: 11.5px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, .42);
}

.login-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 46px 44px;
}

.login-form h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-form > .muted {
  margin: 0 0 28px;
}

.login-hint {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.login-hint code {
  background: rgba(139, 148, 158, .13);
  padding: 2px 6px;
  border-radius: 6px;
}

#loginBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  padding: 11px 13px;
}

/* ---------- Field & input ---------- */
.field {
  margin-bottom: 18px;
}

.field > label,
.switch-label {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 8px;
}

input[type="text"], input[type="password"], input[type="number"], input:not([type]) {
  width: 100%;
  background: #0d1117;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--accent); }

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap .input-icon {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
  z-index: 1;
}

.input-wrap input {
  padding: 11px 44px 11px 40px;
  background: rgba(13, 17, 23, .88);
  color: var(--text);
  caret-color: var(--accent);
  border-radius: 10px;
}

.input-wrap input::placeholder {
  color: rgba(139, 148, 158, .5);
}

.input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .22);
}

.pass-toggle {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background .15s;
}

.pass-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .07);
}

.pass-toggle svg {
  width: 17px;
  height: 17px;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Modal koneksi modern ---------- */
.modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 700px;
  margin: 0;
  padding: 0;
  background: rgba(22, 27, 36, .96);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(47, 111, 237, .10), transparent);
}

.modal-title {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.modal-icon {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(47, 111, 237, .14);
  border: 1px solid rgba(47, 111, 237, .32);
}

.modal-title h2 {
  margin: 2px 0 4px;
  font-size: 18px;
}

.modal-title p {
  margin: 0;
  line-height: 1.5;
}

.modal-close {
  width: 32px;
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: color .15s, background .15s;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .07);
}

#connForm {
  padding: 22px 26px 24px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 16px;
}

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
}

.switch-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 14px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #30363d;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  transition: transform .18s;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .login-shell {
    grid-template-columns: 1fr;
    max-width: 440px;
  }
  .login-brand { display: none; }
  .login-form { padding: 40px 30px; }
}
