/* =========================================================
   IPAM — sistema visual
   Oscuro: negro y grises · Claro: azul y blanco
   ========================================================= */
:root {
  /* Claro: azul y blanco, suave y legible (sin blancos puros ni azul saturado) */
  --bg: #c5cfdd;
  --bg-grid: transparent;
  --surface: #f7f9fc;
  --surface-2: #e7ecf3;
  --surface-glass: rgba(236, 241, 247, 0.82);
  --border: #c3cddb;
  --border-strong: #a6b3c7;
  --text: #17233a;
  --muted: #4d5b73;
  --faint: #76839a;
  --accent: #2f5fc4;
  --accent-hover: #264fa8;
  --accent-soft: rgba(47, 95, 196, 0.1);
  --on-accent: #ffffff;
  --ring: rgba(47, 95, 196, 0.25);
  --ok: #1f8a4c;
  --ok-soft: rgba(31, 138, 76, 0.12);
  --warn: #a5620f;
  --warn-soft: rgba(165, 98, 15, 0.1);
  --danger: #b4332b;
  --danger-soft: rgba(180, 51, 43, 0.09);
  --cell-free: #d9e0eb;
  --cell-used: #3d6cd0;
  --cell-gw: #17233a;
  --shadow: 0 1px 2px rgba(23, 35, 58, 0.08), 0 8px 22px rgba(23, 35, 58, 0.1);
  --shadow-lg: 0 24px 60px rgba(23, 35, 58, 0.2);
  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}

/* El tema se fija en <html data-theme> desde el script del <head> (preferencia guardada o la del sistema) */
:root[data-theme="dark"] {
  --bg: #08080a;
  --bg-grid: rgba(255, 255, 255, 0.035);
  --surface: #111114;
  --surface-2: #18181c;
  --surface-glass: rgba(17, 17, 20, 0.66);
  --border: #26262c;
  --border-strong: #3a3a42;
  --text: #f2f2f4;
  --muted: #a3a3ad;
  --faint: #6e6e78;
  --accent: #e8e8ec;
  --accent-hover: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.07);
  --on-accent: #0a0a0c;
  --ring: rgba(255, 255, 255, 0.22);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.1);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.1);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.1);
  --cell-free: #17171b;
  --cell-used: #a1a1aa;
  --cell-gw: #f2f2f4;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}
.mono { font-family: var(--mono); }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  view-transition-name: brand-mark;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-family: var(--mono); font-weight: 700; letter-spacing: 0.14em; font-size: 15px; }
.brand-sub { font-family: var(--mono); font-size: 10.5px; color: var(--faint); letter-spacing: 0.08em; }

/* ---------- Barra superior (blur) ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 24px;
  background: var(--surface-glass);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border);
}
.appbar-right { display: flex; align-items: center; gap: 10px; }

/* ---------- Dock con magnificación ---------- */
.dock {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 6px 8px; height: 50px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.dock-item {
  --s: 1;
  position: relative;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--muted);
  cursor: pointer;
  transform: scale(var(--s)); transform-origin: bottom center;
  margin: 0 calc((var(--s) - 1) * 9px);
  transition: transform 0.18s var(--ease), margin 0.18s var(--ease), background 0.2s, color 0.2s;
}
.dock-item svg { width: 18px; height: 18px; }
.dock-item:hover { color: var(--text); background: var(--accent-soft); }
.dock-item[aria-current="true"] { color: var(--text); background: var(--accent-soft); border-color: var(--border); }
.dock-item[aria-current="true"]::after {
  content: ""; position: absolute; bottom: -5px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.dock-item .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; translate: -50% 4px;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  font-size: 11px; font-family: var(--mono);
  background: var(--text); color: var(--bg);
  opacity: 0; pointer-events: none; transition: opacity 0.15s, translate 0.15s;
}
.dock .dock-item .tip { bottom: auto; top: calc(100% + 10px); translate: -50% -4px; }
.dock-item:hover .tip { opacity: 1; translate: -50% 0; }
.dock-item .tip { scale: calc(1 / var(--s)); transform-origin: top center; }

