/* IoT Hub — tema "sala de control"
   Paleta: fondo azul-pizarra profundo, paneles con borde tenue,
   acento COBRE (pistas de PCB) y LED verde de estado. */
:root {
  --fondo: #0d1117;
  --fondo-2: #131a24;
  --panel: #18212e;
  --borde: #26313f;
  --texto: #dbe4ee;
  --texto-2: #8b98a8;
  --cobre: #d98e4a;          /* pista de cobre */
  --cobre-osc: #b06f33;
  --led-on: #4ade80;
  --led-off: #64748b;
  --peligro: #e0604f;
  --radio: 10px;
  --f-display: 'Chakra Petch', sans-serif;
  --f-body: 'Inter', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font-family: var(--f-body); font-size: 15px; line-height: 1.5;
  background-image: radial-gradient(circle at 20% -10%, #16202e 0%, transparent 50%);
}
h1, h2, .marca, .dev-nombre { font-family: var(--f-display); }
h1 { font-size: 1.5rem; margin: 0 0 .4rem; display: flex; align-items: center; gap: .6rem; }
h2 { font-size: 1.02rem; margin: 0 0 .7rem; color: var(--texto); letter-spacing: .02em; }
.mono { font-family: var(--f-mono); font-size: .82rem; }
a { color: var(--cobre); text-decoration: none; }
code { font-family: var(--f-mono); background: var(--fondo-2); padding: 1px 5px; border-radius: 4px; font-size: .8em; }

/* ── Navegación ─────────────────────────────── */
.nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: .7rem 1.3rem; border-bottom: 1px solid var(--borde);
  background: rgba(13,17,23,.85); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.marca { font-size: 1.15rem; color: var(--texto); display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.marca b { color: var(--cobre); font-weight: 700; }
.marca-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--led-on); box-shadow: 0 0 8px var(--led-on);
  animation: latido 2.4s ease-in-out infinite;
}
.marca-dot.grande { width: 16px; height: 16px; }
@keyframes latido { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .marca-dot, .led-on { animation: none !important; } }
.nav-der { display: flex; align-items: center; gap: 1rem; }
.nav-link { color: var(--texto-2); }
.nav-link:hover { color: var(--texto); }
.nav-user { display: inline-flex; align-items: center; gap: .45rem; color: var(--texto-2); font-size: .88rem; }
.nav-user img { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--borde); }

