:root {
  --bg: #0b1220;
  --bg2: #111827;
  --card: #151c2c;
  --line: #1f2a44;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #f59e0b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 500px at 10% -10%, #1e3a8a33, transparent), var(--bg);
  color: var(--text);
}
button, input, select { font-family: inherit; }
.hidden { display: none !important; }

#login {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.brand-copy { min-width: 0; }
.logo {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--blue); display: grid; place-items: center;
  font-weight: 800; letter-spacing: .04em; overflow: hidden; flex-shrink: 0;
  text-transform: uppercase;
}
.logo.has-img { background: #fff; padding: 0; }
.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-wide {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.brand-wide .logo {
  width: 100%;
  height: auto;
  min-height: 52px;
  max-height: none;
  border-radius: 10px;
  padding: 8px 10px;
}
.brand-wide .logo img {
  width: 100%;
  height: auto;
  max-height: 72px;
  object-fit: contain;
}
aside .brand-aside {
  margin-bottom: 14px;
}
aside .brand-wide .logo {
  padding: 10px 8px;
  background: #fff;
}
aside .brand-wide h1 {
  font-size: 16px;
  line-height: 1.25;
  word-break: break-word;
}
h1 { font-size: 20px; margin: 0; }
h2 { margin: 0; font-size: 22px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
input, select {
  width: 100%; background: #0f172a; color: var(--text);
  border: 1px solid #334155; border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
.btn {
  border: 0; border-radius: 8px; padding: 10px 14px; cursor: pointer;
  font-weight: 600; font-size: 13px; color: #fff;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-blue { background: var(--blue); }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-ghost { background: #1e293b; color: var(--text); }
.btn-wide { width: 100%; margin-top: 18px; padding: 12px; }
.err { color: #fca5a5; font-size: 13px; min-height: 18px; margin-top: 10px; }
.turnstile { margin-top: 14px; }

body.in-app { overflow: hidden; }
#app {
  height: 100%;
  min-height: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: 58px 1fr;
  grid-template-areas: "topbar topbar" "aside main";
}
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: linear-gradient(#121a2c, #0e1626);
  border-bottom: 1px solid #334155;
  box-shadow: 0 10px 28px #00000055;
  z-index: 8;
}
.topbar-toggle, .topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #334155;
  background: #152036;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.topbar-toggle {
  width: 38px; height: 38px; padding: 0; flex-shrink: 0;
}
.topbar-toggle svg, .topbar-btn svg { width: 18px; height: 18px; }
.topbar-toggle:hover, .topbar-btn:hover { border-color: #60a5fa; color: #fff; background: #1e3a8a; }
.topbar-brand { margin: 0; min-width: 0; }
.topbar-brand .logo { width: 36px; height: 36px; font-size: 13px; }
.topbar-brand.brand-wide {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.topbar-brand.brand-wide .logo {
  width: auto; height: 36px; min-height: 36px; max-height: 36px;
  padding: 4px 8px; background: #fff;
}
.topbar-brand.brand-wide .logo img { width: auto; height: 28px; max-height: 28px; }
.topbar-brand h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-chip {
  font-size: 12px; font-weight: 700;
  color: #93c5fd; background: #1e3a8a44;
  border: 1px solid #1d4ed866;
  border-radius: 999px; padding: 6px 10px;
  white-space: nowrap; max-width: 42vw; overflow: hidden; text-overflow: ellipsis;
}
.topbar-spacer { flex: 1; }
.topbar-btn { height: 38px; padding: 0 12px; }
aside {
  grid-area: aside;
  width: 248px;
  background: linear-gradient(#10182a, #0c1422);
  border-right: 1px solid #2a3a5c;
  box-shadow: 10px 0 28px #00000040;
  padding: 16px 10px;
  display: flex; flex-direction: column; gap: 6px;
  overflow: hidden;
  transition: width .2s ease;
}
#app.aside-collapsed aside { width: 76px; padding: 16px 8px; }
#app.aside-collapsed .nav-label { display: none; }
#app.aside-collapsed .nav { justify-content: center; padding: 11px 0; }
#app.aside-collapsed .ico-collapse { transform: scaleX(-1); }
.ico-collapse { transition: transform .2s ease; }
.nav {
  background: transparent; border: 0; color: var(--muted); text-align: left;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  width: 100%;
}
.nav svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav:hover { background: #1e293b; color: #fff; }
.nav.active {
  background: #1e3a8a66; color: #fff;
  box-shadow: inset 3px 0 0 #60a5fa;
}
.spacer { flex: 1; }
.marca-row {
  display: flex; align-items: center; gap: 12px; margin: 8px 0 4px;
}
.marca-row input[type=file] { flex: 1; max-width: none; padding: 8px; }
#cfgLogoPrev.has-img {
  width: 180px; height: auto; min-height: 48px; max-height: 72px;
  padding: 6px; background: #fff;
}
#cfgLogoPrev.has-img img { height: auto; max-height: 60px; }
.icon-prev {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover;
  background: #0f172a; border: 1px solid var(--line); flex-shrink: 0;
}
.icon-empty {
  display: grid; place-items: center; color: var(--muted); font-size: 16px;
}
.switch {
  display: flex; align-items: center; gap: 10px; margin: 12px 0 8px;
  color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer;
}
.toggle {
  position: relative; width: 44px; height: 24px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span {
  position: absolute; inset: 0; background: #334155; border-radius: 99px; transition: .15s;
}
.toggle span::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .15s;
}
.toggle input:checked + span { background: var(--blue); }
.toggle input:checked + span::before { transform: translateX(20px); }
main { grid-area: main; padding: 22px 26px 40px; overflow: auto; }
.top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.card-btn { cursor: pointer; transition: border-color .15s, background .15s; }
.card-btn:hover { border-color: #3b82f6; }
.card-btn.selected { border-color: #3b82f6; background: #1e3a8a33; }
.card .pair { display: flex; gap: 16px; margin-top: 10px; }
.card .pair span { display: block; }
.grid-listas { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-listas.una { grid-template-columns: 1fr; }
.tabla-wrap { max-height: 42vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.tabla-ips { margin: 0; }
.tabla-ips th, .tabla-ips td { vertical-align: middle; }
.tabla-ips td.col-pais { white-space: nowrap; min-width: 120px; }
.tabla-ips td.col-ip { font-family: Consolas, ui-monospace, monospace; white-space: nowrap; }
.jail-checks { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.jail-checks label { margin: 0; display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; cursor: pointer; }
.jail-checks input { width: auto; margin: 0; accent-color: #2563eb; }
.chk-jails { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.chk-jails label { margin: 0; display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-size: 12px; cursor: pointer; }
.chk-jails input { width: auto; margin: 0; accent-color: #2563eb; }
.ip-linea { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.geo-slot { display: inline-flex; align-items: center; gap: 6px; }
.flag { font-size: 16px; line-height: 1; }
.ip-pais { color: var(--muted); font-size: 12px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) {
  .cards-3, .cards-4, .grid-listas { grid-template-columns: 1fr; }
}
.estado-head { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.badge-estado {
  display: inline-block; font-weight: 700; font-size: 14px;
  padding: 8px 16px; border-radius: 8px;
}
.badge-estado.up { background: #166534; color: #bbf7d0; }
.badge-estado.down { background: #991b1b; color: #fecaca; }
.badge-estado.pause { background: #334155; color: #e2e8f0; }
.uptime-kuma { display: flex; gap: 3px; align-items: stretch; height: 28px; }
.uptime-kuma span {
  flex: 1; min-width: 4px; border-radius: 3px; background: #1e293b;
}
.uptime-kuma span.on { background: #22c55e; }
.uptime-kuma span.off { background: #ef4444; }
.uptime-kuma span.na { background: #1e293b; }
.uptime-leyenda {
  display: flex; justify-content: space-between; color: var(--muted);
  font-size: 12px; margin: 6px 0 4px;
}
.tabla-ips .badge-estado { padding: 4px 10px; font-size: 12px; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.pager .btn { padding: 6px 10px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 6px; }
.ok { color: #4ade80; } .bad { color: #f87171; } .warn { color: #fbbf24; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; align-items: center; }
.toolbar input { max-width: 240px; }
.toolbar select { width: auto; min-width: 140px; max-width: 200px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #0f172a; }
tr.selected td { background: #1e3a8a44; }
.mono { font-family: Consolas, ui-monospace, monospace; }
pre.cmd {
  white-space: pre-wrap;
  background: #0f172a;
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  margin: 12px 0;
}
.dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px;
}
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px #22c55e33; }
.dot.off { background: #64748b; }
.tag {
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 8px;
  background: #1e293b; color: #93c5fd;
}
.tag.pub { color: #86efac; }
.toast {
  position: fixed; right: 18px; bottom: 18px; background: #0f172a;
  border: 1px solid var(--line); color: #86efac; padding: 12px 14px;
  border-radius: 10px; font-size: 13px; max-width: 360px; display: none; z-index: 20;
}
.filtros { margin: 0 0 14px; }
.filtros .filtro-on { background: #1d4ed8; color: #fff; }
.uptime-bar { display: flex; gap: 3px; align-items: center; min-width: 92px; }
.uptime-seg {
  display: inline-block; width: 6px; height: 20px; border-radius: 99px;
  background: #334155;
}
.uptime-seg.on { background: #4ade80; }
.uptime-seg.off { background: #f87171; }
.uptime-seg.na { background: #1e293b; }
.eq-menu {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.eq-menu-tabs { display: flex; gap: 8px; }
.chart-card { padding: 14px 16px 8px; background: #0b1220; }
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chart-head select { width: auto; min-width: 130px; padding: 6px 10px; }
.chart-wrap { position: relative; width: 100%; height: 280px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-tip {
  position: absolute; pointer-events: none; background: #0f172aee;
  border: 1px solid #334155; color: #e2e8f0; padding: 8px 10px;
  border-radius: 8px; font-size: 12px; white-space: nowrap; z-index: 5;
}
.chart-tip .dotc {
  display: inline-block; width: 8px; height: 8px; background: #4ade80;
  margin-right: 6px; vertical-align: middle;
}
.layout-equipo { display: grid; grid-template-columns: 1fr; gap: 16px; }
.panel-vacio { color: var(--muted); padding: 28px 8px; }
.chip-list { display: flex; flex-direction: column; gap: 8px; max-height: 42vh; overflow: auto; }
.chip {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: #0f172a; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
@media (max-width: 980px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 58px auto 1fr;
    grid-template-areas: "topbar" "aside" "main";
  }
  aside {
    width: auto; flex-direction: row; flex-wrap: wrap;
    box-shadow: none; border-right: 0; border-bottom: 1px solid #2a3a5c;
  }
  #app.aside-collapsed aside { width: auto; }
  #app.aside-collapsed .nav-label { display: none; }
  .layout-equipo { grid-template-columns: 1fr; }
  .spacer { display: none; }
  .topbar-btn span { display: none; }
  .topbar-chip { max-width: 28vw; }
}
