@font-face {
  font-family: "Chakra Petch";
  src: url("fonts/chakra-petch-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Chakra Petch";
  src: url("fonts/chakra-petch-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --abyss: #070b1f;
  --deep: #0b1130;
  --panel: #101842;
  --line: #24306a;
  --line-soft: #1a2352;
  --ice: #e2e9ff;
  --mist: #8e9bcb;
  --cyan: #3de1ff;
  --magenta: #ff4fb8;
  --amber: #ffc457;
  /* Estado del servicio en Conectados: rojo suspendido, verde activo (pedido del usuario). */
  --svc-off: #ff5c5c;
  --svc-on: #3ddc84;

  --display: "Chakra Petch", "Instrument Sans", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --rail: 208px;
  color-scheme: dark;
}

* { box-sizing: border-box; scrollbar-color: #33428c transparent; scrollbar-width: thin; }

html { background: var(--abyss); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 88% -12%, rgba(255, 79, 184, .13), transparent 62%),
    radial-gradient(900px 600px at 8% 0%, rgba(61, 225, 255, .10), transparent 60%),
    var(--abyss);
  background-attachment: fixed;
  color: var(--ice);
  font: 400 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.noscript { padding: 2rem; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--mist); }
.small { font-size: 12.500px; }

/* ---------- Ingreso ---------- */

.login {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  overflow: hidden;
}
.login canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.login-brand {
  position: relative;
  align-self: end;
  padding: clamp(24px, 6vw, 80px);
  pointer-events: none;
}
.login-brand h1 {
  font: 700 clamp(44px, 8vw, 112px)/.9 var(--display);
  letter-spacing: -.02em;
}
.login-brand h1 span { display: block; }
.login-brand p {
  margin-top: 20px;
  max-width: 34ch;
  color: var(--mist);
  font-size: 17px;
}
.login-form {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: clamp(24px, 4vw, 56px);
  background: rgba(11, 17, 48, .78);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.login-form h2 {
  font: 700 26px/1.1 var(--display);
  margin-bottom: 6px;
}
.field { display: grid; gap: 6px; }
.field span { color: var(--mist); font-size: 13px; }

.input, select.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: rgba(7, 11, 31, .7);
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #6673a6; }
.input:hover { border-color: #3a4a96; }
.input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(61, 225, 255, .18);
}
input[type="date"].input { min-width: 150px; }

.btn {
  height: 44px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-main {
  border: 0;
  background: linear-gradient(100deg, var(--cyan), #7aa7ff 55%, var(--magenta));
  color: #060a1c;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: .01em;
}
.btn-main:hover:not(:disabled) { color: #060a1c; filter: brightness(1.12); }

.form-error {
  min-height: 1.5em;
  color: var(--magenta);
  font-size: 14px;
}

/* ---------- Estructura ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  border-right: 1px solid var(--line-soft);
  background: rgba(7, 11, 31, .6);
  backdrop-filter: blur(10px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
  font: 700 19px/1 var(--display);
}
.brand img { width: 30px; height: 30px; }
.nav { display: grid; gap: 4px; }
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--mist);
  font-weight: 500;
  transition: color .15s, background .15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { color: var(--ice); background: rgba(36, 48, 106, .35); }
.nav a[aria-current="page"] {
  color: var(--ice);
  background: linear-gradient(90deg, rgba(61, 225, 255, .16), rgba(61, 225, 255, 0));
}
.nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0; top: 9px; bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}
.rail-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 0 8px;
  font-size: 13px;
}
.rail-foot .btn { height: 36px; padding: 0 12px; font-size: 13px; }

.main { min-width: 0; padding: 0 clamp(16px, 3vw, 40px) 56px; }

/* ---------- Franja de fibra (vista Conectados) ---------- */

.fiber {
  position: relative;
  height: 232px;
  margin: 0 calc(-1 * clamp(16px, 3vw, 40px));
  border-bottom: 1px solid var(--line-soft);
  overflow: hidden;
}
.fiber canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.fiber-info {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 clamp(16px, 3vw, 40px) 26px;
  background: linear-gradient(90deg, rgba(7, 11, 31, .82) 0, rgba(7, 11, 31, .25) 46%, rgba(7, 11, 31, 0) 70%);
}
.fiber-count {
  font: 700 clamp(72px, 11vw, 128px)/.8 var(--display);
  letter-spacing: -.03em;
  text-shadow: 0 0 44px rgba(61, 225, 255, .45);
}
.fiber-lead { display: flex; align-items: flex-end; gap: 18px; }
.fiber-lead p { padding-bottom: 6px; font: 500 20px/1.15 var(--display); }
.fiber-lead p small:empty { display: none; }
.fiber-lead p small.live { display: flex; }
.fiber-lead p small { display: block; margin-top: 4px; font: 400 13px/1.3 var(--body); color: var(--mist); }

.facts {
  display: flex;
  gap: 28px;
  margin: 0;
  padding-bottom: 6px;
  text-align: right;
}
.facts div { display: grid; }
.facts dt { order: 2; color: var(--mist); font-size: 13px; }
.facts dd { margin: 0; font: 700 22px/1.2 var(--display); }
.facts .bad dd { color: var(--magenta); }
.facts .svc-fact.on dd { color: var(--svc-on); }
.facts .svc-fact.off dd { color: var(--svc-off); }
.fact-link { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.fact-link:hover, .fact-link:focus-visible { text-decoration: underline; text-underline-offset: 4px; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.live::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 0 rgba(61, 225, 255, .6);
  animation: beat 2s infinite;
}
.live.stale::before { background: var(--amber); animation: none; }
@keyframes beat {
  70% { box-shadow: 0 0 0 9px rgba(61, 225, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 225, 255, 0); }
}

/* ---------- Encabezados y filtros ---------- */

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 34px 0 20px;
}
.head h1 { font: 700 34px/1.05 var(--display); letter-spacing: -.01em; overflow-wrap: anywhere; }
.head p { margin-top: 6px; color: var(--mist); }
.back { display: inline-block; margin-bottom: 10px; color: var(--mist); font-size: 14px; }
.back:hover { color: var(--cyan); }

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 18px 0 14px;
}
.bar .input { width: auto; flex: 1 1 220px; max-width: 380px; height: 40px; }
.bar select.input, .bar input[type="date"].input { flex: 0 1 auto; }
.bar .btn { height: 40px; }
.bar .count { margin-left: auto; color: var(--mist); font-size: 14px; }
.bar label { display: inline-flex; align-items: center; gap: 8px; color: var(--mist); font-size: 14px; }
.bar label[hidden] { display: none; }
.bar label.check { display: inline-flex; }

/* Registros de los Mikrotik en la ficha */
.log-note { margin: -6px 0 12px; color: var(--mist); font-size: 14px; }
.log-note[hidden] { display: none; }
.log-kind {
  display: inline-block; padding: 1px 9px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--mist); font-size: 13px; white-space: nowrap;
}
.log-kind.good { color: var(--cyan); border-color: rgba(61, 225, 255, .35); }
.log-kind.warn { color: var(--amber); border-color: rgba(255, 196, 87, .4); }
.log-kind.bad { color: var(--magenta); border-color: rgba(255, 79, 184, .45); background: rgba(255, 79, 184, .08); }
.log-repeat { color: var(--ice); font-size: 13px; font-weight: 600; }
#table td.clip { max-width: 560px; }
.log-table td.clip { max-width: 420px; }
.logs-bar .input[type="search"] { flex: 1 1 200px; max-width: 280px; }

/* Lista de Mikrotik: los botones van en dos filas para que la tabla entre a 1440 px */
.routers-table .row-actions { display: grid; grid-template-columns: repeat(2, 104px); gap: 6px; justify-content: end; margin-left: auto; }
.routers-table .row-actions .btn { width: 100%; margin: 0; justify-content: center; text-align: center; white-space: nowrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-top: 28px; }
.tabs button {
  padding: 10px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--mist);
  cursor: pointer;
  font-weight: 600;
}
.tabs button:hover { color: var(--ice); }
.tabs button[aria-selected="true"] { color: var(--ice); border-bottom-color: var(--cyan); }

/* ---------- Tablas ---------- */

.table-wrap {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(16, 24, 66, .45);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--mist);
  border-bottom: 1px solid var(--line);
}
td { padding: 11px 16px; border-bottom: 1px solid var(--line-soft); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(61, 225, 255, .055); }
th.r, td.r { text-align: right; }

/* Uso del plan: cuánto del límite contratado se está cursando ahora. El color va del cian (poco)
   al magenta (al límite) y siempre lo acompaña una barrita o un porcentaje. */
:root {
  --lv1: #3de1ff;
  --lv2: #ffc457;
  --lv3: #ff8a3d;
  --lv4: #ff4fb8;
}
.usage.lv0 { color: var(--mist); }
.usage.lv1 { color: var(--lv1); }
.usage.lv2 { color: var(--lv2); }
.usage.lv3 { color: var(--lv3); }
.usage.lv4 { color: var(--lv4); font-weight: 600; }
.tag.usage.lv1 { border-color: rgba(61, 225, 255, .45); }
.tag.usage.lv2 { border-color: rgba(255, 196, 87, .55); background: rgba(255, 196, 87, .08); }
.tag.usage.lv3 { border-color: rgba(255, 138, 61, .65); background: rgba(255, 138, 61, .12); }
.tag.usage.lv4 { border-color: var(--lv4); background: rgba(255, 79, 184, .16); }
td.usage { position: relative; }
.meter {
  position: absolute;
  left: 6px; right: 6px; bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: rgba(142, 155, 203, .16);
  overflow: hidden;
}
.meter i { display: block; height: 100%; width: 0; border-radius: 2px; background: currentColor; }
.lv0 .meter { background: none; }

.usage-legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-left: auto; color: var(--mist); font-size: 12.500px; }
.usage-legend span { display: inline-flex; align-items: center; gap: 6px; }
.usage-legend i { width: 14px; height: 4px; border-radius: 2px; }
.usage-legend .lv1 i { background: var(--lv1); }
.usage-legend .lv2 i { background: var(--lv2); }
.usage-legend .lv3 i { background: var(--lv3); }
.usage-legend .lv4 i { background: var(--lv4); }
.bar .count:empty { display: none; }
.bar .count + .usage-legend { margin-left: 0; }

/* Encabezados que ordenan la tabla */
.sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -6px -8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.sort:hover { color: var(--ice); background: rgba(61, 225, 255, .08); }
.sort .arrow {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0;
  transition: transform .15s;
}
.sort:hover .arrow { opacity: .35; }
th[aria-sort="ascending"] .sort, th[aria-sort="descending"] .sort { color: var(--cyan); }
th[aria-sort="ascending"] .arrow, th[aria-sort="descending"] .arrow { opacity: 1; }
th[aria-sort="ascending"] .arrow { transform: rotate(180deg); }
td.clip { max-width: 250px; overflow: hidden; text-overflow: ellipsis; }

/* Servicio del cliente en Conectados */
.svc { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.svc::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.svc.on { color: var(--svc-on); }
.svc.off { color: var(--svc-off); }
.svc-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: -4px 0 12px; font-size: 14px; }
td.wrap { white-space: normal; min-width: 180px; max-width: 320px; }
td a.user { font-weight: 600; }
td a.user:hover { color: var(--cyan); }
tr.fresh td { animation: arrive 2.4s ease-out; }
@keyframes arrive {
  from { background: rgba(61, 225, 255, .22); }
  to { background: transparent; }
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--mist);
}
.state { display: inline-flex; align-items: center; gap: 8px; }
.state::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #47528a;
}
.state.on { color: var(--cyan); }
.state.on::before { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.state.ok { color: var(--cyan); }
.state.ok::before { background: var(--cyan); }
.state.no { color: var(--magenta); }
.state.no::before { background: var(--magenta); }

.empty { padding: 44px 20px; text-align: center; color: var(--mist); white-space: normal; }
.empty strong { display: block; margin-bottom: 4px; color: var(--ice); font: 500 18px/1.3 var(--display); }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  color: var(--mist);
  font-size: 14px;
}
.pager .btn { height: 36px; padding: 0 14px; }