/* ── Layout ─────────────────────────────────── */
.cont { max-width: 1100px; margin: 0 auto; padding: 1.6rem 1.3rem 4rem; }
.fila-titulo { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.volver { font-size: .85rem; color: var(--texto-2); display: inline-block; margin-bottom: .3rem; }
.tarjeta {
  background: var(--panel); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.dev-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.1rem; align-items: start; }
@media (max-width: 860px) { .dev-layout { grid-template-columns: 1fr; } }

/* ── Tarjetas de dispositivo (módulos PCB) ──── */
.grid-dev { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.dev-card {
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 1rem 1.1rem; color: var(--texto); position: relative; overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.dev-card::before { /* pista de cobre en el borde izquierdo */
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--cobre), var(--cobre-osc));
}
.dev-card:hover { border-color: var(--cobre-osc); transform: translateY(-2px); }
.dev-top { display: flex; align-items: center; gap: .55rem; margin-bottom: .5rem; }
.dev-tipo { color: var(--texto-2); letter-spacing: .08em; font-size: .72rem; }
.dev-nombre { font-size: 1.08rem; margin: 0 0 .45rem; font-weight: 600; }
.dev-meta { color: var(--texto-2); font-size: .74rem; }

.led { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.led-on { background: var(--led-on); box-shadow: 0 0 7px var(--led-on); animation: latido 2s infinite; }
.led-off { background: var(--led-off); }
.led-neutro { background: var(--cobre); box-shadow: 0 0 6px rgba(217,142,74,.5); }

.vacio { text-align: center; padding: 3.2rem 1rem; border: 1px dashed var(--borde); border-radius: var(--radio); }
.vacio-sub { color: var(--texto-2); max-width: 560px; margin: .5rem auto 0; font-size: .9rem; }

/* ── Botones ────────────────────────────────── */
.btn {
  font-family: var(--f-body); font-size: .87rem; font-weight: 500;
  background: var(--fondo-2); color: var(--texto);
  border: 1px solid var(--borde); border-radius: 8px;
  padding: .5rem .95rem; cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--cobre-osc); }
.btn:focus-visible { outline: 2px solid var(--cobre); outline-offset: 2px; }
.btn-primario { background: var(--cobre); border-color: var(--cobre); color: #1a1208; font-weight: 600; }
.btn-primario:hover { background: var(--cobre-osc); }
.btn-peligro { color: var(--peligro); border-color: rgba(224,96,79,.4); }
.btn-peligro:hover { background: rgba(224,96,79,.12); border-color: var(--peligro); }
.btn-google { display: inline-flex; align-items: center; gap: .6rem; background: #fff; color: #1f2937; border: none; font-weight: 600; padding: .65rem 1.3rem; }
.btn-cmd { min-width: 96px; text-transform: capitalize; }
.btn:disabled { opacity: .6; cursor: wait; }

/* ── Login ──────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card {
  background: var(--panel); border: 1px solid var(--borde); border-radius: 14px;
  padding: 2.4rem 2.2rem; text-align: center; max-width: 400px; width: 100%;
}
.login-card h1 { justify-content: center; font-size: 1.9rem; }
.login-card h1 b { color: var(--cobre); }
.login-logo { margin-bottom: .6rem; display: flex; justify-content: center; }
.login-sub { color: var(--texto-2); font-size: .9rem; margin-bottom: 1.5rem; }
.alerta { background: rgba(224,96,79,.14); border: 1px solid rgba(224,96,79,.4); color: #f3b0a7; border-radius: 8px; padding: .6rem .9rem; margin-bottom: 1rem; font-size: .87rem; }

/* ── Formularios ────────────────────────────── */
label { display: block; margin-bottom: .8rem; font-size: .86rem; color: var(--texto-2); }
input, select {
  display: block; width: 100%; margin-top: .3rem;
  background: var(--fondo-2); color: var(--texto);
  border: 1px solid var(--borde); border-radius: 8px; padding: .5rem .7rem;
  font-family: var(--f-body); font-size: .9rem;
}
input:focus, select:focus { outline: none; border-color: var(--cobre); }
small { color: var(--texto-2); }

.dlg { background: var(--panel); color: var(--texto); border: 1px solid var(--borde); border-radius: 12px; padding: 1.4rem 1.5rem; width: min(480px, 92vw); }
.dlg::backdrop { background: rgba(0,0,0,.6); }
.dlg-botones { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* ── Vista dispositivo ──────────────────────── */
.video-marco { background: #000; border-radius: 8px; overflow: hidden; border: 1px solid var(--borde); }
.video-marco img { display: block; width: 100%; min-height: 200px; object-fit: contain; color: var(--texto-2); padding: .5rem; }
.nota { color: var(--texto-2); font-size: .82rem; }
.pad-control { display: flex; flex-wrap: wrap; gap: .55rem; margin: .8rem 0; }
.fila-cmd { display: flex; gap: .55rem; margin-top: .6rem; }
.fila-cmd input { flex: 1; margin-top: 0; }
.acks { color: var(--led-on); margin-top: .5rem; min-height: 1.2em; font-size: .78rem; }

.token-caja {
  background: var(--fondo-2); border: 1px dashed var(--cobre-osc); border-radius: 8px;
  padding: .55rem .7rem; word-break: break-all; cursor: copy; font-size: .78rem;
  transition: background .15s;
}
.token-caja.copiado { background: rgba(74,222,128,.15); border-color: var(--led-on); }
.etiqueta { margin: .7rem 0 .15rem; letter-spacing: .06em; font-size: .7rem; text-transform: uppercase; }
.endpoints { background: var(--fondo-2); border-radius: 8px; padding: .55rem .7rem; font-size: .74rem; overflow-x: auto; white-space: nowrap; }
.endpoints div { padding: .1rem 0; }

/* ── Tablas ─────────────────────────────────── */
.tel-tabla-wrap { max-height: 380px; overflow: auto; }
.tel-tabla { width: 100%; border-collapse: collapse; font-size: .8rem; }
.tel-tabla th { text-align: left; color: var(--texto-2); font-weight: 500; padding: .35rem .5rem; border-bottom: 1px solid var(--borde); position: sticky; top: 0; background: var(--panel); }
.tel-tabla td { padding: .32rem .5rem; border-bottom: 1px solid rgba(38,49,63,.5); }
.admin-tabla { font-family: var(--f-body); font-size: .86rem; }
.fila-inactiva { opacity: .5; }

.pill { font-style: normal; font-size: .68rem; background: var(--fondo-2); border: 1px solid var(--borde); border-radius: 99px; padding: .1rem .5rem; color: var(--texto-2); }
.pill-ok { color: var(--led-on); border-color: rgba(74,222,128,.4); }
.pill-mal { color: var(--peligro); border-color: rgba(224,96,79,.4); }

/* ── Chat asistente IA ──────────────────────── */
.chat-ia { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; margin: .7rem 0; }
.chat-ia:empty { display: none; }
.msg { border-radius: 10px; padding: .55rem .8rem; font-size: .85rem; white-space: pre-wrap; max-width: 92%; }
.msg-yo { background: var(--fondo-2); align-self: flex-end; border: 1px solid var(--borde); }
.msg-ia { background: rgba(217,142,74,.09); border: 1px solid rgba(217,142,74,.25); align-self: flex-start; font-family: var(--f-mono); font-size: .78rem; }

/* ── Banner de plan ─────────────────────────── */
.banner-plan {
  margin-top: 1.6rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: linear-gradient(90deg, rgba(217,142,74,.14), transparent 70%);
  border: 1px solid rgba(217,142,74,.35); border-radius: var(--radio); padding: .9rem 1.1rem;
  flex-wrap: wrap;
}
.banner-plan.suave { background: var(--panel); border-color: var(--borde); color: var(--texto-2); }
