:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c232c;
  --line: #262e39;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #52a447;
  --accent-soft: #52a4471f;
  --warn: #d9a441;
  --danger: #d75f5f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sprite { display: none; }
[hidden] { display: none !important; }

h1 { font-size: 1.25rem; margin: 0 0 .25rem; }
h2 { font-size: .95rem; margin: 0 0 .75rem; letter-spacing: .01em; }
h2.mt { margin-top: 1.75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; background: var(--surface-2); padding: .1em .4em; border-radius: 5px; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .82rem; margin: .6rem 0 0; }
.hint.warn { color: #c9a24d; }
.error { color: var(--danger); font-size: .85rem; margin: .75rem 0 0; }

/* ---------------------------------------------------------------- login */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }

.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo { margin: 0 auto 1.1rem; width: 64px; height: 64px; }
.login-logo svg {
  width: 100%; height: 100%;
  /* Sombra proyectada por debajo del bloque, no un contorno: le da peso
     sin ensuciar las aristas. */
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45));
}

.login-card p { margin: 0 0 1.5rem; font-size: .88rem; }

input[type=password], input[type=text] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .7rem .85rem;
  font: inherit;
  transition: border-color .15s;
}
input:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: #5b6775; }

/* ---------------------------------------------------------------- chrome */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.15rem;
  background: rgba(14,17,22,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand-logo { width: 30px; height: 30px; flex: none; }
.brand-text { min-width: 0; }
.brand strong { display: block; font-size: .95rem; line-height: 1.25; }
.brand .muted { font-size: .78rem; }
.brand .state { display: flex; align-items: center; gap: .4rem; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  flex: none;
  transition: background .2s, box-shadow .2s;
}
.dot.on { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.dot.busy { background: var(--warn); box-shadow: 0 0 0 4px #d9a4411f; }
.dot.off { background: #4a5563; }

.wrap { max-width: 820px; margin: 0 auto; padding: 1.15rem 1.15rem 4rem; display: grid; gap: 1.15rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* ---------------------------------------------------------------- botones */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .6rem 1rem;
  font: inherit; font-weight: 550;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: filter .15s, opacity .15s, border-color .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; fill: currentColor; flex: none; }
.btn-restart svg, .btn svg[stroke] { fill: none; }

.btn-primary { background: var(--accent); color: #08130a; }
.btn-go      { background: var(--accent); color: #08130a; }
.btn-warn    { background: var(--warn);   color: #1c1403; }
.btn-danger  { background: var(--danger); color: #1c0505; }
.btn-ghost   { background: transparent; border-color: var(--line); }
.btn-block   { width: 100%; margin-top: 1rem; }
.btn-icon    { padding: .5rem; }
.btn-icon svg { width: 18px; height: 18px; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }

/* ----------------------------------------------------------------- power */

.power-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.power-buttons .btn { padding: .9rem .5rem; flex-direction: column; gap: .4rem; font-size: .85rem; }
.power-buttons .btn svg { width: 20px; height: 20px; }

/* ----------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}
.stat-label { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { display: block; font-size: 1.25rem; font-weight: 600; margin-top: .2rem; font-variant-numeric: tabular-nums; }

.bar { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: .5rem; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s, background .3s; }
.bar i.high { background: var(--warn); }
.bar i.critical { background: var(--danger); }

/* ------------------------------------------------------------------ tabs */

.tabs { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex; align-items: center; gap: .45rem;
  background: transparent; border: 1px solid transparent; border-radius: 99px;
  color: var(--muted); font: inherit; font-size: .85rem;
  padding: .5rem .9rem; cursor: pointer; white-space: nowrap;
  transition: color .15s, background .15s;
}
.tab svg { width: 16px; height: 16px; fill: none; stroke: currentColor; }
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface-2); color: var(--text); border-color: var(--line); }

/* ----------------------------------------------------------------- listas */

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
  font-size: .88rem;
}
.list li.empty { color: var(--muted); background: transparent; border: 1px dashed var(--line); justify-content: center; }
.list .meta { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.list .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: .25rem; border-radius: 6px; display: grid; place-items: center;
}
.icon-btn:hover { color: var(--danger); background: #d75f5f1a; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; }

/* ---------------------------------------------------------------- consola */

.console {
  background: #0a0d11;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  margin: 0 0 .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem; line-height: 1.6;
  color: #c8d3de;
  max-height: 300px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.console.tall { max-height: 460px; }
.console .cmd { color: var(--accent); }
.console .err { color: var(--danger); }

.row { display: flex; gap: .6rem; }
.row input { flex: 1; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.row-between h2 { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.chip {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px;
  color: var(--muted); font: inherit; font-size: .78rem; padding: .3rem .75rem; cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.chip:hover { color: var(--text); border-color: var(--accent); }

/* --------------------------------------------------------------- dropzone */

.dropzone {
  display: grid; place-items: center; gap: .3rem;
  margin-top: 1rem; padding: 1.75rem 1rem;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: .85rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone svg { width: 22px; height: 22px; fill: none; stroke: currentColor; margin-bottom: .3rem; }
.dropzone strong { color: var(--text); font-size: .9rem; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- toasts */

.toasts { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 50; width: min(420px, calc(100% - 2rem)); }

.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: .7rem .95rem;
  font-size: .86rem;
  box-shadow: var(--shadow);
  animation: rise .2s ease-out;
}
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
