:root {
  --bg: #060b12;
  --bg-soft: #0a121c;
  --panel: #0d1620;
  --panel-2: #111c28;
  --line: rgba(148, 180, 200, 0.12);
  --text: #e8f1f5;
  --muted: #7f95a5;
  --teal: #4ecdc4;
  --cyan: #57d9e8;
  --violet: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --grad: linear-gradient(120deg, #4ecdc4, #7dd3fc 45%, #a78bfa);
  --r: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(70% 50% at 78% -5%, rgba(78, 205, 196, 0.14), transparent 62%),
    radial-gradient(60% 45% at 8% 0%, rgba(167, 139, 250, 0.10), transparent 60%),
    linear-gradient(180deg, #060b12, #050910);
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 180, 200, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 180, 200, 0.05) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(80% 70% at 50% 20%, #000 20%, transparent 95%);
}

.mono, .mono * { font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; }

.card {
  background: linear-gradient(180deg, rgba(17, 28, 40, 0.9), rgba(11, 19, 28, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--r);
  backdrop-filter: blur(10px);
}

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* buttons */
button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  transition: 0.16s ease;
}
button:hover { border-color: rgba(78, 205, 196, 0.5); background: rgba(78, 205, 196, 0.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary {
  background: var(--grad);
  color: #04131a;
  border: none;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(78, 205, 196, 0.18);
}
button.primary:hover { filter: brightness(1.06); }
button.icon { padding: 7px 9px; border-radius: 9px; }
button.link { background: none; border: none; color: var(--muted); padding: 4px; }
button.link:hover { color: var(--teal); background: none; }

input[type="text"], input[type="password"], input[type="number"], textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(4, 9, 15, 0.7);
  color: var(--text);
  font-size: 15px;
  font-family: ui-monospace, Menlo, monospace;
  outline: none;
  transition: 0.16s;
}
textarea { resize: vertical; min-height: 74px; }
input:focus, textarea:focus { border-color: rgba(78, 205, 196, 0.65); box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1); }
input::placeholder, textarea::placeholder { color: #5c6f7d; }

.label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; display: block; }

/* ---------------- LOGIN ---------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-card { width: min(430px, 100%); padding: 26px; }
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.logo { width: 54px; height: 54px; border-radius: 16px; background: var(--grad); display: grid; place-items: center; flex: 0 0 auto; }
.logo svg { width: 28px; height: 28px; }
.login-head h1 { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.2; }
.login-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin: 20px 0; color: var(--muted); font-size: 14px; line-height: 1.5;
  background: rgba(255, 255, 255, 0.02);
}
.notice svg { flex: 0 0 auto; color: var(--teal); }
.login-card form { display: grid; gap: 14px; }
.err { color: var(--bad); font-size: 13.5px; min-height: 18px; }
.fine { color: var(--muted); font-size: 12.5px; text-align: center; margin: 14px 0 0; }

/* ---------------- SHELL ---------------- */
.shell { max-width: 1140px; margin: 0 auto; padding: 26px 20px 46px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.topbar .brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.topbar h1 { margin: 0; font-size: 21px; font-weight: 800; }
.topbar .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.pill { font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 999px; }
.pill.run { background: rgba(52, 211, 153, 0.15); color: var(--ok); }
.pill.pause { background: rgba(251, 191, 36, 0.15); color: var(--warn); }

.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.stat { padding: 16px 18px; }
.stat .top { display: flex; align-items: center; justify-content: space-between; }
.stat .k { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 30px; font-weight: 800; margin: 8px 0 4px; }
.stat .d { color: var(--muted); font-size: 12.5px; }
.stat svg { color: var(--teal); opacity: 0.8; width: 17px; height: 17px; }

.cols { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 16px; align-items: start; }
.panel { padding: 20px; }
.panel h2 { margin: 0; font-size: 17px; font-weight: 700; }
.panel .desc { color: var(--muted); font-size: 13.5px; margin: 5px 0 18px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.eq { display: flex; align-items: flex-end; gap: 3px; height: 26px; }
.eq i { width: 4px; border-radius: 2px; background: var(--grad); animation: eq 1.1s ease-in-out infinite; }
.eq i:nth-child(1) { height: 40%; animation-delay: 0s; }
.eq i:nth-child(2) { height: 80%; animation-delay: 0.12s; }
.eq i:nth-child(3) { height: 55%; animation-delay: 0.24s; }
.eq i:nth-child(4) { height: 95%; animation-delay: 0.36s; }
.eq i:nth-child(5) { height: 45%; animation-delay: 0.48s; }
.eq i:nth-child(6) { height: 25%; animation-delay: 0.6s; }
@keyframes eq { 50% { transform: scaleY(0.4); } }

.join-row { display: flex; gap: 12px; }
.join-row input { flex: 1; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 9px; }
.hint b { color: var(--text); font-family: ui-monospace, monospace; font-weight: 600; }

.divider { height: 1px; background: var(--line); margin: 18px 0; }

.preset-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.preset-head span { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14.5px; }
.tag { font-size: 11.5px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); color: var(--muted); font-family: ui-monospace, monospace; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.preset {
  border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer;
  background: rgba(255, 255, 255, 0.02); transition: 0.15s;
}
.preset:hover { border-color: rgba(78, 205, 196, 0.45); }
.preset .pn { font-size: 14px; font-weight: 600; }
.preset .pid { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, monospace; margin-top: 2px; }
.preset-add { display: flex; gap: 10px; margin-top: 10px; }
.preset-add input { flex: 1; font-family: inherit; }

/* tabs */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: rgba(255, 255, 255, 0.03); border-radius: 12px; margin-bottom: 18px; }
.tabs button { justify-content: center; border: none; background: none; color: var(--muted); border-radius: 9px; }
.tabs button.active { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.tab { display: none; }
.tab.active { display: block; }

.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.range { width: 100%; accent-color: var(--teal); }

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.toggle { border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; background: rgba(255, 255, 255, 0.02); }
.toggle > span:first-child { display: block; min-width: 0; }
.toggle .tt { display: block; font-size: 14.5px; font-weight: 600; }
.toggle .td { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.sw { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw .tr { position: absolute; inset: 0; border-radius: 999px; background: #22303d; transition: 0.18s; cursor: pointer; }
.sw .tr::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #8ea3b2; transition: 0.18s; }
.sw input:checked + .tr { background: rgba(78, 205, 196, 0.28); }
.sw input:checked + .tr::after { left: 21px; background: var(--teal); box-shadow: 0 0 10px rgba(78, 205, 196, 0.7); }

/* sessions */
.session { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.session:last-child { border-bottom: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.dot.on { background: var(--ok); box-shadow: 0 0 9px var(--ok); }
.dot.off { background: var(--bad); box-shadow: 0 0 9px var(--bad); }
.session .info { flex: 1; min-width: 0; }
.session .nm { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.session .nm small { color: var(--muted); font-weight: 500; font-family: ui-monospace, monospace; font-size: 12px; }
.session .mt { color: var(--muted); font-size: 12.5px; font-family: ui-monospace, monospace; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 8px; }
.badge.on { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.badge.off { background: rgba(248, 113, 113, 0.14); color: var(--bad); }
.badge.idle { background: rgba(148, 180, 200, 0.12); color: var(--muted); }

.warnbox { display: flex; gap: 11px; border: 1px solid rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.07); border-radius: 12px; padding: 13px; margin-top: 16px; color: #d9c48c; font-size: 13px; line-height: 1.5; }
.warnbox svg { flex: 0 0 auto; color: var(--warn); }

.console { font-family: ui-monospace, Menlo, monospace; font-size: 12.3px; line-height: 1.65; background: rgba(3, 7, 12, 0.75); border: 1px solid var(--line); border-radius: 11px; padding: 12px; height: 300px; overflow-y: auto; }
.console div { white-space: pre-wrap; word-break: break-word; }
.console .ts { color: #5b6f7d; }
.console .error { color: var(--bad); }
.console .warn { color: var(--warn); }

.cmd { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.cmd:last-child { border-bottom: none; }
.cmd code { font-family: ui-monospace, monospace; color: var(--teal); }
.cmd span { color: var(--muted); text-align: right; }

.foot { border-top: 1px solid var(--line); margin-top: 26px; padding-top: 16px; color: var(--muted); font-size: 12.5px; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 10px; z-index: 60; max-width: min(360px, calc(100vw - 32px)); }
.toast { display: flex; gap: 11px; padding: 13px 15px; border-radius: 12px; background: rgba(13, 22, 32, 0.97); border: 1px solid var(--line); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5); animation: pop 0.2s ease; }
.toast .tt { font-size: 14px; font-weight: 600; }
.toast .td { color: var(--muted); font-size: 12.5px; margin-top: 2px; word-break: break-word; }
.toast.ok svg { color: var(--ok); }
.toast.bad svg { color: var(--bad); }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
  .form-2, .toggles { grid-template-columns: 1fr; }
  .join-row { flex-direction: column; }
}