:root {
  --bg: #16181c;
  --bg-2: #1d2026;
  --card: #23272e;
  --card-2: #2a2f37;
  --line: #343a44;
  --text: #e8eaed;
  --muted: #9aa3ae;
  --green: #4caf50;
  --green-2: #3d9142;
  --red: #e5534b;
  --red-2: #c9443d;
  --amber: #e0a63a;
  --blue: #5b9dff;
  --radius: 12px;
  --mono: ui-monospace, 'Cascadia Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.05rem; }
code { font-family: var(--mono); background: var(--card-2); padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--red); margin: 0; }

/* ---------- botones ---------- */
.btn {
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 10px;
  padding: .55rem 1rem; cursor: pointer; color: var(--text); background: var(--card-2);
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn-primary { background: var(--blue); color: #0b1220; }
.btn-primary:hover:not(:disabled) { background: #7cb1ff; }
.btn-go { background: var(--green); color: #07130a; }
.btn-go:hover:not(:disabled) { background: #5cc260; }
.btn-stop { background: var(--red); color: #fff; }
.btn-stop:hover:not(:disabled) { background: var(--red-2); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--card-2); }
.btn-sm { padding: .3rem .7rem; font-size: .85rem; }
.btn-lg { padding: .8rem 2.2rem; font-size: 1.1rem; }
.btn-block { width: 100%; }

input:not([type=checkbox]) {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .55rem .75rem; width: 100%;
}

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
  width: min(380px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 2rem; display: grid; gap: .9rem; text-align: left;
}
.login-card h1 { font-size: 1.4rem; margin: 0; }
.login-card p { margin: 0; }
.login-card label { display: grid; gap: .35rem; font-size: .9rem; color: var(--muted); }
.login-logo { image-rendering: pixelated; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--bg-2);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .6rem; font-size: 1.05rem; }
.brand img { image-rendering: pixelated; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.me { color: var(--muted); font-size: .9rem; }
.me b { color: var(--text); }

.tabs {
  display: flex; gap: .25rem; padding: 0 1rem; border-bottom: 1px solid var(--line);
  background: var(--bg-2); overflow-x: auto; scrollbar-width: none;
}
.tabs a {
  color: var(--muted); text-decoration: none; padding: .75rem .9rem; font-weight: 600;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--green); }

.content { max-width: 980px; margin: 0 auto; padding: 1.25rem; display: grid; gap: 1rem; }
.tab { display: grid; gap: 1rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- servidor ---------- */
.hero { display: grid; gap: 1.1rem; }
.address { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.addr { font-family: var(--mono); font-size: 1.25rem; word-break: break-all; }
.addr .port { color: var(--muted); }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.status { display: flex; align-items: center; gap: .6rem; font-size: 1.6rem; font-weight: 700; }
.status .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); }
.status-online .dot { background: var(--green); box-shadow: 0 0 0 4px rgba(76, 175, 80, .2); }
.status-online { color: var(--green); }
.status-offline .dot { background: var(--red); }
.status-offline { color: var(--red); }
.status-starting .dot, .status-stopping .dot { background: var(--amber); animation: pulse 1.2s infinite; }
.status-starting, .status-stopping { color: var(--amber); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status .dot { animation: none !important; } }
.power { display: flex; gap: .5rem; flex-wrap: wrap; }
.busy { margin: 0; color: var(--amber); font-size: .9rem; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: .2rem; }
.stat .value.small { font-size: 1.05rem; }
.stat .value small { color: var(--muted); font-weight: 500; }
.stat.wide { grid-column: 1 / -1; display: grid; gap: .35rem; }
.bar { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; margin-bottom: .4rem; }
.bar span { display: block; height: 100%; width: 0; background: var(--green); transition: width .4s; }
.bar span.warn { background: var(--amber); }
.bar span.crit { background: var(--red); }

.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.chips li:not(.muted) { background: var(--card-2); border: 1px solid var(--line); border-radius: 99px; padding: .3rem .8rem; }

/* ---------- listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .65rem 0; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.list li:first-child { border-top: 0; }
.list li.empty { color: var(--muted); justify-content: flex-start; }
.list .who { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.list .who b { overflow-wrap: anywhere; }
.list .meta { color: var(--muted); font-size: .85rem; }
.list .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.list.compact li { padding: .45rem 0; font-size: .9rem; }
.badge { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 6px; background: var(--card-2); color: var(--muted); }
.badge.op { background: rgba(224, 166, 58, .18); color: var(--amber); }
.badge.on { background: rgba(76, 175, 80, .18); color: var(--green); }
.inline-form { display: flex; gap: .5rem; margin-bottom: .5rem; }

.switch { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 40px; height: 22px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.switch input:disabled + span { opacity: .5; }

/* ---------- consola ---------- */
.console-card { display: grid; gap: .75rem; }
.console-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.console-head h2 { margin: 0; }
.check { display: inline-flex; gap: .4rem; align-items: center; color: var(--muted); font-size: .9rem; }
.console {
  margin: 0; height: 60vh; min-height: 280px; overflow: auto; background: #0e1013; border: 1px solid var(--line);
  border-radius: 10px; padding: .75rem; font-family: var(--mono); font-size: .8rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.console .l-warn { color: var(--amber); }
.console .l-err { color: var(--red); }
.console .l-join { color: var(--green); }
.console .l-leave { color: #c58cff; }
.console .l-cmd { color: var(--blue); }
.cmd { display: flex; align-items: center; gap: .5rem; }
.cmd .prompt { font-family: var(--mono); color: var(--muted); font-size: 1.1rem; }
.cmd input { font-family: var(--mono); }

/* ---------- modal / toasts ---------- */
.modal { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); padding: 1.4rem; width: min(440px, 92vw); }
.modal::backdrop { background: rgba(0, 0, 0, .6); }
.modal p { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.toasts { position: fixed; bottom: 1rem; right: 1rem; display: grid; gap: .5rem; z-index: 50; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.toast.err { background: #3a2426; border-color: rgba(229, 83, 75, .45); }

@media (max-width: 760px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: .9rem; }
  .status { font-size: 1.35rem; }
  .btn-lg { width: 100%; }
  .power { width: 100%; }
  .addr { font-size: 1.05rem; }
  .me { display: none; }
}