/* ---------- Ficha de usuario ---------- */

.sheet {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(16, 24, 66, .45);
  overflow: hidden;
}
.sheet section { padding: 20px 22px; border-right: 1px solid var(--line-soft); }
.sheet section:last-child { border-right: 0; }
.sheet h2 { font: 500 14px/1.2 var(--body); color: var(--mist); margin-bottom: 12px; }
.sheet .big { font: 700 26px/1.15 var(--display); }
.sheet .big.on { color: var(--cyan); text-shadow: 0 0 24px rgba(61, 225, 255, .4); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 12px 0 0; font-size: 14px; }
.kv dt { color: var(--mist); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

.notice {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 196, 87, .4);
  border-radius: 8px;
  background: rgba(255, 196, 87, .08);
  color: var(--amber);
}
.notice.ok { border-color: rgba(61, 225, 255, .45); background: rgba(61, 225, 255, .07); color: var(--ice); }
.notice.ok strong { color: var(--cyan); }
.notice .kv { margin-top: 8px; }
.notice pre.raw { margin: 10px 0 0; padding: 10px 12px; border-radius: 6px; background: rgba(7, 11, 31, .6); color: var(--mist); font: 12.500px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.notice .kv dd { text-align: left; }
.form .notice { margin-bottom: 0; }
.pair { display: grid; grid-template-columns: 1fr 150px; gap: 14px; }
.notice a { text-decoration: underline; }
.notice + .notice { margin-top: -6px; }
.notice.error { border-color: rgba(255, 79, 184, .45); background: rgba(255, 79, 184, .08); color: var(--magenta); }

/* ---------- Panel y gráficos ---------- */

:root {
  /* Colores de serie validados sobre el fondo oscuro (luminosidad, contraste y daltonismo). */
  --s1: #14a0c6;
  --s2: #7a5cf0;
  /* Tercera serie (Mikrotik), validada junto con s1 y s2 comparando todos los pares. sx: "otros", neutro. */
  --s3: #c97b22;
  --sx: #6f7aa8;
}

.segmented { display: inline-flex; }
.segmented .btn { height: 38px; border-radius: 0; margin-left: -1px; color: var(--mist); }
.segmented .btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.segmented .btn:last-child { border-radius: 0 6px 6px 0; }
.segmented .btn[aria-pressed="true"] { position: relative; border-color: var(--cyan); color: var(--ice); background: rgba(61, 225, 255, .12); }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.chart-card {
  min-width: 0;
  padding: 20px 22px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(16, 24, 66, .45);
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-card > header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 12px; }
.chart-card h2 { font: 700 18px/1.2 var(--display); }
.chart-card > p { margin-top: 8px; font-size: 13px; max-width: 78ch; }
.chart-card details { margin-top: 10px; font-size: 14px; }
.chart-card summary { width: fit-content; color: var(--mist); cursor: pointer; }
.chart-card summary:hover { color: var(--ice); }
.chart-card details .table-wrap { margin-top: 10px; max-height: 260px; overflow-y: auto; }

.legend { display: flex; gap: 16px; color: var(--mist); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.key.s1, .rank-bar .s1 { background: var(--s1); }
.key.s2, .rank-bar .s2 { background: var(--s2); }

.chart { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-svg .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart-svg .axis { stroke: var(--line); stroke-width: 1; }
.chart-svg .tick { fill: var(--mist); font: 11px var(--body); font-variant-numeric: tabular-nums; }
.chart-svg .cross { stroke: var(--mist); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .bar.s1, .chart-svg .dot.s1 { fill: var(--s1); }
.chart-svg .bar.s2 { fill: var(--s2); }
.chart-svg .bar.est { opacity: .4; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .line.s1 { stroke: var(--s1); }
.chart-svg .line.s2 { stroke: var(--s2); }
.chart-svg .dot.s2 { fill: var(--s2); }
.chart-svg .lost { fill: var(--magenta); }
.key.lost { background: var(--magenta); width: 4px; }
.legend b { color: var(--ice); font-weight: 600; }
.chart-card > .legend { margin-bottom: 10px; }
.chart-card[hidden] { display: none; }
#user-charts { margin-top: 16px; }
.chart-svg .area.s1 { fill: var(--s1); opacity: .16; }
.chart-svg .dot { stroke: var(--deep); stroke-width: 2; }

.tip {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 4px;
  min-width: 170px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--deep);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  font-size: 13px;
  pointer-events: none;
}
.tip[hidden] { display: none; }
.tip span { display: flex; align-items: center; gap: 8px; color: var(--mist); }
.tip b { margin-left: auto; padding-left: 12px; color: var(--ice); font-weight: 600; }

.rank { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.rank-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 14px; }
.rank-head a { font-weight: 600; overflow-wrap: anywhere; }
.rank-head span { color: var(--mist); }
.rank-bar { display: flex; gap: 2px; height: 8px; margin-top: 5px; }
.rank-bar i { min-width: 2px; border-radius: 0; }
.rank-bar i:last-child { border-radius: 0 4px 4px 0; }
.rank .empty { padding: 24px 0; }

/* ---------- Gráficos: acabado ---------- */

:root {
  /* Tonos más luminosos de cada serie, para el borde superior de las barras, la cabeza de las líneas y el brillo. */
  --s1-hi: #58d6f7;
  --s2-hi: #a892ff;
  --s3-hi: #f0a54a;
  --sx-hi: #9aa4cc;
}

.chart-card > header { align-items: flex-start; }
.chart-card > header > div > p { margin-top: 4px; max-width: 76ch; font-size: 13px; }
.chart-card.feature {
  border-color: rgba(61, 225, 255, .3);
  background: linear-gradient(180deg, rgba(20, 160, 198, .13), rgba(16, 24, 66, .45) 46%);
  box-shadow: 0 30px 70px -40px rgba(20, 160, 198, .65);
}
.legend .live { color: var(--ice); font-weight: 600; }

/* Relleno bajo las líneas y cuerpo de las barras */
.area-from.s1 { stop-color: var(--s1); stop-opacity: .5; }
.area-to.s1 { stop-color: var(--s1); stop-opacity: 0; }
.area-from.s2 { stop-color: var(--s2); stop-opacity: .42; }
.area-to.s2 { stop-color: var(--s2); stop-opacity: 0; }
.bar-from.s1 { stop-color: var(--s1-hi); }
.bar-to.s1 { stop-color: var(--s1); stop-opacity: .62; }
.bar-from.s2 { stop-color: var(--s2-hi); }
.bar-to.s2 { stop-color: var(--s2); stop-opacity: .7; }

.chart-svg .grid { stroke: rgba(36, 48, 106, .55); stroke-dasharray: 2 4; }
.chart-svg .line { stroke-width: 2; }
.chart-svg .line.s1 { stroke: var(--s1-hi); filter: drop-shadow(0 0 6px rgba(20, 160, 198, .8)); }
.chart-svg .line.s2 { stroke: var(--s2-hi); filter: drop-shadow(0 0 6px rgba(122, 92, 240, .8)); }
.chart-svg .dot.s1, .chart-svg .head.s1, .chart-svg .dot-lone.s1 { fill: var(--s1-hi); }
.chart-svg .dot.s2, .chart-svg .head.s2, .chart-svg .dot-lone.s2 { fill: var(--s2-hi); }
.chart-svg .head { stroke: var(--deep); stroke-width: 1.500; }
.chart-svg .head-ring { fill: none; stroke-width: 1.500; opacity: 0; animation: head-pulse 1s ease-out; }
.chart-svg .head-ring.s1 { stroke: var(--s1-hi); }
.chart-svg .head-ring.s2 { stroke: var(--s2-hi); }
@keyframes head-pulse {
  from { r: 4px; opacity: .8; }
  to { r: 14px; opacity: 0; }
}
.chart-svg .band { fill: rgba(142, 155, 203, .09); }
.chart-svg .cross { stroke: var(--ice); opacity: .45; }
.chart-svg .lost { fill: rgba(255, 79, 184, .24); }
.chart-svg .ref { stroke: var(--ice); stroke-width: 1; stroke-dasharray: 6 5; opacity: .6; }
.chart-svg .ref-label { fill: var(--ice); font: 600 11px var(--body); opacity: .85; paint-order: stroke; stroke: var(--deep); stroke-width: 3px; }
.chart-svg .peak { fill: var(--ice); font: 600 11px var(--body); font-variant-numeric: tabular-nums; }
.key.ref { width: 16px; height: 0; border-top: 2px dashed var(--ice); border-radius: 0; background: none; opacity: .7; }
.key.lost { width: 8px; background: rgba(255, 79, 184, .5); }

.tip { min-width: 190px; padding: 12px 14px; border-color: #33428c; background: rgba(9, 14, 42, .96); backdrop-filter: blur(6px); }
.tip strong { margin-bottom: 2px; font: 600 13px var(--display); letter-spacing: .01em; }
.tip .more { margin-top: 2px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.tip .more + .more { margin-top: 0; padding-top: 0; border-top: 0; }

/* Fila de indicadores sobre un gráfico */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  margin: 2px 0 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--line-soft);
  overflow: hidden;
}
.stats:empty { display: none; }
.stat { display: grid; align-content: start; gap: 2px; min-width: 0; padding: 12px 16px 11px; background: #0b1236; }
.stat-label { color: var(--mist); font-size: 12.500px; }
.stat b { font: 700 25px/1.15 var(--display); color: var(--ice); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.usage { font-weight: 400; }
.stat.usage:not(.lv0) b { color: inherit; }
.stat.usage.lv4 b { text-shadow: 0 0 22px rgba(255, 79, 184, .55); }
.stat-detail { min-height: 1.300em; color: var(--mist); font-size: 12px; font-weight: 400; }
.gauge { display: block; height: 4px; margin: 5px 0 3px; border-radius: 2px; background: rgba(142, 155, 203, .16); overflow: hidden; }
.gauge i { display: block; width: 0; height: 100%; border-radius: 2px; background: currentColor; }
.stat.lv0 .gauge i { background: none; }

/* Tercera serie y "otros" */
.key.s3, .rank-bar .s3 { background: var(--s3); }
.key.sx, .rank-bar .sx { background: var(--sx); }
.area-from.s3 { stop-color: var(--s3); stop-opacity: .42; }
.area-to.s3 { stop-color: var(--s3); stop-opacity: 0; }
.bar-from.s3 { stop-color: var(--s3-hi); }
.bar-to.s3 { stop-color: var(--s3); stop-opacity: .7; }
.chart-svg .line.s3 { stroke: var(--s3-hi); filter: drop-shadow(0 0 6px rgba(201, 123, 34, .8)); }
.chart-svg .line.sx { stroke: var(--sx-hi); }
.chart-svg .dot.s3, .chart-svg .dot-lone.s3 { fill: var(--s3-hi); }
.chart-svg .dot.sx, .chart-svg .dot-lone.sx { fill: var(--sx-hi); }

/* Áreas apiladas: relleno plano y semitransparente; el borde superior de cada capa va con su línea. */
.chart-svg .stack-area { stroke: none; opacity: .34; }
.chart-svg .stack-area.s1 { fill: var(--s1); }
.chart-svg .stack-area.s2 { fill: var(--s2); }
.chart-svg .stack-area.s3 { fill: var(--s3); }
.chart-svg .stack-area.sx { fill: var(--sx); }

/* Leyendas que prenden y apagan series */
.legend.toggles { flex-wrap: wrap; gap: 6px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border: 1px solid var(--line-soft); border-radius: 999px;
  color: var(--ice); background: rgba(16, 24, 66, .6); font: 500 13px var(--body); cursor: pointer;
}
.legend-item:hover { border-color: var(--line); background: rgba(61, 225, 255, .07); }
.legend-item[aria-pressed="false"] { color: var(--mist); text-decoration: line-through; opacity: .6; }
.legend-item[aria-pressed="false"] .key { background: transparent; box-shadow: inset 0 0 0 1.500px var(--mist); }

/* Indicadores del Panel */
.kpis {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px;
  border: 1px solid var(--line-soft); border-radius: 10px; background: var(--line-soft); overflow: hidden;
}
.kpi { position: relative; display: grid; align-content: start; gap: 3px; min-width: 0; padding: 18px 20px 14px; background: #0b1236; }
.kpi-label { color: var(--mist); font-size: 13.500px; }
.kpi b, .kpi > a.num { font: 700 28px/1.15 var(--display); color: var(--ice); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.off > a.num { color: var(--svc-off); }
.kpi > a.num:hover, .kpi > a.num:focus-visible { text-decoration: underline; text-underline-offset: 4px; }
.spark-line.off { stroke: var(--svc-off); }
.kpi-detail { overflow-wrap: normal; word-break: normal; min-height: 2.600em; color: var(--mist); font-size: 12.500px; line-height: 1.300; }
.spark { display: block; width: 100%; height: 32px; margin-top: 6px; overflow: visible; }
.spark-line { fill: none; stroke-width: 1.750; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-line.s1 { stroke: var(--s1-hi); }
.spark-line.s2 { stroke: var(--s2-hi); }
.spark-line.s3 { stroke: var(--s3-hi); }
.spark-line.sx { stroke: var(--sx-hi); }

/* Tarjetas de los Mikrotik bajo el gráfico de conectados */
.router-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin-top: 16px; }
.router-card {
  display: grid; gap: 8px; min-width: 0; padding: 14px 16px 12px;
  border: 1px solid var(--line-soft); border-radius: 10px; background: rgba(11, 18, 54, .75);
  color: var(--ice); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, opacity .15s;
}
.router-card:hover { border-color: var(--line); }
.router-card.off { opacity: .45; }
.router-name { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.router-state { margin-left: auto; padding: 1px 8px; border-radius: 999px; font-size: 11.500px; font-weight: 500; white-space: nowrap; }
.router-state.ok { color: var(--cyan); background: rgba(61, 225, 255, .1); }
.router-state.err { color: var(--magenta); background: rgba(255, 79, 184, .12); }
.router-state.err::before { content: "⚠ "; }
.router-now { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.router-now b { font: 700 30px/1 var(--display); }
.router-now span { color: var(--mist); font-size: 13px; }
.router-card .gauge { margin: 0; }
.router-card .gauge.s1 i { background: var(--s1-hi); }
.router-card .gauge.s2 i { background: var(--s2-hi); }
.router-card .gauge.s3 i { background: var(--s3-hi); }
.router-card .gauge.sx i { background: var(--sx-hi); }
.router-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; color: var(--mist); font-size: 12px; }
.router-facts > span { display: grid; gap: 1px; min-width: 0; }
.router-facts b { color: var(--ice); font: 600 15px/1.2 var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.router-facts small { font-size: 11.500px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.router-card .spark { margin-top: 0; }
.router-since { color: var(--amber); font-size: 12px; }

.rank-head { align-items: baseline; }
.rank-pos { min-width: 1.600em; color: var(--mist); font: 600 13px var(--display); }
.rank-head a { margin-right: auto; }

/* Seis indicadores: 6, 3 o 2 por fila, siempre filas completas. */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi b, .kpi > a.num { font-size: 22px; }
}

/* ---------- Reparto PCQ ---------- */

.pcq-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 2px 0 14px; }
.pcq-controls .segmented .btn { height: 36px; }
.pcq-sim { display: inline-flex; align-items: center; gap: 10px; margin-left: auto; color: var(--mist); font-size: 14px; }
.pcq-sim input { width: 170px; accent-color: var(--cyan); }
.pcq-sim b { min-width: 4.500em; color: var(--ice); }
.pcq-stage { position: relative; overflow-x: auto; }
.pcq-svg { display: block; max-width: none; }
.pcq-empty { position: absolute; inset: 44px 0 auto 0; text-align: center; padding-top: 50px; }
.pcq-empty[hidden] { display: none; }
.pcq-about { margin-top: 12px; max-width: 110ch; font-size: 13px; }

.pcq-svg .p-head { fill: var(--mist); font: 12.500px var(--body); }
.pcq-svg .p-name { fill: var(--ice); font: 600 13px var(--body); font-variant-numeric: tabular-nums; }
.pcq-svg .p-sub { fill: var(--mist); font: 11.500px var(--body); font-variant-numeric: tabular-nums; }
.pcq-svg .p-value { fill: var(--ice); font: 600 12.500px var(--body); font-variant-numeric: tabular-nums; white-space: pre; paint-order: stroke; stroke: rgba(11, 18, 54, .85); stroke-width: 3px; }
.pcq-svg .p-total { fill: var(--ice); font: 700 21px var(--display); }
.pcq-svg .p-hit { fill: transparent; }
.pcq-svg .p-track { fill: rgba(142, 155, 203, .11); }
.pcq-svg .p-fill { fill: var(--s1-hi); filter: drop-shadow(0 0 5px rgba(20, 160, 198, .7)); }
.pcq-svg .p-ghost { fill: rgba(255, 79, 184, .13); stroke: rgba(255, 79, 184, .6); stroke-width: 1; stroke-dasharray: 3 3; }
.pcq-svg .p-ribbon { fill: var(--s1); stroke: none; opacity: .36; }
.pcq-svg .p-dots { fill: none; stroke: var(--s1-hi); stroke-width: 2.600; stroke-linecap: round; stroke-dasharray: .100 13.900; }
.pcq-svg .up .p-fill, .pcq-svg .up.p-fill { fill: var(--s2-hi); filter: drop-shadow(0 0 5px rgba(122, 92, 240, .7)); }
.pcq-svg .up.p-ribbon { fill: var(--s2); }
.pcq-svg .up.p-dots, .pcq-svg .up .p-dots { stroke: var(--s2-hi); }
.pcq-svg .capped .p-fill { fill: var(--magenta); filter: drop-shadow(0 0 5px rgba(255, 79, 184, .7)); }
.pcq-svg .capped.p-ribbon { fill: var(--magenta); }
.pcq-svg .capped.p-dots, .pcq-svg .capped .p-dots { stroke: var(--magenta); }
.pcq-svg .rest .p-name { fill: var(--mist); font-weight: 500; }
.pcq-svg .lane { cursor: pointer; outline: none; animation: lane-in .6s ease-out; }
.pcq-svg .p-ribbon, .pcq-svg [data-layer="ribbons"] .p-dots { animation: lane-in .6s ease-out; }
@keyframes lane-in { from { opacity: 0; } }
.pcq-svg .lane:focus-visible .p-track { stroke: var(--cyan); stroke-width: 2; }
.pcq-svg.focus .lane:not(.hot), .pcq-svg.focus .p-ribbon:not(.hot), .pcq-svg.focus .p-dots:not(.hot) { opacity: .22; }
.pcq-svg.focus .lane.hot .p-dots { opacity: 1; }
.pcq-svg .p-ribbon.hot { opacity: .7; }
.pcq-svg .lane.hot .p-track { fill: rgba(142, 155, 203, .2); }
.pcq-svg .lane.pinned .p-name { fill: var(--cyan); }
.pcq-svg .trunk { fill: rgba(142, 155, 203, .1); stroke: var(--line); }
.pcq-svg .trunk-fill { fill: currentColor; filter: drop-shadow(0 0 8px currentColor); }
.pcq-svg .p-fair { stroke: var(--ice); stroke-width: 1; stroke-dasharray: 5 4; opacity: .6; }
.pcq-svg .p-fair-label { fill: var(--ice); font: 600 11px var(--body); opacity: .9; }

.pcq-inspect { min-height: 96px; margin-top: 12px; padding: 14px 18px; border: 1px solid var(--line-soft); border-radius: 8px; background: #0b1236; }
.pcq-inspect h3 { margin: 0 0 10px; font: 700 16px var(--display); }
.pcq-inspect h3 .tag { margin-left: 8px; vertical-align: 2px; border-color: rgba(61, 225, 255, .5); color: var(--cyan); font-family: var(--body); font-weight: 400; }
.pcq-inspect dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 22px; margin: 0; }
.pcq-inspect dt { color: var(--mist); font-size: 12.500px; }
.pcq-inspect dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Alta, edición y baja ---------- */

/* Los lugares reservados para mensajes no ocupan espacio mientras están vacíos. */
.form .form-error:empty, .dialog .form-error:empty, .form #result:empty { display: none; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.actions[hidden] { display: none; }
a.btn { display: inline-flex; align-items: center; }
.btn-danger { border-color: rgba(255, 79, 184, .5); color: var(--magenta); }
.btn-danger:hover:not(:disabled) { border-color: var(--magenta); background: var(--magenta); color: #060a1c; }
.btn[hidden] { display: none; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; padding: 0 !important; }
.btn-icon svg { width: 14px; height: 14px; pointer-events: none; }
.btn-icon:hover:not(:disabled) { border-color: var(--magenta); color: var(--magenta); }
.btn-small { height: 32px; padding: 0 12px; font-size: 13px; color: var(--mist); }
.tag.full { border-color: rgba(61, 225, 255, .5); color: var(--cyan); }
.who .tag { margin-top: 4px; border-color: rgba(255, 196, 87, .5); color: var(--amber); }
.tag.block { margin-left: 8px; border-color: rgba(255, 196, 87, .5); color: var(--amber); }

.form {
  display: grid;
  gap: 20px;
  max-width: 560px;
  padding: 26px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(16, 24, 66, .45);
}
.form small { color: var(--mist); font-size: 13px; }
.form .input[readonly] { color: var(--mist); border-style: dashed; }
.with-button { display: flex; gap: 8px; }
.with-button .input { flex: 1; min-width: 0; }
.check { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--cyan); }
.check small { grid-column: 2; }

.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--deep);
  color: var(--ice);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.dialog::backdrop { background: rgba(4, 6, 18, .72); backdrop-filter: blur(4px); }
.dialog form { display: grid; gap: 16px; }
.dialog small { color: var(--mist); font-size: 13px; }
td .btn-small + .btn-small { margin-left: 6px; }
.dialog h2 { font: 700 22px/1.2 var(--display); margin-bottom: 10px; overflow-wrap: anywhere; }
.dialog p { color: var(--mist); }
.dialog .actions { justify-content: flex-end; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 20;
  transform: translateX(-50%);
  padding: 12px 20px;
  border: 1px solid var(--cyan);
  border-radius: 8px;
  background: var(--deep);
  box-shadow: 0 0 30px rgba(61, 225, 255, .25);
  font-weight: 600;
  animation: toast-in .25s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Pantallas chicas ---------- */

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .login-form { border-left: 0; border-top: 1px solid var(--line); }

  .shell { grid-template-columns: 1fr; padding-bottom: 64px; }
  .rail {
    position: fixed;
    top: auto; bottom: 0; left: 0; right: 0;
    z-index: 10;
    height: 64px;
    flex-direction: row;
    align-items: center;
    padding: 0 8px;
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgba(7, 11, 31, .94);
  }
  .brand, .rail-foot .who { display: none; }
  .nav { display: flex; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .pair { grid-template-columns: 1fr 110px; }
  .nav a { flex: 1 0 68px; flex-direction: column; justify-content: center; gap: 3px; height: 52px; padding: 0; font-size: 11px; }
  .nav a[aria-current="page"]::before { left: 30%; right: 30%; top: 0; bottom: auto; width: auto; height: 3px; }
  .rail-foot { margin: 0; padding: 0 4px; display: flex; gap: 6px; }
  .rail-foot .own-pass.full { display: none; }

  /* En pantallas chicas el alto lo define el contenido, para que los textos largos no se encimen. */
  .fiber { height: auto; }
  .fiber canvas { opacity: .5; }
  .fiber-info { position: relative; min-height: 230px; padding-top: 28px; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 14px; }
  .fiber-lead { flex-wrap: wrap; gap: 6px 18px; }
  .fiber-lead p small { line-height: 1.35; }
  .facts { text-align: left; gap: 22px; padding-bottom: 0; }
  .facts dd { font-size: 18px; }
  .sheet section { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .sheet section:last-child { border-bottom: 0; }
  .bar .count { margin-left: 0; width: 100%; }
  .toast { bottom: 80px; }
  .charts { grid-template-columns: 1fr; }
  .chart-card { padding: 16px; }
  .nav a { overflow: hidden; }
  .with-button { flex-wrap: wrap; }
  .with-button .input { flex-basis: 100%; }
}

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

/* ---------- Pantallas grandes: menú que se pliega y lista de conectados a pantalla completa ---------- */

@media (min-width: 861px) {
  :root { --rail-closed: 64px; }

  /* El menú queda plegado mostrando solo los íconos. Al pasarle el mouse o recorrerlo con el teclado
     se despliega y la columna del contenido se achica para dejarle lugar, sin taparlo. */
  .shell {
    grid-template-columns: var(--rail-closed) minmax(0, 1fr);
    transition: grid-template-columns .18s ease;
  }
  .shell:has(.rail:hover), .shell:has(.rail :focus-visible) {
    grid-template-columns: var(--rail) minmax(0, 1fr);
    transition-delay: .08s;
  }
  .rail {
    position: sticky;
    top: 0;
    z-index: 30;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    background: #080c22;
    backdrop-filter: none;
  }
  .rail .label { opacity: 0; transition: opacity .12s ease; }
  .rail:hover .label, .rail:has(:focus-visible) .label { opacity: 1; transition-delay: .1s; }
  .main { grid-column: 2; }
  .brand { padding-left: 3px; }
  .brand img { flex: none; }
  .nav a { padding: 0 9px; }
  .rail-foot {
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease, visibility .15s;
  }
  .rail:hover .rail-foot, .rail:has(:focus-visible) .rail-foot { opacity: 1; visibility: visible; transition-delay: .1s; }
  .rail-foot .who { white-space: normal; }
}

/* Los cinco indicadores del Panel van siempre en una sola fila cuando hay ancho. */
@media (min-width: 1100px) {
  #tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (min-width: 861px) and (min-height: 400px) {
  /* Conectados: la tabla ocupa todo el ancho y todo el alto que queda, con su propio desplazamiento
     y el encabezado siempre a la vista. */
  .main.fill {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    overflow: hidden;
  }
  .main.fill > * { flex: none; }
  .main.fill .fiber { height: 124px; margin: 0; }
  .main.fill .fiber-info { padding: 0 20px 16px; }
  .main.fill .fiber-count { font-size: clamp(52px, 6vw, 76px); }
  .main.fill .fiber-lead p { padding-bottom: 2px; font-size: 17px; }
  .main.fill .facts { padding-bottom: 2px; }
  .main.fill .bar { padding: 12px 20px; }
  .main.fill #alert { padding: 0 20px; }
  .main.fill #alert:empty { display: none; }
  .main.fill .table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    border-width: 1px 0;
    border-radius: 0;
  }
  /* Con bordes colapsados el borde no acompaña al encabezado fijo; se dibuja como sombra. */
  .main.fill th { z-index: 1; background: var(--deep); border-bottom: 0; box-shadow: inset 0 -1px 0 var(--line); }
  .main.fill th:first-child, .main.fill td:first-child { padding-left: 16px; }
  .main.fill th:last-child, .main.fill td:last-child { padding-right: 12px; }
  /* Filas de un renglón y celdas angostas, para que entren más conectados y más columnas. */
  .main.fill table { font-size: 13.500px; }
  .main.fill td { padding: 7px 4px; }
  .main.fill th { padding: 10px 4px; }
  /* El comentario se recorta a un ancho fijo y el espacio que sobra se reparte entre todas las columnas
     (antes tomaba todo lo sobrante; el usuario pidió repartirlo mejor, 2026-10-14). */
  .main.fill td.clip { max-width: 85px; }
  .main.fill td.mac, .main.fill td.sig { font-size: 12.500px; }
  /* Un usuario muy largo se recorta en vez de empujar la tabla fuera de la pantalla. */
  .main.fill td:first-child { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
  .main.fill .tag { padding: 1px 8px; font-size: 12px; }
  .main.fill .btn-small { height: 26px; padding: 0 10px; font-size: 12.500px; }
  .main.fill .notice { margin-bottom: 10px; padding: 8px 14px; font-size: 14px; }
  .main.fill .pager { padding: 10px 20px; }
  .main.fill #pager:empty { display: none; }
}

/* ---------- Syslog y Radius log ---------- */

/* Pestañas que son enlaces (Syslog: Registros / Equipos), con el mismo aspecto que las de la ficha. */
.tabs a { padding: 10px 16px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--mist); font-weight: 600; }
.tabs a:hover { color: var(--ice); }
.tabs a[aria-selected="true"] { color: var(--ice); border-bottom-color: var(--cyan); }
.page-tabs { margin: 4px 0 18px; }

.syslog-block { margin-top: 28px; }
.block-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 10px; }
.block-head h2 { font: 700 20px/1.2 var(--display); }
.block-head p { flex: 1 1 360px; max-width: 90ch; font-size: 13.500px; }
.block-head .btn { margin-left: auto; }
.dev-table td { vertical-align: top; }
.dev-table .row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.dev-table td.clip { max-width: 520px; }
.mono { font: 12.500px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--mist); }
.warn-text { color: var(--amber); font-size: 12.500px; }
.state.warn { color: var(--amber); }
.state.warn::before { background: var(--amber); }

.syslog-store { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.syslog-store > p { flex-basis: 100%; margin: 0; }
.store-facts { display: flex; flex-wrap: wrap; gap: 10px 32px; color: var(--mist); font-size: 13.500px; }
.store-facts span { display: grid; }
.store-facts b { color: var(--ice); font: 700 22px/1.2 var(--display); }

/* Radius log */
.kpis.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.kpi.bad b { color: var(--magenta); }
.kpi.warn b { color: var(--amber); }
.spark-line.bad { stroke: var(--magenta); }
.radius-top { margin-bottom: 18px; }
.radius-top .rank { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px 28px; }
.radius-top .rank-head { flex-wrap: nowrap; min-width: 0; }
.radius-top .rank-head a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.radius-top .rank-head span { flex: none; }
.top-why { margin-top: 2px; padding-left: 2.100em; font-size: 12.500px; }
@media (max-width: 1180px) {
  .kpis.kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Bloqueo de MAC */
.macblock-grid { display: grid; grid-template-columns: minmax(0, 1.200fr) minmax(0, 1fr); gap: 18px; }
.macblock-grid .chart-card { margin: 0; }
.macblock-form { display: grid; gap: 14px; }
.macblock-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.macblock-fields small { color: var(--mist); font-size: 12px; }
.macblock-fields .field { align-content: start; }
.macblock-form textarea.input { height: auto; min-height: 60px; padding-top: 8px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
.macblock-form .actions { justify-content: flex-end; }
.macblock-kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.macblock-kv dt { color: var(--mist); }
.macblock-kv dd { margin: 0; }
#watch-card .rank { gap: 10px; }
#watch-card .meter { position: relative; left: auto; right: auto; bottom: auto; display: block; width: 100%; height: 4px; margin-top: 5px; color: var(--amber); background: rgba(255, 196, 87, .15); }
.macblock-cov { max-width: none; }
.chip { display: inline-block; margin: 1px 0; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; white-space: nowrap; }
.chip.ok { color: var(--cyan); border-color: rgba(61, 225, 255, .35); }
.chip.no { color: var(--magenta); border-color: rgba(255, 79, 184, .45); }
.chip.warn { color: var(--amber); border-color: rgba(255, 196, 87, .4); }
.chip.dim { color: var(--mist); }
.ok-text { color: var(--cyan); font-size: 12.500px; }
.block-head .segmented { margin-left: auto; }
.block-head .input[type="search"] { width: 220px; }
@media (max-width: 1100px) {
  .macblock-grid { grid-template-columns: 1fr; }
  .macblock-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tabla del Radius log: anchos fijos para que las columnas queden parejas y el detalle use el resto. */
.radius-table { table-layout: fixed; width: 100%; }
.radius-table .c-date { width: 13%; }
.radius-table .c-kind { width: 11%; }
.radius-table .c-nas { width: 10%; }
.radius-table .c-user { width: 22%; }
.radius-table .c-mac { width: 15%; }
/* Las columnas cortas van centradas: así el espacio queda repartido a cualquier ancho de pantalla. */
.radius-table th:nth-child(2), .radius-table td:nth-child(2),
.radius-table th:nth-child(3), .radius-table td:nth-child(3),
.radius-table th:nth-child(5), .radius-table td:nth-child(5) { text-align: center; }
.radius-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.radius-table td.clip { max-width: none; }
.radius-table td:nth-child(5) { font-variant-numeric: tabular-nums; letter-spacing: .01em; color: var(--mist); }
.radius-bar .input[type="search"] { flex: 0 1 210px; min-width: 0; }
.radius-bar select.input { width: 170px; }
.radius-bar label .input[type="date"] { width: 140px; }
@media (max-width: 860px) {
  .radius-table { table-layout: auto; min-width: 860px; }
}
.radius-bar .date-range { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Switch: puertos */
.ports-table tr.port-down td { opacity: .55; }
.ports-table td { vertical-align: top; }
.sfp { font-variant-numeric: tabular-nums; font-weight: 600; }
.sfp.good { color: var(--cyan); }
.sfp.warn { color: var(--amber); }
.sfp.bad { color: var(--magenta); }
.ports-note { margin-top: 10px; font-size: 13px; max-width: 100ch; }
.routers-table td.wrap { min-width: 130px; max-width: 230px; }

/* ---------- Topología ---------- */
.topo-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-bottom: 12px; color: var(--mist); font-size: 12.500px; }
.topo-legend span { display: inline-flex; align-items: center; gap: 7px; }
.topo-key { display: inline-block; width: 26px; height: 0; border-top: 3px solid var(--lv1); }
.topo-key.solid { border-top-color: var(--ice); }
.topo-key.dashed { border-top: 2px dashed var(--ice); }
.topo-key.lv2 { border-top-color: var(--lv2); }
.topo-key.lv3 { border-top-color: var(--lv3); }
.topo-key.lv4 { border-top-color: var(--lv4); }
.topo-wrap { position: relative; overflow: auto; border: 1px solid var(--line-soft); border-radius: 12px;
  background: radial-gradient(ellipse at 50% 0%, rgba(61, 225, 255, .06), transparent 60%), #080d27; }
.topo { display: block; min-width: 100%; touch-action: pan-x pan-y; user-select: none; }
.topo-link .line { fill: none; stroke: var(--lv1); stroke-opacity: .55; stroke-linecap: round; transition: stroke-opacity .15s; }
.topo-link.lv2 .line { stroke: var(--lv2); }
.topo-link.lv3 .line { stroke: var(--lv3); }
.topo-link.lv4 .line { stroke: var(--lv4); stroke-opacity: .8; }
.topo-link.dashed .line { stroke-dasharray: 6 6; stroke-opacity: .4; }
.topo-link .hit { fill: none; stroke: transparent; stroke-width: 14; cursor: help; }
.topo-link:hover .line { stroke-opacity: 1; }
.topo-dot { fill: var(--lv1); filter: drop-shadow(0 0 3px rgba(61, 225, 255, .9)); pointer-events: none; }
.topo-dot.lv2 { fill: var(--lv2); }
.topo-dot.lv3 { fill: var(--lv3); }
.topo-dot.lv4 { fill: var(--lv4); }
.topo-node { cursor: grab; outline: none; }
.topo-node:active { cursor: grabbing; }
.topo-node .card { fill: #111a48; stroke: var(--line); stroke-width: 1.200; }
.topo-node.loaded .card { fill: #142057; stroke: rgba(61, 225, 255, .45); }
.topo-node.deduced .card { stroke-dasharray: 5 4; fill: #0d1438; }
.topo-node.t-group .card { fill: #0c1235; stroke-dasharray: 2 4; }
.topo-node:hover .card, .topo-node:focus-visible .card, .topo-node.selected .card { stroke: var(--cyan); stroke-width: 2; }
.topo-node .badge { fill: rgba(61, 225, 255, .1); }
.topo-node .glyph { color: var(--cyan); }
.topo-node.t-olt .badge { fill: rgba(255, 196, 87, .12); }
.topo-node.t-olt .glyph { color: var(--amber); }
.topo-node.t-upstream .badge { fill: rgba(122, 92, 240, .18); }
.topo-node.t-upstream .glyph { color: #a996ff; }
.topo-node.t-server .glyph, .topo-node.t-group .glyph, .topo-node.t-other .glyph { color: var(--mist); }
.topo-node .name { fill: var(--ice); font: 600 13.500px var(--body); }
.topo-node .sub { fill: var(--mist); font: 11.500px var(--body); }
.topo-node .state { fill: var(--cyan); }
.topo-node.error .state { fill: var(--magenta); }
.topo-node.error .card { stroke: var(--magenta); }
.topo-tip { position: absolute; z-index: 5; max-width: 320px; pointer-events: none; display: grid; gap: 4px; font-size: 12.500px; }
.topo-tip i { font-style: normal; }
.topo-tip em { margin-top: 4px; color: var(--mist); font-size: 11.500px; }
.topo-detail { margin-top: 18px; }
.topo-link.selected .line { stroke-opacity: 1; filter: drop-shadow(0 0 4px currentColor); }
.topo-link .hit { cursor: pointer; }
.topo-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 22px; margin: 4px 0 16px; font-size: 13px; }
.topo-facts span { display: flex; flex-direction: column; gap: 2px; color: var(--mist); min-width: 0; }
.topo-facts i { font-style: normal; font-size: 12px; }
.topo-facts b { color: var(--ice); font-weight: 600; overflow-wrap: anywhere; }
.topo-hist { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.topo-hist > header { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 18px; margin-bottom: 10px; }
.topo-hist > header > div:first-child { flex: 1 1 260px; }
.topo-hist h3 { margin: 0 0 2px; font: 600 16px/1.2 var(--display); }
.topo-history { margin-top: 28px; }
.topo-detail .dev-table td { white-space: normal; }
.topo-detail .dev-table td:nth-child(2), .topo-detail .dev-table td:nth-child(3) { min-width: 180px; max-width: 320px; }
/* Botón Syslog On / Off de las listas de equipos */
.syslog-toggle.on { color: var(--cyan); border-color: rgba(61, 225, 255, .45); background: rgba(61, 225, 255, .08); }
.syslog-toggle.on::before { content: "●"; margin-right: 6px; font-size: 9px; vertical-align: 1px; }
.syslog-toggle.off { color: var(--mist); }
.syslog-toggle.off::before { content: "○"; margin-right: 6px; font-size: 9px; vertical-align: 1px; }

.topo-vlans { position: relative; }
.topo-vlan { height: 40px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.topo-vlan-menu { position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; display: grid; gap: 8px; width: 360px; max-width: calc(100vw - 32px);
  padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--deep); box-shadow: 0 16px 40px rgba(0, 0, 0, .55); }
.topo-vlan-menu[hidden] { display: none; }
.topo-vlan-list { display: grid; gap: 2px; max-height: 320px; overflow-y: auto; }
.topo-vlan-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13.500px; cursor: pointer; }
.topo-vlan-item:hover { background: rgba(61, 225, 255, .07); }
.topo-vlan-item span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topo-vlan-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 6px; border-top: 1px solid var(--line-soft); font-size: 12.500px; }
.topo-vlan-keys { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; margin-right: 8px; }
.topo-vlan-keys span { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.key.sx { background: var(--sx); }
.key.s3 { background: var(--s3); }
/* Con varias VLAN elegidas, el color del enlace es el de su VLAN (no el de uso). */
.topo-link.byvlan .line { stroke-opacity: .85; }
.topo-link.byvlan.s1 .line { stroke: var(--s1-hi); }
.topo-link.byvlan.s2 .line { stroke: var(--s2-hi); }
.topo-link.byvlan.s3 .line { stroke: var(--s3-hi); }
.topo-link.byvlan.sx .line { stroke: var(--sx-hi); }
.topo-dot.byvlan.s1 { fill: var(--s1-hi); }
.topo-dot.byvlan.s2 { fill: var(--s2-hi); }
.topo-dot.byvlan.s3 { fill: var(--s3-hi); }
.topo-dot.byvlan.sx { fill: var(--sx-hi); }
.topo-vlan-note { margin: -4px 0 12px; padding: 10px 14px; border: 1px solid rgba(61, 225, 255, .3); border-radius: 8px; background: rgba(61, 225, 255, .06); color: var(--ice); font-size: 13.500px; }

.topo-vlan-menu.to-left { left: auto; right: 0; }
.topo-legend.byvlan .use { display: none; }

/* ---------- AI ---------- */
.ai-health { display: grid; grid-template-columns: minmax(220px, auto) 1fr auto; align-items: center; gap: 14px 28px; margin-bottom: 18px;
  padding: 18px 22px; border: 1px solid var(--line-soft); border-radius: 12px; background: #0b1236; }
.ai-state { display: flex; align-items: center; gap: 12px; }
.ai-state b { display: block; font: 700 22px/1.2 var(--display); }
.ai-state .dim { font-size: 12.500px; }
.ai-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--mist); flex: none; }
.ai-state.ok .ai-dot { background: var(--svc-on); box-shadow: 0 0 12px var(--svc-on); }
.ai-state.atencion .ai-dot { background: var(--amber); box-shadow: 0 0 12px var(--amber); }
.ai-state.problemas .ai-dot { background: var(--lv3); box-shadow: 0 0 12px var(--lv3); }
.ai-state.critico .ai-dot { background: var(--magenta); box-shadow: 0 0 14px var(--magenta); }
.ai-summary { margin: 0; color: var(--ice); font-size: 14px; line-height: 1.55; }
.ai-counts { display: flex; gap: 6px; }
.ai-count { display: grid; justify-items: center; min-width: 64px; padding: 6px 8px; border: 1px solid var(--line-soft); border-radius: 8px; color: var(--mist); font-size: 11.500px; }
.ai-count b { font: 700 20px/1.1 var(--display); color: var(--ice); }
.ai-count.sev-critica b { color: var(--magenta); }
.ai-count.sev-alta b { color: var(--lv3); }
.ai-count.sev-media b { color: var(--amber); }
.ai-count.sev-baja b { color: var(--cyan); }
.ai-alerts { display: grid; gap: 14px; }
.ai-alert { display: grid; gap: 12px; padding: 16px 20px 14px; border: 1px solid var(--line-soft); border-left: 4px solid var(--mist); border-radius: 10px; background: #0b1236; }
.ai-alert.sev-critica { border-left-color: var(--magenta); }
.ai-alert.sev-alta { border-left-color: var(--lv3); }
.ai-alert.sev-media { border-left-color: var(--amber); }
.ai-alert.sev-baja { border-left-color: var(--cyan); }
.ai-alert.closed { opacity: .65; }
.ai-alert header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ai-alert h3 { flex-basis: 100%; margin: 2px 0 0; font: 700 17px/1.3 var(--display); }
.ai-seen { flex-basis: 100%; font-size: 12.500px; }
.ai-sev { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(142, 155, 203, .15); color: var(--mist); }
.ai-sev.sev-critica { background: rgba(255, 79, 184, .16); color: var(--magenta); }
.ai-sev.sev-alta { background: rgba(255, 138, 61, .16); color: var(--lv3); }
.ai-sev.sev-media { background: rgba(255, 196, 87, .16); color: var(--amber); }
.ai-sev.sev-baja { background: rgba(61, 225, 255, .12); color: var(--cyan); }
.ai-affected { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.300fr); gap: 18px; }
.ai-body h4 { margin: 0 0 4px; color: var(--mist); font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: none; }
.ai-body p { margin: 0; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.ai-steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; line-height: 1.5; }
.ai-alert details summary { color: var(--mist); font-size: 13px; cursor: pointer; width: fit-content; }
.ai-alert details .ai-body { margin-top: 10px; }
.ai-alert footer { display: flex; gap: 6px; justify-content: flex-end; }
.ai-note { margin: 0; font-size: 13px; }
.ai-empty { padding: 34px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; }
.ai-pill { padding: 2px 10px; border-radius: 999px; font-size: 12.500px; font-weight: 600; background: rgba(142, 155, 203, .15); }
.ai-pill.ok { color: var(--svc-on); } .ai-pill.atencion { color: var(--amber); } .ai-pill.problemas { color: var(--lv3); } .ai-pill.critico { color: var(--magenta); }
.ai-dialog { width: min(560px, calc(100vw - 32px)); }
.ai-dialog.wide { width: min(1000px, calc(100vw - 32px)); }
.ai-dialog textarea.input { height: auto; padding-top: 8px; resize: vertical; }
.ai-pre { max-height: 60vh; overflow: auto; margin: 10px 0; padding: 12px 14px; border-radius: 8px; background: rgba(7, 11, 31, .7); color: var(--mist);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .ai-health { grid-template-columns: 1fr; }
  .ai-body { grid-template-columns: 1fr; }
}

.ai-customer { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: rgba(61, 225, 255, .07); border: 1px solid rgba(61, 225, 255, .25); }
.ai-customer h4 { color: var(--cyan); }
a.chip.ai-user { color: var(--ice); text-decoration: none; }
a.chip.ai-user:hover { border-color: var(--cyan); color: var(--cyan); }

/* ---------- AI (2): franja de estado, lista compacta, detalle y chat ---------- */
.ai-head { margin-bottom: 12px; }
.ai-strip { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px 22px; margin-bottom: 16px;
  padding: 12px 16px; border: 1px solid var(--line-soft); border-radius: 12px; background: #0b1236; }
.ai-strip .ai-state b { font: 700 17px/1.2 var(--display); }
.ai-strip .ai-state small { display: block; color: var(--mist); font-size: 12px; }
.ai-strip .ai-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; font-size: 13.500px; color: var(--mist); }
.ai-strip .ai-counts { gap: 4px; }
.ai-strip .ai-count { min-width: 56px; padding: 4px 8px; background: transparent; font: inherit; font-size: 11px; cursor: pointer; }
.ai-strip .ai-count b { font-size: 17px; }
.ai-strip .ai-count[aria-pressed="true"] { border-color: var(--cyan); background: rgba(61, 225, 255, .1); }
.ai-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.ai-side { display: grid; gap: 10px; min-width: 0; }
.ai-tools { display: grid; gap: 8px; }
.ai-tools .segmented { display: grid; grid-template-columns: repeat(3, 1fr); }
.ai-tools .segmented .btn { height: 34px; padding: 0 8px; font-size: 13px; }
.ai-general, .ai-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 1px solid var(--line-soft); border-radius: 10px;
  background: #0b1236; color: var(--ice); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.ai-general:hover, .ai-row:hover { border-color: var(--line); background: #0f1840; }
.ai-general.selected, .ai-row.selected { border-color: var(--cyan); background: rgba(61, 225, 255, .08); box-shadow: inset 3px 0 0 var(--cyan); }
.ai-general small { display: block; color: var(--mist); font-size: 12px; }
.ai-list { display: grid; gap: 6px; max-height: calc(100vh - 330px); overflow-y: auto; padding-right: 2px; }
.ai-row { align-items: flex-start; }
.ai-row.closed { opacity: .6; }
.ai-row-sev { flex: none; width: 52px; margin-top: 2px; padding: 2px 0; border-radius: 6px; font-size: 10.500px; font-weight: 700; text-align: center;
  background: rgba(142, 155, 203, .15); color: var(--mist); }
.ai-row-sev.sev-critica { background: rgba(255, 79, 184, .16); color: var(--magenta); }
.ai-row-sev.sev-alta { background: rgba(255, 138, 61, .16); color: var(--lv3); }
.ai-row-sev.sev-media { background: rgba(255, 196, 87, .16); color: var(--amber); }
.ai-row-sev.sev-baja { background: rgba(61, 225, 255, .12); color: var(--cyan); }
.ai-row-main { display: grid; gap: 2px; min-width: 0; }
.ai-row-main b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13.500px; font-weight: 600; line-height: 1.3; }
.ai-row-main small { color: var(--mist); font-size: 11.500px; }
.ai-list-empty { padding: 18px; text-align: center; }
.ai-runs summary { color: var(--mist); font-size: 13px; cursor: pointer; }
.ai-runs-note { margin: 8px 0; font-size: 12px; }
.ai-runs-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.ai-runs-table td { padding: 4px 4px; border-top: 1px solid var(--line-soft); }
.ai-avatar { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--cyan), #7a5cf0 60%, var(--magenta)); color: #071022; font: 700 12px var(--display); }
.ai-avatar.big { width: 42px; height: 42px; font-size: 15px; border-radius: 12px; }

.ai-main { position: sticky; top: 14px; display: flex; flex-direction: column; min-width: 0; height: calc(100vh - 28px); min-height: 520px;
  border: 1px solid var(--line-soft); border-radius: 12px; background: #0b1236; overflow: hidden; }
.ai-detail { flex: none; max-height: 46%; overflow-y: auto; padding: 14px 18px 10px; border-bottom: 1px solid var(--line-soft); }
.ai-detail-head { display: flex; align-items: flex-start; gap: 12px; }
.ai-detail-head h2 { margin: 4px 0 0; font: 700 18px/1.3 var(--display); }
.ai-detail-head p { margin: 2px 0 0; font-size: 13px; }
.ai-detail-title { flex: 1; min-width: 0; }
.ai-detail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.ai-detail-actions select { height: 36px; max-width: 320px; }
.ai-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; }
.ai-detail .ai-affected { margin: 10px 0 2px; }
.ai-tabs { margin-top: 10px; }
.ai-tabs button { padding: 8px 12px; font-size: 13px; }
.ai-tab { padding: 10px 2px 2px; font-size: 14px; line-height: 1.55; }
.ai-tab p { margin: 0 0 6px; }
.ai-say { padding: 10px 12px; border-radius: 8px; background: rgba(61, 225, 255, .07); border: 1px solid rgba(61, 225, 255, .25); }

.ai-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ai-messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: grid; align-content: start; gap: 14px; }
.ai-msg { display: flex; gap: 10px; max-width: 92%; }
.ai-msg.user { margin-left: auto; flex-direction: column; align-items: flex-end; }
.ai-msg small { color: var(--mist); font-size: 11px; margin-top: 3px; }
.ai-bubble { padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.ai-msg.user .ai-bubble { background: linear-gradient(135deg, rgba(61, 225, 255, .22), rgba(122, 92, 240, .25)); border-bottom-right-radius: 4px; }
.ai-msg.bot .ai-bubble { background: #111a48; border: 1px solid var(--line-soft); border-top-left-radius: 4px; }
.ai-bubble p { margin: 0 0 8px; } .ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble h4 { margin: 10px 0 6px; font: 700 14px var(--display); color: var(--ice); }
.ai-bubble h4:first-child { margin-top: 0; }
.ai-bubble ul, .ai-bubble ol { margin: 4px 0 8px; padding-left: 20px; display: grid; gap: 3px; }
.ai-bubble code { padding: 1px 5px; border-radius: 4px; background: rgba(7, 11, 31, .7); font: 12.500px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ai-bubble pre { margin: 6px 0 8px; padding: 10px 12px; border-radius: 8px; background: rgba(7, 11, 31, .8); overflow-x: auto; }
.ai-bubble pre code { padding: 0; background: none; }
.ai-bubble a { color: var(--cyan); }
.ai-error { color: var(--magenta); }
.ai-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--mist); animation: ai-dots 1.2s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; } .ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dots { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-chat-empty { display: grid; justify-items: center; gap: 10px; margin: auto; padding: 30px 20px; max-width: 420px; text-align: center; color: var(--mist); font-size: 14px; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 8px; }
.ai-suggestion { background: transparent; color: var(--mist); font: inherit; font-size: 12.500px; cursor: pointer; }
.ai-suggestion:hover { border-color: var(--cyan); color: var(--cyan); }
.ai-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px 14px; border-top: 1px solid var(--line-soft); }
.ai-input textarea { flex: 1; min-height: 44px; max-height: 160px; height: 44px; padding-top: 11px; resize: none; line-height: 1.4; }
@media (max-width: 1100px) {
  .ai-strip { grid-template-columns: 1fr; }
  .ai-layout { grid-template-columns: 1fr; }
  .ai-list { max-height: 360px; }
  .ai-main { position: static; height: 80vh; }
}
.ai-input textarea { font: 400 14px/1.4 var(--body); }
.ai-msg.bot > div { display: grid; gap: 2px; min-width: 0; }
.ai-suggest { padding-top: 6px; }
@media (max-width: 700px) {
  .ai-detail-head { flex-wrap: wrap; }
  .ai-detail-title { flex-basis: 100%; }
  .ai-detail-actions { margin-left: 0; }
  .ai-detail { max-height: 40%; }
  .ai-msg { max-width: 100%; }
}

/* ---------- AI (3): detalle a lo ancho y consultor en ventana flotante ---------- */
.ai-main { position: static; height: auto; min-height: 0; overflow: visible; }
.ai-detail { max-height: none; overflow: visible; padding: 16px 20px 14px; border-bottom: 0; }
.ai-detail .ai-tab { padding: 12px 2px 4px; }
.ai-empty-detail { display: grid; justify-items: center; gap: 8px; padding: 46px 20px; text-align: center; }
.ai-empty-detail h2 { margin: 6px 0 0; font: 700 18px var(--display); }
.ai-empty-detail p { margin: 0 0 8px; max-width: 46ch; }
.ai-ask { display: inline-flex; align-items: center; gap: 7px; border-color: rgba(61, 225, 255, .45); color: var(--ice); }
.ai-avatar.mini { width: 18px; height: 18px; border-radius: 5px; font-size: 8.500px; }

.ai-fab { position: fixed; right: 24px; bottom: 24px; z-index: 40; display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 0 20px 0 10px;
  border: 1px solid rgba(61, 225, 255, .45); border-radius: 26px; background: #111a48; color: var(--ice); font: 600 14.500px var(--body); cursor: pointer;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .55), 0 0 0 1px rgba(61, 225, 255, .08); transition: transform .15s, border-color .15s; }
.ai-fab:hover { transform: translateY(-2px); border-color: var(--cyan); }
.ai-fab.active { opacity: 0; pointer-events: none; }
.ai-fab-dot { position: absolute; top: 8px; right: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 10px var(--magenta); }
.ai-fab-dot[hidden] { display: none; }

.ai-chatbox { position: fixed; right: 24px; bottom: 24px; z-index: 41; display: flex; flex-direction: column; width: 400px; height: min(620px, calc(100vh - 48px));
  border: 1px solid var(--line); border-radius: 16px; background: #0b1236; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6), 0 0 0 1px rgba(61, 225, 255, .1); animation: ai-pop .18s ease-out; transform-origin: bottom right; }
.ai-chatbox[hidden] { display: none; }
.ai-chatbox.big { width: min(780px, calc(100vw - 48px)); height: calc(100vh - 48px); }
@keyframes ai-pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.ai-chatbox-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(61, 225, 255, .07), transparent); }
.ai-chatbox-title { display: grid; gap: 3px; flex: 1; min-width: 0; }
.ai-chatbox-title b { font: 700 15px var(--display); }
.ai-chatbox-title > span { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--mist); }
.ai-ctx { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--cyan); }
.ai-ctx-x { flex: none; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--mist); font: inherit; font-size: 11px; cursor: pointer; }
.ai-ctx-x:hover { border-color: var(--cyan); color: var(--cyan); }
.ai-thread-select { width: 100%; max-width: 100%; height: 26px; padding: 0 6px; border: 1px solid var(--line-soft); border-radius: 6px; background: #0b1236; color: var(--mist); font: inherit; font-size: 12px; }
.ai-icon-btn { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--mist); font-size: 15px; cursor: pointer; }
.ai-icon-btn:hover { border-color: var(--line); color: var(--ice); }
.ai-chatbox .ai-messages { padding: 14px; gap: 12px; }
.ai-chatbox .ai-msg { max-width: 100%; }
.ai-chatbox .ai-msg.user { max-width: 88%; }
.ai-chatbox .ai-bubble { font-size: 13.500px; padding: 9px 12px; }
.ai-chatbox .ai-suggest { padding: 0 12px 8px; }
.ai-chatbox .ai-suggestion { font-size: 12px; padding: 3px 9px; }
.ai-chatbox .ai-input { padding: 10px 12px 12px; }
.ai-chatbox .ai-input .btn { width: 44px; height: 44px; padding: 0; font-size: 16px; }
.ai-chatbox .ai-chat-empty { padding: 24px 10px; font-size: 13.500px; }
@media (max-width: 700px) {
  .ai-fab { right: 16px; bottom: 84px; }
  .ai-chatbox, .ai-chatbox.big { right: 0; bottom: 0; width: 100vw; height: 100vh; border-radius: 0; }
}
@media (max-width: 700px) { #chat-size { display: none; } }

/* Sesiones colgadas */
.macblock-fields.stale-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- OLT y ONU ---------- */
.notice.warn { border-color: rgba(255, 196, 87, .45); background: rgba(255, 196, 87, .07); color: var(--amber); }
.pon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 18px; }
.pon-card {
  display: grid; gap: 2px; padding: 12px 14px; text-align: left; cursor: pointer; color: var(--ice); font: inherit;
  background: #0b1236; border: 1px solid var(--line); border-radius: 8px; transition: border-color .15s, background .15s;
}
.pon-card:hover, .pon-card:focus-visible { border-color: rgba(61, 225, 255, .55); outline: none; }
.pon-card.on { border-color: var(--cyan); background: rgba(61, 225, 255, .1); box-shadow: 0 0 0 1px rgba(61, 225, 255, .25) inset; }
.pon-card.off { opacity: .6; }
.pon-name { font: 600 13px/1.2 var(--display); color: var(--mist); letter-spacing: .02em; }
.pon-card b { font: 700 26px/1.15 var(--display); }
.pon-card b .dim { font-size: 16px; font-weight: 500; }
.pon-card .dim { font-size: 12.500px; }
.onu-table { table-layout: fixed; width: 100%; }
.onu-table .c-onu { width: 7%; }
.onu-table .c-user { width: 15%; }
.onu-table .c-desc { width: 12%; }
.onu-table .c-model { width: 11%; }
.onu-table .c-state { width: 10%; }
.onu-table .c-dist { width: 7.500%; }
.onu-table .c-rx { width: 7.500%; }
.onu-table .c-rate { width: 9%; }
.onu-table .c-down { width: 12%; }
.onu-table td, .onu-table th { white-space: nowrap; }
.onu-table td { overflow: hidden; text-overflow: ellipsis; }
.onu-table td.wrap { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 860px) {
  .onu-table { table-layout: auto; min-width: 980px; }
}
.onu-facts { flex-wrap: wrap; gap: 14px 36px; margin-bottom: 18px; text-align: left; }
.onu-facts dd { font-size: 19px; }
.onu-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
@media (max-width: 1100px) { .onu-lists { grid-template-columns: 1fr; } }
.panel-card { min-width: 0; padding: 16px 18px; background: #0b1236; border: 1px solid var(--line); border-radius: 10px; }
.panel-card h2 { margin-bottom: 10px; font: 600 17px/1.2 var(--display); }
.chart-empty { padding: 34px 0; text-align: center; }
.fiber-note { margin-top: 4px; max-width: 110ch; font-size: 14px; line-height: 1.45; }
.fiber-note .dim { font-size: 13px; }
#fiber-more:empty { display: none; }
#fiber-card > header .actions { display: flex; gap: 6px; }
.fiber-chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 14px 0 6px; }
.stat b.sfp.good { color: var(--cyan); }
.stat b.sfp.warn { color: var(--amber); }
.stat b.sfp.bad { color: var(--magenta); }

/* ---------- Módulo ONUs ---------- */
.onu-rank .rank-head { flex-wrap: nowrap; align-items: baseline; }
.onu-rank .rank-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ice); }
.onu-rank .rank-head > .num { flex: none; color: var(--ice); font-weight: 600; }
.onu-rank .rank-detail { display: block; margin-top: 3px; font-size: 12.500px; }
.rank-bar i.lv-good { background: var(--cyan); }
.rank-bar i.lv-warn { background: var(--amber); }
.rank-bar i.lv-bad { background: var(--magenta); }
.rank-bar i.s3 { background: var(--s3); }
.onu-breakdown td, .onu-breakdown th { white-space: nowrap; }
.onu-breakdown td:last-child { white-space: normal; }
/* Muchos rangos (módulo ONUs): en pantallas chicas los botones bajan de renglón en vez de ensanchar la página. */
@media (max-width: 860px) {
  .segmented.many { flex-wrap: wrap; max-width: 100%; }
  .segmented.many .btn { flex: 1 0 auto; height: 34px; padding: 0 10px; border-radius: 0; margin: 0 0 -1px -1px; }
}
.onu-rank { grid-template-columns: minmax(0, 1fr); }
.onu-rank > li { min-width: 0; }

/* ---------- Historial del switch ---------- */
.sw-history { margin-top: 28px; }
.sw-history-head { margin-bottom: 14px; }
.sw-history-head h2 { font: 600 22px/1.2 var(--display); }
.link-button { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.link-button:hover, .link-button:focus-visible { color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; }
.sw-port-select { max-width: 320px; }

/* ---------- Menú en pantallas bajas (notebooks) ----------
   La lista de secciones ocupa el alto que queda y se compacta según el alto de la ventana;
   si aun así no entra, se desplaza dentro del menú (sin mover el pie con la sesión y Salir). */

@media (min-width: 861px) {
  .nav { flex: 1 1 auto; min-height: 0; align-content: start; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }
  .rail-foot { padding-top: 10px; }
}
@media (min-width: 861px) and (max-height: 900px) {
  .rail { padding-top: 14px; padding-bottom: 14px; }
  .brand { padding-bottom: 14px; }
  .nav { gap: 2px; }
  .nav a { height: 36px; }
  .nav a[aria-current="page"]::before { top: 7px; bottom: 7px; }
}
@media (min-width: 861px) and (max-height: 760px) {
  .rail { padding-top: 10px; padding-bottom: 10px; }
  .brand { padding-bottom: 10px; }
  .brand img { width: 26px; height: 26px; }
  .nav { gap: 1px; }
  .nav a { height: 32px; }
  .nav a[aria-current="page"]::before { top: 6px; bottom: 6px; }
  .rail-foot { grid-template-columns: 1fr auto; gap: 6px; }
  .rail-foot .who { grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rail-foot .btn { height: 30px; padding: 0 10px; font-size: 12px; }
}
@media (min-width: 861px) and (max-height: 640px) {
  .brand { padding-bottom: 8px; }
  .nav a { height: 28px; }
  .nav a[aria-current="page"]::before { top: 5px; bottom: 5px; }
}
/* Plegado, el pie (sesión, contraseña, Salir) no se ve: que tampoco ocupe alto, así entran todos los íconos. */
@media (min-width: 861px) and (max-height: 900px) {
  .rail:not(:hover):not(:has(:focus-visible)) .rail-foot { display: none; }
}

/* ---------- Conectados en notebooks ----------
   Bajo 1440 px la tabla no entra entera: se ocultan columnas de a pasos, de la menos usada a la más
   (clases col-<clave> que pone onlineView). Lo oculto sigue a mano: Autentica en el title de Equipo;
   Bajada y Subida en el title de En línea; todo en la ficha. El comentario ya no es columna (2026-10-15,
   pedido del usuario): va en el title del usuario y sigue entrando en la búsqueda. */
@media (min-width: 861px) and (max-width: 1439px) {
  .online-table .col-auth { display: none; }
}
@media (min-width: 861px) and (max-width: 1279px) {
  .online-table .col-down, .online-table .col-up { display: none; }
}
/* Encabezado de Conectados en notebooks: los indicadores en dos renglones parejos (número y texto corto),
   sin que el texto se parta palabra por palabra. */
@media (min-width: 861px) and (max-width: 1439px) {
  .main.fill .facts { gap: 18px; }
  .main.fill .facts dt { font-size: 12px; line-height: 1.25; max-width: 13ch; }
  .main.fill .facts dd { font-size: 20px; }
  .main.fill .fiber-lead p small { max-width: 30ch; }
}
/* Todas las tablas en notebooks (861 a 1439 px): menos relleno lateral, así entran sin desplazarse.
   Las tablas con reglas propias más específicas (Conectados, Radius log...) no cambian. */
@media (min-width: 861px) and (max-width: 1439px) {
  th { padding: 11px 9px; }
  td { padding: 10px 9px; }
  th:first-child, td:first-child { padding-left: 14px; }
  th:last-child, td:last-child { padding-right: 14px; }
  .kpi { padding: 16px 14px 12px; }
  .kpi b, .kpi > a.num { font-size: 24px; }
  /* La última columna (detalle, motivo, botones) puede bajar de renglón en vez de empujar la tabla. */
  td:last-child { white-space: normal; }
  .main.fill td:last-child { white-space: nowrap; }
}
/* Notebooks de 1280 px: un poco menos todavía (columnas de texto que bajan de renglón más angostas). */
@media (min-width: 861px) and (max-width: 1365px) {
  th { padding-left: 7px; padding-right: 7px; }
  td { padding-left: 7px; padding-right: 7px; }
  td.wrap { min-width: 140px; }
}
/* Notebooks con escala de Windows (1366 al 125 % = 1093 px, 1280 al 150 % = 853...): un escalón más. */
@media (min-width: 861px) and (max-width: 1199px) {
  table { font-size: 13.5px; }
  th { padding-left: 5px; padding-right: 5px; }
  td { padding-left: 5px; padding-right: 5px; }
  th:first-child, td:first-child { padding-left: 10px; }
  th:last-child, td:last-child { padding-right: 10px; }
  td.wrap { min-width: 120px; }
  .main.fill table { font-size: 13px; }
  .main.fill td.mac, .main.fill td.sig { font-size: 12px; }
  .main.fill td:first-child { max-width: 130px; }
  .main.fill .fiber-lead p small { max-width: 24ch; }
}
@media (min-width: 861px) and (max-width: 1199px) {
  /* Mikrotik / Switchs y routers / OLT: los cuatro botones en una columna en vez de la grilla de 2×2. */
  .routers-table .row-actions { grid-template-columns: 96px; }
  .routers-table .row-actions .btn-small { padding: 0 6px; }
  th:last-child { white-space: normal; }
}
/* 861 a 1099 px (1280 al 125 %, 1024...): los títulos de columna pueden ir en dos renglones y celdas más angostas;
   en Conectados se oculta también Equipo (está en la ficha). */
@media (min-width: 861px) and (max-width: 1099px) {
  th { white-space: normal; padding-left: 4px; padding-right: 4px; }
  td { padding-left: 4px; padding-right: 4px; }
  table { font-size: 13px; }
  td.wrap { min-width: 110px; }
  .online-table .col-router { display: none; }
  .main.fill th { white-space: nowrap; }
  .main.fill td:first-child { max-width: 120px; }
}
@media (min-width: 861px) and (max-width: 1099px) {
  /* Cualquier celda puede bajar de renglón (fechas, nombres de equipos, textos) antes que empujar la tabla.
     Conectados (main.fill) mantiene filas de un renglón. */
  td { white-space: normal; }
  .main.fill td { white-space: nowrap; }
}
@media (min-width: 861px) and (max-width: 1023px) {
  .online-table .col-mac { display: none; }
}
@media (min-width: 861px) and (max-width: 1099px) {
  .dev-table .tag { white-space: normal; }
}
@media (min-width: 861px) and (max-width: 1023px) {
  td.wrap { min-width: 90px; }
}
