/* AxisFlow - estilos */

:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: #c3c2b7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-soft: rgba(42, 120, 214, 0.12);
  --on-accent: #ffffff;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --critical-text: #b42f2f;
  --diff-add: rgba(12, 163, 12, 0.12);
  --diff-del: rgba(208, 59, 59, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  /* Gráficas: paleta categórica validada (orden fijo) y trazos recesivos */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
  /* Mapa de calor: rampa secuencial de un solo tono (claro = pocas visitas, oscuro = muchas) */
  --heat-0: #e7e6e1;
  --heat-1: #cfe0f4;
  --heat-2: #97bfe9;
  --heat-3: #5a97da;
  --heat-4: #2c6dbd;
  --heat-5: #174585;
  --topbar-h: 56px;
  --sidebar-w: 236px;
  --sidebar-w-min: 64px;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: #383835;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-soft: rgba(57, 135, 229, 0.18);
    --good-text: #0ca30c;
    --critical-text: #e66767;
    --diff-add: rgba(12, 163, 12, 0.20);
    --diff-del: rgba(230, 103, 103, 0.20);
    --shadow: none;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --chart-grid: #2c2c2a;
    --chart-axis: #383835;
    /* En oscuro la rampa va de tenue a brillante */
    --heat-0: #2b2b29;
    --heat-1: #1f3550;
    --heat-2: #24538a;
    --heat-3: #3576c4;
    --heat-4: #69a3e6;
    --heat-5: #b5d4f6;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: #383835;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #898781;
  --accent: #3987e5;
  --accent-hover: #5598e7;
  --accent-soft: rgba(57, 135, 229, 0.18);
  --good-text: #0ca30c;
  --critical-text: #e66767;
  --diff-add: rgba(12, 163, 12, 0.20);
  --diff-del: rgba(230, 103, 103, 0.20);
  --shadow: none;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --chart-grid: #2c2c2a;
  --chart-axis: #383835;
  --heat-0: #2b2b29;
  --heat-1: #1f3550;
  --heat-2: #24538a;
  --heat-3: #3576c4;
  --heat-4: #69a3e6;
  --heat-5: #b5d4f6;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; }
p { margin: 0 0 8px; }

.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Barra superior (siempre visible) ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.brand:hover { text-decoration: none; }
.topbar-spacer { flex: 1; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* Idioma (ES/EN) y modo claro/oscuro */
.lang-switch { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; flex: none; }
.lang-btn {
  height: 30px;
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.3px;
  cursor: pointer;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--border-strong); }
.lang-btn:hover:not(.active) { background: var(--surface-2); color: var(--text); }
.lang-btn.active { background: var(--accent-soft); color: var(--accent); cursor: default; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 999px; color: var(--text); }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 13.5px; font-weight: 600; }
.user-meta small { color: var(--text-2); font-size: 12px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; flex: none; font-size: 30px; }
.avatar-initials {
  display: inline-grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}
.avatar-lg.avatar-initials { font-size: 30px; }

.logout-form { margin: 0; }

/* ---------- Menú lateral colapsable ---------- */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden auto;
  transition: width 0.18s ease, transform 0.18s ease;
  z-index: 30;
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text-2);
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .icon { width: 20px; height: 20px; }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.sidebar-footer .version { font-weight: 600; color: var(--text-2); }

