:root {
  --bg: #0b0e12;
  --surface: #12171e;
  --surface-2: #1a212a;
  --surface-3: #212a35;
  --line: #232c37;
  --line-soft: #1b232c;
  --text: #e8eef5;
  --text-2: #aebac8;
  --muted: #7d8b9b;
  --accent: #5cb554;
  --accent-bright: #6cc45e;
  --accent-soft: rgba(92, 181, 84, .12);
  --warn: #d9a441;
  --danger: #dc6a6a;
  --radius: 16px;
  --radius-sm: 10px;
  --ring: 0 0 0 3px rgba(92, 181, 84, .3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  --ease: cubic-bezier(.32, .72, 0, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

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

h1 { font-size: 1.35rem; letter-spacing: -.02em; margin: 0 0 .35rem; }
h2 {
  font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted);
  margin: 0 0 .85rem;
}
h2.mt { margin-top: 2rem; }
h3 { font-size: 1.02rem; letter-spacing: -.01em; margin: 0 0 .5rem; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85em;
  background: var(--surface-3);
  padding: .12em .42em;
  border-radius: 5px;
  color: var(--text-2);
}

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

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

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

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

.login-card {
  width: min(370px, 100%);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2.25rem 1.9rem 2rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: rise .45s var(--ease) both;
}

.login-logo { margin: 0 auto 1.25rem; 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 8px 14px rgba(0, 0, 0, .5));
}

.login-sub { color: var(--muted); font-size: .88rem; margin: 0 0 1.6rem; }
.field { margin-bottom: .8rem; }

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: .72rem .9rem;
  font: inherit;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder { color: #55616f; }
input:disabled { opacity: .45; cursor: not-allowed; }

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

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.15rem;
  background: rgba(11, 14, 18, .8);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}

.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: .96rem; line-height: 1.25; letter-spacing: -.01em; }
.brand .state { display: flex; align-items: center; gap: .42rem; }
.state-text { color: var(--muted); font-size: .78rem; }

.topbar-right { display: flex; align-items: center; gap: .55rem; flex: none; }

.role-chip {
  display: inline-flex; align-items: center; gap: .32rem;
  background: var(--accent-soft);
  color: var(--accent-bright);
  border: 1px solid rgba(92, 181, 84, .25);
  border-radius: 99px;
  padding: .22rem .6rem .22rem .5rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .04em;
}
.role-chip svg { width: 13px; height: 13px; fill: none; stroke: currentColor; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); flex: none;
  transition: background .25s, box-shadow .25s;
}
.dot.on { background: var(--accent-bright); box-shadow: 0 0 0 3.5px var(--accent-soft); }
.dot.busy { background: var(--warn); box-shadow: 0 0 0 3.5px rgba(217, 164, 65, .14); animation: pulse 1.6s ease-in-out infinite; }
.dot.off { background: #47525f; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .62rem 1.05rem;
  font: inherit; font-weight: 550;
  color: var(--text);
  background: var(--surface-3);
  cursor: pointer;
  transition: filter .16s, opacity .16s, transform .1s var(--ease), border-color .16s;
}
.btn:hover:not(:disabled) { filter: brightness(1.16); }
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; fill: currentColor; flex: none; }
.btn svg[stroke], .btn svg use[href="#i-restart"] { fill: none; }

.btn-primary, .btn-go { background: var(--accent); color: #06120a; }
.btn-warn   { background: var(--warn);   color: #1c1403; }
.btn-danger { background: var(--danger); color: #1c0505; }
.btn-ghost  { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--muted); filter: none; }
.btn-block  { width: 100%; }
.btn-icon   { padding: .48rem; }
.btn-icon svg { width: 18px; height: 18px; }
.btn-sm { padding: .38rem .75rem; font-size: .82rem; }

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

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

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

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

.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: .9rem 1rem 1rem;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  display: block; color: var(--muted);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 600;
}
.stat-value {
  display: block; font-size: 1.4rem; font-weight: 600;
  margin-top: .22rem; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

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

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

.tabs {
  display: flex; gap: .3rem;
  overflow-x: auto; scrollbar-width: none;
  padding: .3rem; margin: 0 -.3rem;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 99px;
}
.tabs::-webkit-scrollbar { display: none; }

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

.tabpanel { animation: fade .28s var(--ease) both; }

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

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .62rem .9rem;
  font-size: .88rem;
  transition: background .16s, border-color .16s;
}
.list li:not(.empty):hover { background: var(--surface-3); }
.list li.empty {
  color: var(--muted); background: transparent;
  border: 1px dashed var(--line);
  justify-content: center; padding: 1.1rem;
  font-size: .85rem;
}
.list .meta { color: var(--muted); font-size: .77rem; font-variant-numeric: tabular-nums; }
.list .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .right { display: flex; align-items: center; gap: .6rem; flex: none; }

.icon-btn {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: .3rem; border-radius: 7px;
  display: grid; place-items: center;
  transition: color .16s, background .16s;
}
.icon-btn:hover { color: var(--danger); background: rgba(220, 106, 106, .12); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; }

/* ---------------------------------------------------------------- bloqueo */

.locked {
  display: flex; gap: .85rem; align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.15rem;
}
.locked svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); flex: none; margin-top: .1rem; }
.locked strong { display: block; font-size: .9rem; margin-bottom: .2rem; }
.locked span { color: var(--muted); font-size: .84rem; }

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

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

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

.chips { display: flex; flex-wrap: wrap; gap: .38rem; margin-top: .85rem; }
.chip {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px;
  color: var(--muted); font-size: .77rem; padding: .3rem .72rem; cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transition: color .16s, border-color .16s, background .16s;
}
.chip:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

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

.dropzone {
  display: grid; place-items: center; gap: .25rem;
  margin-top: 1.1rem; padding: 1.9rem 1rem;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: .84rem; text-align: center; cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s var(--ease);
}
.dropzone svg { width: 22px; height: 22px; fill: none; stroke: currentColor; margin-bottom: .35rem; }
.dropzone strong { color: var(--text); font-size: .92rem; }
.dropzone:hover { border-color: var(--muted); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }

/* ----------------------------------------------------------------- modal */

.modal {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(400px, calc(100vw - 2.5rem));
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(4, 6, 9, .68); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .26s var(--ease) both; }
.modal[open]::backdrop { animation: fade .26s var(--ease) both; }

.modal-inner { padding: 1.5rem 1.5rem 1.25rem; margin: 0; }
.modal-inner p { color: var(--text-2); font-size: .9rem; margin: 0 0 1.5rem; }
.modal-actions { display: flex; gap: .55rem; justify-content: flex-end; }
.modal-actions .btn { min-width: 96px; }

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

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

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

/* --------------------------------------------------------------- animacion */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }
@keyframes pulse { 50% { opacity: .45; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
