/* Power Off 2 Web — tema oscuro, mismo lenguaje visual que la app de Windows */
:root {
  --bg: #16161a;
  --surface: #1d1d22;
  --card: #26262c;
  --card-2: #2d2d34;
  --line: rgba(255,255,255,.08);
  --text: #ececef;
  --muted: #9a9aa6;
  --accent: #3b82f6;
  --green: #30a46c;
  --red: #e5484d;
  --orange: #f97316;
  --amber: #f5a524;
  --purple: #a855f7;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ---------- Botones y formularios ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: background .15s, border-color .15s;
}
.btn:hover { background: #35353d; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.btn-primary:hover { background: #4f8ff7; }
.btn-danger { color: #ff8a8e; }
.btn-danger:hover { background: rgba(229,72,77,.18); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
input, select {
  display: block; width: 100%; margin-top: 6px; padding: 9px 12px; font: inherit; color: var(--text);
  background: #1a1a1f; border: 1px solid var(--line); border-radius: 8px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.form-error { background: rgba(229,72,77,.14); color: #ff9da0; padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; }

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100%; padding: 20px;
  background: radial-gradient(900px 500px at 50% -10%, rgba(59,130,246,.12), transparent), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px 28px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.login-card h1 { font-size: 22px; margin-top: 14px; }
.login-card p { margin: 4px 0 24px; }
.login-card form { text-align: left; }
.login-logo img { display: block; margin: 0 auto; }

/* ---------- Estructura de la app ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 600; font-size: 15px; }
.brand img { width: 26px; height: 26px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.nav a svg { width: 18px; height: 18px; opacity: .85; flex: none; }
.nav a:hover { background: rgba(255,255,255,.05); }
.nav a.active { background: var(--card-2); box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; font-weight: 600; flex: none; }
.who { min-width: 0; flex: 1; }
.who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12px; color: var(--muted); }
.main { padding: 26px 30px 40px; min-width: 0; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Tarjetas, puntos y píldoras ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h3 { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 8px; letter-spacing: .02em; }
.card .value { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #555b64; flex: none; display: inline-block; }
.dot.green { background: var(--green); } .dot.red { background: var(--red); } .dot.orange { background: var(--orange); }
.dot.amber { background: var(--amber); } .dot.purple { background: var(--purple); } .dot.blue { background: var(--accent); }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px; font-size: 12px; background: var(--card-2); }
.pill.online { background: rgba(48,164,108,.16); color: #5fd39b; }
.pill.offline { background: rgba(229,72,77,.14); color: #ff8a8e; }
.pill.pending { background: rgba(245,165,36,.15); color: var(--amber); }

.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Tarjeta de equipo */
.device { cursor: pointer; transition: transform .12s, border-color .12s; display: flex; flex-direction: column; gap: 12px; }
.device:hover { border-color: rgba(255,255,255,.2); transform: translateY(-1px); }
.device .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.device .name { font-size: 16px; font-weight: 600; word-break: break-word; }
.device .rid { font-family: var(--mono); color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.device .flags { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.device .flags span { display: inline-flex; align-items: center; gap: 6px; }
.device .foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); padding-top: 10px; gap: 8px; }

.banner { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 8px; margin-bottom: 14px; }
.banner.alarm { background: rgba(229,72,77,.16); color: #ffb0b3; }
.banner.info { background: rgba(59,130,246,.14); color: #a9c8ff; }

/* ---------- Tablas ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .row-actions { text-align: right; white-space: nowrap; }
.table-wrap { padding: 0; overflow-x: auto; }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

pre.json { background: #121216; border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow: auto; max-height: 60vh;
  font: 12.5px/1.5 var(--mono); color: #d7d7dc; margin: 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }

/* ---------- Modal y avisos ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: 0 24px 70px rgba(0,0,0,.55); }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.copyrow { display: flex; gap: 8px; align-items: center; }
.copyrow input { margin: 0; font-family: var(--mono); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--card-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.toast.ok { border-left-color: var(--green); } .toast.err { border-left-color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty svg { width: 42px; height: 42px; opacity: .5; margin-bottom: 10px; }

/* ---------- Móvil ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; gap: 8px; overflow-x: auto; }
  .brand { padding: 4px 8px; } .brand span { display: none; }
  .nav { flex-direction: row; } .nav a { padding: 8px 10px; } .nav a span { display: none; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; } .who { display: none; }
  .main { padding: 18px 14px 34px; }
}

/* ---------- Ficha de equipo: log, consola, robot en vivo ---------- */
.sev1 { color: var(--amber); } .sev2 { color: #ff8a8e; }
.logbox { padding: 6px 4px; max-height: 68vh; overflow: auto; font: 12px/1.5 var(--mono); }
.logrow { display: grid; grid-template-columns: 190px 56px 116px 1fr; gap: 10px; padding: 2px 12px; }
.logrow span:last-child { word-break: break-word; }
.logrow:hover { background: rgba(255,255,255,.04); }

.console-wrap { display: grid; grid-template-columns: 330px 1fr; gap: 14px; align-items: start; }
.cmdlist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; max-height: 74vh; overflow: auto; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.legend .dot + .dot, .legend .dot { margin-left: 6px; }
.cmdgroup h4 { margin: 14px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cmd { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: 0; color: var(--text);
  font: inherit; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.cmd:hover { background: rgba(255,255,255,.06); }
.cmd span { display: flex; flex-direction: column; min-width: 0; }
.cmd b { font-size: 13px; font-weight: 500; }
.cmd small { color: var(--muted); font-size: 12px; }

.terminal { background: #0e1014; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 440px; height: 74vh; }
.term-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font: 13px var(--mono); color: var(--muted); }
.term-out { flex: 1; overflow: auto; padding: 12px 14px; font: 13px/1.5 var(--mono); }
.tline { display: grid; grid-template-columns: 70px 14px 1fr; gap: 6px; padding: 1px 0; }
.tline .ts { opacity: .45; } .tline .tx { white-space: pre-wrap; word-break: break-word; }
.tline.cmd { color: #7dd3fc; } .tline.ok { color: var(--green); } .tline.err { color: var(--red); } .tline.info { color: #9aa0a6; }
.term-in { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.term-in input { margin: 0; flex: 1; }

.iorow { display: flex; gap: 10px; margin-top: 4px; }
.iorow span { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.iorow small { color: var(--muted); font-size: 11px; }
.legend2 { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; margin-bottom: 4px; color: var(--text); }
.legend2 i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.chart { width: 100%; height: auto; display: block; }
.table td.sev1 { color: var(--amber); } .table td.sev2 { color: #ff8a8e; }

@media (max-width: 900px) {
  .console-wrap { grid-template-columns: 1fr; }
  .cmdlist { max-height: 38vh; }
  .logrow { grid-template-columns: 1fr; gap: 0; padding: 4px 12px; }
}

/* ---------- Marca y detalles de diseño ---------- */
body { background: radial-gradient(1100px 520px at 85% -12%, rgba(229,72,77,.07), transparent 60%), var(--bg); background-attachment: fixed; }
.brand img { width: 30px; height: 30px; object-fit: contain; filter: drop-shadow(0 2px 8px rgba(229,72,77,.35)); }
.brand { gap: 11px; padding-bottom: 20px; }
.brand b { display: block; font-size: 15px; line-height: 1.15; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; letter-spacing: .04em; }
.sidebar { background: linear-gradient(180deg, #1f1f25 0%, #1a1a1f 100%); }
.main { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.login-body { background: radial-gradient(800px 420px at 50% -5%, rgba(229,72,77,.16), transparent 65%), radial-gradient(900px 500px at 50% 110%, rgba(59,130,246,.10), transparent), var(--bg); }
.login-card { backdrop-filter: blur(6px); animation: rise .5s ease both; }
.login-logo img { filter: drop-shadow(0 6px 22px rgba(229,72,77,.45)); margin-bottom: 4px; }
.login-card h1 { letter-spacing: .01em; }

/* Resumen de equipos */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); font: inherit;
  cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: border-color .15s, transform .12s, background .15s; }
.stat:hover { border-color: rgba(255,255,255,.22); transform: translateY(-1px); }
.stat.sel { border-color: var(--accent); background: linear-gradient(180deg, rgba(59,130,246,.14), var(--card)); }
.stat-n { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--c); font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.toolbar { margin-bottom: 16px; }
.toolbar input { margin: 0; max-width: 420px; padding-left: 14px; }

/* Tarjetas de equipo con acento de estado */
.device { position: relative; overflow: hidden; }
.device::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: #555b64; }
.device[data-state="online"]::before { background: var(--green); }
.device[data-state="offline"]::before { background: var(--red); }
.device[data-state="pending"]::before { background: var(--amber); }
.device.alarm { border-color: rgba(229,72,77,.55); box-shadow: 0 0 0 1px rgba(229,72,77,.25), 0 8px 28px rgba(229,72,77,.12); }
.device[data-state="offline"] { opacity: .8; }
.device:hover { box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.pill.online .dot { animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(48,164,108,.55); } 70% { box-shadow: 0 0 0 7px rgba(48,164,108,0); } 100% { box-shadow: 0 0 0 0 rgba(48,164,108,0); } }

/* Pestañas y pie */
.tabs button { border-radius: 8px 8px 0 0; transition: color .15s, background .15s; }
.tabs button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.card { transition: border-color .15s; }