.content {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 24px) 28px 48px;
  min-width: 0;
  transition: margin-left 0.18s ease;
}

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-min); }
body.sidebar-collapsed .content { margin-left: var(--sidebar-w-min); }
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-footer .build { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-footer { align-items: center; padding: 12px 4px 14px; }

@media (max-width: 860px) {
  .sidebar { width: var(--sidebar-w); transform: translateX(-100%); box-shadow: var(--shadow); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .sidebar-footer .build { display: inline; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 0 12px; }
  .content, body.sidebar-collapsed .content { margin-left: 0; padding: calc(var(--topbar-h) + 16px) 16px 32px; }
  .user-meta, .logout-form .btn span, .pwa-install-top span { display: none; }
  .brand span { display: none; }
}
/* Botón Instalar app (PWA): solo aparece cuando el navegador ofrece instalar */
.pwa-install[hidden] { display: none; }
.pwa-install-login { width: 100%; height: 40px; gap: 8px; margin-top: 10px; }

/* ---------- Encabezado de página y tarjetas ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card.narrow { max-width: 640px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.card-head-pad { padding: 16px 20px 4px; margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.grid-2 > *, .chart-grid > *, .rank-grid > * { min-width: 0; } /* una tabla ancha se desplaza dentro de su tarjeta en vez de desbordar la cuadrícula */

/* ---------- Indicadores (stat tiles) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
/* Seis indicadores: una fila en pantallas anchas, 3 + 3 en medianas y 2 por fila en angostas (sin uno suelto) */
.tiles-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1280px) { .tiles-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .tiles-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile-label { color: var(--text-2); font-size: 12.5px; }
.tile-value { font-size: 26px; font-weight: 650; line-height: 1.2; margin-top: 4px; overflow-wrap: anywhere; }
.tile-badge { margin-top: 6px; }
a.tile-link { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
a.tile-link:hover, a.tile-link:focus-visible { border-color: var(--accent); }
.tile-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.tile-value-compact { font-size: 20px; overflow-wrap: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
/* Indicador con dos valores (tiempo activo del sistema y de HAProxy) */
.tile-pairs { margin: 6px 0 0; display: grid; gap: 4px; }
.tile-pairs > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tile-pairs dt { color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
.tile-pairs dd { margin: 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Insignias de estado (ícono de color + texto en tinta normal) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.tone-good .icon { color: var(--good); }
.tone-warning .icon { color: var(--warning); }
.tone-serious .icon { color: var(--serious); }
.tone-critical .icon { color: var(--critical); }
.tone-neutral .icon { color: var(--muted); }
.tone-info .icon { color: var(--accent); }

.chip {
  display: inline-block;
  padding: 1px 8px;
  margin: 1px 2px 1px 0;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- Tablas ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--accent-soft); }
.table td.actions, .table th.actions { text-align: right; white-space: nowrap; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
.table-compact th, .table-compact td { padding: 6px 8px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--critical-text); }
.btn-danger:hover { background: var(--diff-del); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

form.inline { display: inline; margin: 0; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field[hidden] { display: none; }
.restore-card { border-color: var(--accent); }
.table tr.row-selected td { background: var(--accent-soft); }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.break-all { word-break: break-all; }
.field.span-all { grid-column: 1 / -1; }
.field label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 96px; font-family: var(--mono); font-size: 12.5px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[readonly], input:disabled, select:disabled, textarea:disabled, textarea[readonly] { background: var(--surface-2); color: var(--text-2); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; white-space: nowrap; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.section-title { margin: 22px 0 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.rows-table input, .rows-table select { min-height: 32px; padding: 4px 8px; }
.rows-table td { padding: 6px; }
.rows-table .w-port { width: 90px; }
.rows-table .w-num { width: 84px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="search"] { max-width: 360px; }

.pw-rules { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; font-size: 12.5px; color: var(--text-2); }
.pw-rules li { display: flex; align-items: center; gap: 6px; }
.pw-rules li .icon { width: 14px; height: 14px; color: var(--muted); }
.pw-rules li.ok { color: var(--text); }
.pw-rules li.ok .icon { color: var(--good); }

/* ---------- Avisos ---------- */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--surface);
}
.alert .icon { margin-top: 1px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert-ok { border-left-color: var(--good); }
.alert-ok > .icon { color: var(--good); }
.alert-error { border-left-color: var(--critical); }
.alert-error > .icon { color: var(--critical); }
.alert-warning { border-left-color: var(--warning); }
.alert-warning > .icon { color: var(--warning); }
.alert-info { border-left-color: var(--accent); }
.alert-info > .icon { color: var(--accent); }

/* ---------- Código y diferencias ---------- */
.code {
  margin: 0;
  padding: 14px 16px;
  max-height: 560px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
  tab-size: 4;
}
.small-code { max-height: 180px; padding: 8px 10px; font-size: 12px; white-space: pre-wrap; }
.section-gap { margin-top: 14px; }
.diff { padding: 8px 0; }
.diff span { display: block; padding: 0 16px; }
.diff .add { background: var(--diff-add); }
.diff .del { background: var(--diff-del); }
.diff .skip { color: var(--muted); font-style: italic; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--text-2); font-size: 12.5px; }
.kv dd { margin: 0; }

.profile-head { display: flex; gap: 18px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-brand strong { font-size: 22px; }
.login-card .field { margin-bottom: 12px; }
.login-links { margin: -4px 0 12px; text-align: right; font-size: 13px; }
.login-back { margin: 14px 0 0; text-align: center; font-size: 13px; }
.login-card .btn-primary { width: 100%; height: 40px; margin-top: 6px; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--muted); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.btn-google { width: 100%; height: 40px; gap: 10px; background: #ffffff; color: #1f1f1f; border-color: #dadce0; }
.btn-google:hover { background: #f7f8f8; }

/* Gráficas en tiempo real (detalle del sitio) */
.charts { margin-top: 4px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.chart-card { margin: 0; padding: 14px 16px 12px; min-width: 0; }
.chart-title { font-weight: 650; margin-bottom: 6px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 4px; font-size: 12px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; flex: none; background: var(--series-1); }
.legend-key.s2 { background: var(--series-2); }
.legend-key.s3 { background: var(--series-3); }
.legend-key.s4 { background: var(--series-4); }
.chart-plot { position: relative; min-height: 200px; border-radius: 6px; }
.chart-plot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-empty { margin: 0; padding: 86px 0; text-align: center; }
.ch-grid { stroke: var(--chart-grid); stroke-width: 1; }
.ch-axis { stroke: var(--chart-axis); stroke-width: 1; }
.ch-cross { stroke: var(--chart-axis); stroke-width: 1; }
.ch-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-label { fill: var(--text-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ch-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; stroke: var(--series-1); }
.ch-line.s2 { stroke: var(--series-2); }
.ch-line.s3 { stroke: var(--series-3); }
.ch-line.s4 { stroke: var(--series-4); }
.ch-dot { stroke: var(--surface); stroke-width: 2; fill: var(--series-1); }
.ch-dot.s2 { fill: var(--series-2); }
.ch-dot.s3 { fill: var(--series-3); }
.ch-dot.s4 { fill: var(--series-4); }
.ch-hit { fill: transparent; cursor: crosshair; }
/* Analítica: barras (SVG generado en el servidor), rankings y tablas en pestañas */
.ch-bar { fill: var(--series-1); }
.ch-hit:hover { fill: var(--accent-soft); }
.chart-plot.an-plot { min-height: 0; }
@media (max-width: 600px) {
  .an-plot .ch-tick { font-size: 17px; } /* el SVG se reduce en pantallas angostas: unidades más grandes = texto legible */
}
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head .chart-title { margin-bottom: 0; }
.rank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; align-items: baseline; font-size: 13px; }
.rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-svg { grid-column: 1 / -1; display: block; width: 100%; height: 8px; }
.rank-track { fill: var(--surface-2); }
.rank-other .ch-bar { fill: var(--muted); }
.rank-other .rank-label { color: var(--text-2); }
/* Analítica › Top 10 países bloqueados: dos columnas en pantallas anchas, en orden de arriba abajo */
.rank.rank-cols { display: block; columns: 2 300px; column-gap: 36px; }
.rank.rank-cols li { break-inside: avoid; margin-bottom: 10px; }
.rank-cols a.rank-label { color: inherit; text-decoration: none; }
.rank-cols a.rank-label:hover { color: var(--accent); text-decoration: underline; }
/* Analítica: valores de los indicadores y tablas que filtran con un clic */
a.an-filter { color: inherit; text-decoration: none; }
a.an-filter:hover, a.an-filter:focus-visible { color: var(--accent); text-decoration: underline; }
.rank-cols .rank-label .cc { margin-right: 2px; }
.ch-bar-blocked { fill: var(--critical); }
.an-tables { padding: 0; overflow: hidden; }
.an-tables .tabs { padding: 4px 12px 0; margin-bottom: 0; }
.an-tables .tabs a { white-space: nowrap; }
.an-note { margin: 10px 16px 0; }
.an-tables > .table-pager { margin: 0; padding: 10px 16px; border-top: 1px solid var(--border); }
.an-table .td-label { max-width: 0; width: 100%; min-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 130px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-size: 12px;
  pointer-events: none;
}
.chart-tip[hidden] { display: none; }
.tip-time { margin-bottom: 4px; color: var(--text-2); }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-row span:last-child { color: var(--text-2); }
.charts.is-stale .chart-plot { opacity: 0.55; }
.chart-table { margin-top: 8px; font-size: 12.5px; }
.chart-table summary { cursor: pointer; color: var(--text-2); }
.chart-table .table-wrap { margin-top: 6px; }
@media (max-width: 860px) {
  .chart-grid { grid-template-columns: 1fr; }
}

/* Tablas: ordenamiento por columna y paginación */
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.th-sort:hover { color: var(--text); }
.th-sort::after { content: "↕"; font-size: 10px; color: var(--muted); }
th[aria-sort="ascending"] .th-sort::after { content: "▲"; color: var(--accent); }
th[aria-sort="descending"] .th-sort::after { content: "▼"; color: var(--accent); }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--text); }
.table-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin: -8px 0 20px; }
.table-pager[hidden] { display: none; }

/* Modales (<dialog>): salida de cada despliegue */
.modal { width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28); }
.modal::backdrop { background: rgba(0, 0, 0, 0.5); }
.modal[open] { display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0 0 4px; font-size: 16px; }
.modal-body { padding: 14px 18px 18px; overflow: auto; min-height: 0; }
.modal-code { margin: 0; max-height: none; white-space: pre-wrap; overflow-wrap: anywhere; }
.modal-narrow { width: min(480px, calc(100vw - 32px)); }
.modal-body > p:first-child { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* Selector múltiple desplegable (Analítica › Omitir sitios): <details> con casillas */
.multi-pick { position: relative; }
.multi-pick > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 38px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
  color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; }
.multi-pick > summary::-webkit-details-marker { display: none; }
.multi-pick > summary::after { content: ""; flex: none; width: 7px; height: 7px; margin-top: -3px; border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2); transform: rotate(45deg); }
.multi-pick > summary > span { overflow: hidden; text-overflow: ellipsis; }
.multi-pick[open] > summary { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.multi-pick.is-disabled > summary { background: var(--surface-2); color: var(--text-2); cursor: not-allowed; }
.multi-pick-panel { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: max(100%, 300px); padding: 8px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22); }
.multi-pick-list { display: grid; gap: 2px; max-height: 280px; overflow: auto; margin: 6px 0; }
.multi-pick-list .check { padding: 5px 6px; border-radius: 6px; white-space: normal; align-items: flex-start; }
.multi-pick-list .check:hover { background: var(--accent-soft); }
.multi-pick-list .check[hidden] { display: none; }
.multi-pick-list .check input { margin-top: 2px; flex: none; }
.multi-pick-actions { display: flex; justify-content: space-between; gap: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.omit-note { margin: -6px 0 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* Inicio: mapa de calor por país */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.geo-card { margin-bottom: 20px; }
.geo-period select { width: auto; min-height: 34px; padding: 4px 10px; }
.geo-grid { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(220px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .geo-grid { grid-template-columns: 1fr; } }
.geo-map { position: relative; margin: 0; min-width: 0; }
.world-map { display: block; width: 100%; height: auto; }
.world-map path { fill: var(--heat-0); stroke: var(--surface); stroke-width: 0.6; stroke-linejoin: round; transition: fill 0.25s; outline: none; }
.world-map path.h1, .geo-key.h1 { fill: var(--heat-1); background: var(--heat-1); }
.world-map path.h2, .geo-key.h2 { fill: var(--heat-2); background: var(--heat-2); }
.world-map path.h3, .geo-key.h3 { fill: var(--heat-3); background: var(--heat-3); }
.world-map path.h4, .geo-key.h4 { fill: var(--heat-4); background: var(--heat-4); }
.world-map path.h5, .geo-key.h5 { fill: var(--heat-5); background: var(--heat-5); }
.geo-key.h0 { background: var(--heat-0); }
.world-map path:hover, .world-map path:focus { stroke: var(--text); stroke-width: 1.2; }
.geo-card.is-loading .world-map { opacity: 0.55; }
.geo-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.geo-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.geo-key { display: inline-block; width: 14px; height: 10px; border-radius: 2px; border: 1px solid var(--border); }
.geo-top h3 { margin: 0 0 10px; font-size: 13.5px; }
.geo-top .rank-label .cc { margin-right: 2px; }
.geo-top > p { margin: 12px 0 0; }
/* Analítica (al final) y Monitoreo (antes de los sitios): el espacio lo da .section-gap; en Analítica cada país filtra */
.section-gap > .geo-card { margin-bottom: 0; }
.geo-linked .world-map path[tabindex] { cursor: pointer; }
.geo-linked a.rank-label { color: inherit; text-decoration: none; }
.geo-linked a.rank-label:hover { color: var(--accent); text-decoration: underline; }
.multi-pick-list .cc { margin-right: 2px; }

/* Bloqueo por país (Editar sitio y Configuraciones globales): origen de la regla y resumen */
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 2px 0 4px; }
.geo-summary { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.geo-summary .icon { flex: none; margin-top: 1px; color: var(--accent); }
.plain-list { margin: 0; padding-left: 18px; }
.plain-list li { margin: 3px 0; }

/* Configuración › Geolocalización */
.kv th { width: 42%; background: transparent; font-weight: 600; color: var(--text-2); white-space: normal; }
.probe-result { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }

/* Analítica: país de cada IP */
.cc { display: inline-block; min-width: 26px; padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; font: 600 11px var(--mono);
  text-align: center; color: var(--text-2); background: var(--surface-2); }
.an-attrib { margin: 0; padding: 8px 16px; border-top: 1px solid var(--border); }

/* Mantenimientos: buscador de sitios */
.site-search { position: relative; max-width: 640px; margin-bottom: 12px; }
.site-results { list-style: none; margin: 4px 0 0; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); max-height: 360px; overflow: auto; }
.site-results[hidden] { display: none; }
.site-results li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 6px; }
.site-results li + li { border-top: 1px solid var(--border); }
.site-results li > div { min-width: 0; }
.site-results li .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-results li .btn { flex: none; }
.site-results li.site-result-empty { display: block; }

/* Vista previa de un sitio (Monitoreo › sitio) */
.preview-form { display: inline-flex; gap: 6px; align-items: center; }
.preview-form select { width: auto; max-width: 240px; min-height: 36px; }
.table-pager .pages { display: flex; align-items: center; gap: 8px; }
.pager-size { display: inline-flex; align-items: center; gap: 8px; }
.pager-size select { width: auto; min-height: 30px; padding: 3px 8px; }

/* Instrucciones (Configuración) */
.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.steps li { padding-left: 2px; }
.steps li::marker { color: var(--text-2); font-weight: 600; }
.help-card { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.help-card h3 { margin-top: 18px; }

/* Bitácora: filtros y paginación */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 14px; align-items: end; margin-bottom: 14px; }
.filters .field-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: -6px 0 20px; }
.pager .pages { display: flex; gap: 6px; }
input[type="date"] {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.login-foot { margin-top: 14px; text-align: center; color: var(--muted); font-size: 12px; }