/* ---------- Botones e inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, transform 0.1s, box-shadow 0.2s;
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus-visible, .dock-item:focus-visible, .cell:focus-visible, .row:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--ring);
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--accent-soft); }
.btn-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn-block { width: 100%; height: 44px; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

.field { display: grid; gap: 6px; }
.label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.input {
  width: 100%; height: 42px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
textarea.input { height: 76px; padding: 10px 14px; resize: vertical; }
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); background: var(--surface); }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 13px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.input-wrap > .input { padding-left: 40px; }
.input-row { display: flex; gap: 8px; }

/* ---------- Layout del panel ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.view { display: none; }
.view.active { display: block; }

.banner {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 14px; margin-bottom: 18px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--warn); font-size: 13px; border: 1px solid transparent;
}
.banner svg { width: 16px; height: 16px; flex: none; }

/* ---------- Tarjetas ---------- */
.grid-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-top: 14px; }
.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { margin: 0; font-size: 14px; font-weight: 600; }
.card-meta { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.stat-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); display: flex; align-items: center; gap: 8px; }
.stat-label svg { width: 14px; height: 14px; }
.stat-value { font-family: var(--mono); font-size: 28px; font-weight: 600; margin-top: 10px; letter-spacing: -0.02em; }
.stat-foot { margin-top: 6px; font-size: 12px; color: var(--muted); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 12px; border: 1px solid var(--border); }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width 0.6s var(--ease); }

/* Crossfade del contenido de una tarjeta al actualizarse */
.xf-host { position: relative; }
.xf-old { position: absolute; inset: 0; pointer-events: none; animation: xf-out 0.38s var(--ease) forwards; }
.xf-new { animation: xf-in 0.38s var(--ease); }
@keyframes xf-out { to { opacity: 0; filter: blur(2px); } }
@keyframes xf-in { from { opacity: 0; filter: blur(2px); } }

/* Crossfade de las tarjetas al cambiar de vista (fallback sin View Transitions) */
.view.entering .card { animation: card-in 0.42s var(--ease) both; }
.view.entering .card:nth-child(2) { animation-delay: 0.04s; }
.view.entering .card:nth-child(3) { animation-delay: 0.08s; }
.view.entering .card:nth-child(4) { animation-delay: 0.12s; }
@keyframes card-in { from { opacity: 0; } }

/* ---------- Tabla de dispositivos ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input-wrap { flex: 1; min-width: 220px; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-family: var(--mono); font-weight: 500; font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint);
  padding: 0 14px 10px; border-bottom: 1px solid var(--border);
}
.row { cursor: pointer; transition: background 0.15s; }
.row td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.row:last-child td { border-bottom: 0; }
.row:hover { background: var(--accent-soft); }
.ip-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-weight: 600; font-size: 13px;
}
.ip-chip::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--st-unk); box-shadow: 0 0 0 3px var(--st-unk-soft); transition: background 0.4s, box-shadow 0.4s; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 42px 16px; color: var(--muted); font-size: 13.5px; }
.empty svg { width: 28px; height: 28px; color: var(--faint); margin-bottom: 8px; }
.list-compact { display: grid; gap: 2px; }
.list-compact .row { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px; border-radius: 9px; font-size: 13.5px; }

/* ---------- Mapa de subred ---------- */
.map { display: grid; grid-template-columns: repeat(32, minmax(0, 1fr)); gap: 4px; }
.cell {
  aspect-ratio: 1; border-radius: 4px; border: 0; padding: 0; cursor: pointer;
  background: var(--cell-free); outline: 1px solid var(--border); outline-offset: -1px;
  transition: transform 0.15s var(--ease), background 0.3s;
}
.cell:hover { transform: scale(1.35); z-index: 1; position: relative; }
.cell.used { background: var(--cell-used); outline-color: transparent; }
.cell.gw { background: var(--cell-gw); outline-color: transparent; cursor: default; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; outline: 1px solid var(--border); outline-offset: -1px; }

