/* Breakpoints del panel (coinciden con equipo.css):
   <= 900px  tablet / movil en horizontal -> objetivos tactiles, sin colapsar layout
   <= 640px  movil -> apilado de una columna, cabeceras compactas
   No se toca nada fuera de estas media queries salvo arreglos que no
   cambian el aspecto en escritorio (safe-area, foco visible, dvh con
   fallback a vh, overflow-wrap). */

/* El atributo hidden tiene que ganar a cualquier display que definamos despues.
   Sin !important, una regla posterior con la misma especificidad lo anula. */
[hidden] { display: none !important; }

:root {
  --bg: #0d1117; --panel: #161b22; --line: #262d36;
  --text: #e6edf3; --muted: #8b949e;
  --accent: #3fb950; --warn: #d29922; --bad: #f85149; --link: #58a6ff;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: break-word; /* textos largos/urls no fuerzan scroll horizontal */
}

/* Foco de teclado visible en cualquier control, en cualquier vista.
   :focus-visible no salta con el raton, asi que en escritorio no cambia nada. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px;
}
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
code { background: #1f242c; padding: .1em .35em; border-radius: 4px; }
a { color: var(--link); }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; row-gap: 8px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
  /* sticky de verdad: respeta el notch/isla en movil sin cambiar nada en escritorio */
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}
.brand { font-weight: 600; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.grid {
  display: grid; gap: 16px; padding: 20px; max-width: 1400px; margin: 0 auto;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.card.wide { grid-column: 1 / -1; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
footer { padding: 0 20px 24px; max-width: 1400px; margin: 0 auto; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error {
  color: var(--bad); background: rgba(248,81,73,.1);
  border: 1px solid rgba(248,81,73,.3); padding: 8px 10px; border-radius: 6px;
}

.metric { margin-bottom: 12px; }
.metric-head { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 13px; }
.metric-detail { color: var(--muted); }
.bar { height: 6px; background: #21262d; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); transition: width .4s ease; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--bad); }
.kv {
  display: flex; justify-content: space-between;
  padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px;
}
.kv span:first-child { color: var(--muted); }

.row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.row:last-of-type { border-bottom: none; }
.row-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pill {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 20px;
  font-size: 11px; background: #21262d; color: var(--muted);
}
.pill.live { background: rgba(63,185,80,.15); color: var(--accent); }

.btn {
  background: #21262d; color: var(--text); border: 1px solid var(--line);
  padding: 7px 13px; border-radius: 6px; cursor: pointer; font-size: 13px;
  text-decoration: none; display: inline-block; transition: background .15s, border-color .15s;
}
.btn:hover { background: #2d333b; border-color: #3d444d; }
.btn.primary { background: #238636; border-color: #2ea043; font-weight: 500; }
.btn.primary:hover { background: #2ea043; }
.btn.danger:hover { background: rgba(248,81,73,.15); border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.input {
  background: #0d1117; border: 1px solid var(--line); color: var(--text);
  padding: 7px 10px; border-radius: 6px; font-size: 13px; min-width: 180px;
}
.input:focus { outline: none; border-color: var(--link); }

.terminal-frame {
  height: 60vh; height: 60dvh; min-height: 380px; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; background: #000;
}
.terminal-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

.centered {
  display: grid; place-items: center; padding: 20px;
  min-height: 100vh; min-height: 100dvh; /* barra del navegador movil */
}
.login { width: min(360px, 100%); display: grid; gap: 14px; }
.login h1 { margin: 0 0 4px; font-size: 20px; display: flex; align-items: center; gap: 9px; }
.login label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login .input { width: 100%; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 24px); text-align: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.5); z-index: 50;
}
.toast.bad { border-color: var(--bad); color: var(--bad); }

/* Tactil: objetivos >= 44x44 y sin zoom automatico de iOS en los campos.
   Se aplica tambien a tablet (900px) porque ahi tambien se usa con el dedo. */
@media (max-width: 900px) {
  .btn, a.btn {
    min-height: 44px; padding: 10px 16px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .input { min-height: 44px; padding: 10px 12px; }
  .input, input, select, textarea { font-size: 16px; }
  .row { flex-wrap: wrap; row-gap: 8px; }
}

@media (max-width: 640px) {
  .grid { padding: 12px; gap: 12px; grid-template-columns: 1fr; }
  .terminal-frame { height: 70vh; height: 70dvh; }

  /* Cabecera del panel: si no cabe todo en una fila, que baje en bloques
     enteros (marca / acciones) en vez de desbordar o solaparse. */
  .topbar { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; gap: 8px; row-gap: 8px; }
  .topbar .muted.small { display: none; } /* el usuario no es imprescindible en pantalla pequena */
}

/* Fichas del equipo en el panel */
.fichas { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.ficha {
  display: flex; gap: 10px; align-items: center;
  background: #1a1f27; border: 1px solid var(--line); border-radius: 8px; padding: 10px;
}
.ficha .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 13px;
}
.ficha.activa { border-color: var(--accent); background: rgba(63,185,80,.07); }
.pulso-mini {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-left: 6px;
  animation: pulso-mini 1.4s ease-in-out infinite;
}
@keyframes pulso-mini { 0%,100% { opacity:.3 } 50% { opacity:1 } }