/* ---------- Modales y menús (blur) ---------- */
dialog.modal {
  width: min(480px, calc(100vw - 32px));
  padding: 0; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface-glass); color: var(--text);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop {
  background: rgba(5, 8, 15, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
dialog.modal[open] { animation: modal-in 0.32s var(--ease); }
dialog.modal[open]::backdrop { animation: fade-in 0.3s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 12px 20px 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 0; }
.detail-ip { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 10px 14px; font-size: 13.5px; }
.kv dt { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); padding-top: 2px; }
.kv dd { margin: 0; word-break: break-word; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 210px; z-index: 40;
  padding: 6px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-4px) scale(0.98); transform-origin: top right;
  pointer-events: none; transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 8px; border: 0; background: transparent;
  font-size: 13.5px; text-align: left; text-decoration: none; cursor: pointer; color: var(--text);
}
.menu-item:hover { background: var(--accent-soft); }
.menu-item svg { width: 16px; height: 16px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; translate: -50% 20px; z-index: 60;
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px;
  background: var(--surface-glass); border: 1px solid var(--border);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease), translate 0.25s var(--ease);
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.auth-top { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; }
.auth-main { display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); padding: 32px; }
.auth-card h1 { margin: 18px 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.auth-card p.lead { margin: 0 0 24px; color: var(--muted); font-size: 13.5px; }
.auth-form { display: grid; gap: 16px; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; background: var(--danger-soft); color: var(--danger); }
.terminal { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--border); line-height: 1.8; }
.terminal .ok { color: var(--ok); }
.terminal .ln { opacity: 0; animation: ln-in 0.3s var(--ease) forwards; }
@keyframes ln-in { to { opacity: 1; } }
.terminal .ln:nth-child(2) { animation-delay: 0.25s; }
.terminal .ln:nth-child(3) { animation-delay: 0.5s; }
body.login-page { background-image: none; }
.auth-foot { padding: 18px 24px; text-align: center; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.status-dot { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

/* ---------- View Transitions (crossfade + elementos compartidos) ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.35s; animation-timing-function: var(--ease); }
::view-transition-group(*) { animation-duration: 0.4s; animation-timing-function: var(--ease); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .map { grid-template-columns: repeat(16, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .appbar { padding: 8px 16px; }
  .brand-sub { display: none; }
  .page { padding: 20px 16px 48px; }
  .grid-stats { gap: 10px; }
  .stat-value { font-size: 22px; }
  .hide-sm { display: none; }
  .dock { gap: 2px; }
  .auth-card { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}


/* =========================================================
   Fondo de circuito en el panel
   ========================================================= */
#circuit-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#circuit-bg.circuit-soft { opacity: 0.75; }
body.has-circuit { background-image: none; }
body.has-circuit .page { position: relative; z-index: 1; }
body.has-circuit .card {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
}

/* =========================================================
   Selector de red
   ========================================================= */
.netbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.seg {
  position: relative; display: flex; gap: 4px; padding: 4px; min-width: 0;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg-item {
  position: relative; z-index: 1; flex: none;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 7px 14px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); cursor: pointer; text-align: left; transition: color 0.2s;
}
.seg-item[aria-selected="true"] { color: var(--on-accent); }
.seg-name { font-size: 13px; font-weight: 600; }
.seg-cidr { font-size: 11px; opacity: 0.85; }
.seg-thumb {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px;
  border-radius: 9px; background: var(--accent); box-shadow: 0 2px 10px var(--ring);
  transition: transform 0.35s var(--ease), width 0.35s var(--ease);
}
.btn-nets { flex: none; }

/* =========================================================
   Administrador de redes
   ========================================================= */
.modal-wide { width: min(560px, calc(100vw - 32px)); }
.nets-list { display: grid; gap: 6px; }
.net-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.net-row.is-current { border-color: var(--accent); }
.net-name { font-weight: 600; font-size: 14px; }
.net-meta { font-size: 11.5px; margin-top: 2px; }
.net-actions { display: flex; gap: 4px; flex: none; }
.net-form { display: grid; gap: 10px; padding-top: 14px; border-top: 1px dashed var(--border); }
.net-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.danger-text { color: var(--danger); }
.spacer { flex: 1; }
.modal-foot { align-items: center; }

/* Varios */
.list-scroll { max-height: 360px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.stat-ip { font-size: 20px; margin-top: 14px; }
.btn-inline { margin: 6px 0 0 -10px; height: 30px; }
.sm-only { display: none; }
.row-sub { font-size: 12px; margin-top: 3px; }
.dock-item .lbl { display: none; }
.page-sub.xf-host { min-height: 1.4em; }

/* =========================================================
   Celular: barra inferior tipo app, hojas inferiores, toques grandes
   ========================================================= */
@media (max-width: 720px) {
  body { -webkit-tap-highlight-color: transparent; }
  .appbar { padding: calc(8px + env(safe-area-inset-top)) 16px 8px; }
  .page { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 14px; }
  .page-title { font-size: 21px; }

  /* Dock → barra de navegación inferior */
  .dock {
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    height: 64px; padding: 6px; gap: 0; z-index: 40;
    justify-content: space-around; align-items: stretch;
    border-radius: 20px; box-shadow: var(--shadow-lg);
    backdrop-filter: blur(22px) saturate(170%); -webkit-backdrop-filter: blur(22px) saturate(170%);
  }
  .dock-item { flex: 1; width: auto; height: auto; flex-direction: column; gap: 3px; border-radius: 14px; transform: none; margin: 0; }
  .dock-item svg { width: 21px; height: 21px; }
  .dock-item .lbl { display: block; font-size: 10.5px; font-weight: 500; }
  .dock-item .tip { display: none; }
  .dock-item[aria-current="true"]::after { display: none; }
  .dock-item[aria-current="true"] { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
  .dock .dock-add { color: var(--on-accent); background: var(--accent); }
  .dock .dock-add:hover, .dock .dock-add:active { background: var(--accent-hover); color: var(--on-accent); }
  .appbar .dock-item { width: 42px; height: 42px; }

  .netbar { position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 20; margin: 0 -16px 16px; padding: 6px 16px; }
  .seg { flex: 1; }
  .btn-nets span { display: none; }
  .btn-nets { width: 46px; padding: 0; height: 46px; border-color: var(--border); background: var(--surface-glass); backdrop-filter: blur(14px); }

  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 14px; border-radius: 16px; }
  .stat-value { font-size: 24px; }
  .stat-ip { font-size: 16px; }
  .grid-2 { gap: 10px; margin-top: 10px; }

  .row td { padding: 14px 10px; }
  .table th { padding: 0 10px 10px; }
  .sm-only { display: block; }
  .list-compact .row { padding: 13px 10px; }
  .list-scroll { max-height: none; }
  .input { height: 48px; font-size: 16px; }
  .btn { height: 46px; }
  .toolbar .input-wrap { min-width: 0; }

  .map { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 5px; }
  .cell:hover { transform: none; }

  /* Modales como hoja inferior */
  dialog.modal, .modal-wide {
    width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0;
    border-radius: 22px 22px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom); overflow-y: auto;
  }
  dialog.modal[open] { animation: sheet-in 0.36s var(--ease); }
  .sheet-grip { width: 40px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 10px auto 0; }
  .net-grid { grid-template-columns: 1fr; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }
  .modal-foot .spacer { display: none; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet-grip { display: none; }
@media (max-width: 720px) { .sheet-grip { display: block; } }

/* Dock fuera del header (para que en el celular pueda fijarse abajo) */
[hidden] { display: none !important; }
.appbar { min-height: 70px; }
.dock { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 35; }
.net-grid { grid-template-columns: 1fr 1.25fr 1fr; }
@media (max-width: 720px) {
  .dock { top: auto; left: 10px; transform: none; }
  .appbar { min-height: 0; }
}

/* =========================================================
   Roles: se ocultan los controles que el usuario no puede usar
   ========================================================= */
body[data-role="lector"] .need-devices,
body[data-role="lector"] .need-import,
body:not([data-role="admin"]) .need-admin { display: none !important; }

/* Menú */
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.tag { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 500; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }

/* Importar */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 26px 16px; border: 1.5px dashed var(--border-strong); border-radius: 14px;
  background: var(--surface-2); color: var(--muted); cursor: pointer; text-align: center; font-size: 13.5px;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone svg { width: 26px; height: 26px; color: var(--accent); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.import-res { display: grid; gap: 10px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 6px 10px; border-radius: 9px; font-size: 13px; background: var(--accent-soft); color: var(--text); }
.pill b { font-family: var(--mono); margin-right: 2px; }
.pill.ok { background: var(--ok-soft); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.faint { background: var(--surface-2); color: var(--muted); }
.err-list { max-height: 180px; overflow-y: auto; font-size: 12.5px; color: var(--muted); display: grid; gap: 4px; padding: 10px; border-radius: 10px; background: var(--danger-soft); }
.err-list .mono { color: var(--danger); }

/* Usuarios */
.user-grid { grid-template-columns: 1fr 1fr 1fr 1.2fr; }
select.input { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8aa5' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input:disabled { opacity: 0.6; }
.toolbar .btn svg { flex: none; }

@media (max-width: 720px) {
  .user-grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: nowrap; }
  .toolbar .btn { width: 46px; padding: 0; flex: none; }
}

/* Ver/ocultar contraseña */
.pw-wrap { position: relative; }
.pw-wrap > .input { padding-right: 48px; }
.pw-toggle {
  position: absolute; right: 5px; top: 50%; translate: 0 -50%;
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 9px; background: transparent; color: var(--faint); cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.pw-toggle:hover, .pw-toggle[aria-pressed="true"] { color: var(--text); background: var(--accent-soft); }
.pw-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.pw-toggle svg { width: 19px; height: 19px; }

/* Áreas */
.area-chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.recent-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.area-filter { width: auto; min-width: 170px; flex: none; }
.areas-list { max-height: 50vh; overflow-y: auto; }
@media (max-width: 720px) {
  .toolbar { flex-wrap: wrap; }
  .toolbar .input-wrap { flex: 1 1 100%; order: -1; }
  .area-filter { flex: 1; min-width: 0; }
  .recent-right .area-chip { display: none; }
}

/* =========================================================
   Estado por ping
   ========================================================= */
:root {
  --st-up: #1f9d55;  --st-up-soft: rgba(31, 157, 85, 0.18);
  --st-down: #e08a00; --st-down-soft: rgba(224, 138, 0, 0.2);
  --st-lost: #d23a32; --st-lost-soft: rgba(210, 58, 50, 0.18);
  --st-unk: #8a94a6; --st-unk-soft: rgba(138, 148, 166, 0.18);
}
:root[data-theme="dark"] {
  --st-up: #4ade80; --st-up-soft: rgba(74, 222, 128, 0.15);
  --st-down: #fb9a26; --st-down-soft: rgba(251, 154, 38, 0.16);
  --st-lost: #f05252; --st-lost-soft: rgba(240, 82, 82, 0.16);
  --st-unk: #6b6b75; --st-unk-soft: rgba(107, 107, 117, 0.2);
}
.ip-chip.st-up::before { background: var(--st-up); box-shadow: 0 0 0 3px var(--st-up-soft); animation: st-pulse 2.6s ease-in-out infinite; }
.ip-chip.st-down::before { background: var(--st-down); box-shadow: 0 0 0 3px var(--st-down-soft); }
.ip-chip.st-lost::before { background: var(--st-lost); box-shadow: 0 0 0 3px var(--st-lost-soft); }
@keyframes st-pulse { 50% { box-shadow: 0 0 0 5px transparent; } }
.dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--st-unk); }
.dot.st-up { background: var(--st-up); } .dot.st-down { background: var(--st-down); }
.dot.st-lost { background: var(--st-lost); } .dot.st-unk { background: var(--st-unk); }
.legend i.dot { width: 10px; height: 10px; outline: 0; }
.status-legend { margin-top: 14px; }
.status-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.status-foot .dot ~ .dot { margin-left: 6px; }
.d-status { display: flex; align-items: center; gap: 8px; }
.detail-ip { display: flex; align-items: center; gap: 12px; }
.detail-ip::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--st-unk); flex: none; }
.detail-ip.st-up::before { background: var(--st-up); box-shadow: 0 0 0 4px var(--st-up-soft); }
.detail-ip.st-down::before { background: var(--st-down); box-shadow: 0 0 0 4px var(--st-down-soft); }
.detail-ip.st-lost::before { background: var(--st-lost); box-shadow: 0 0 0 4px var(--st-lost-soft); }
.ping-stale { color: var(--st-down); font-weight: 500; }
.status-filter { width: auto; min-width: 170px; flex: none; }
.mon-state { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; }
.mon-state.on { border-color: var(--st-up); }
.mon-state.wait { border-color: var(--st-down); }
.mon-text { margin: 0; font-size: 13.5px; line-height: 1.55; }
.mon-steps { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.7; }
@media (max-width: 720px) { .status-filter { flex: 1; min-width: 0; } }
@media (prefers-reduced-motion: reduce) { .ip-chip.st-up::before { animation: none; } }
.legend i.dot { border-radius: 50%; }
