/* ==========================================================================
   ASCRIGAR PRO 2 · Sistema de diseño
   Cromo cálido de la marca (marrón / dorado) y datos en la paleta validada para
   daltonismo (azul serie 1, rampa ordinal azul para etapas, rampa ámbar para mapas).
   Escala de espacio: múltiplos de 4 px. Radios: 6 / 8 / 12 px.
   ========================================================================== */

:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r-sm: 6px; --r: 8px; --r-lg: 12px;
  --sidebar-w: 256px; --topbar-h: 60px;

  --bg: #f6f4f0;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --surface-3: #f2efe9;
  --ink: #1d1a17;
  --ink-2: #57514a;
  --muted: #857e75;
  --line: #e7e2da;
  --line-2: #d6cfc4;
  --shadow: 0 1px 2px rgba(40, 28, 16, .05);
  --shadow-pop: 0 12px 32px rgba(40, 28, 16, .16), 0 2px 6px rgba(40, 28, 16, .08);

  --brand: #b7791f;
  --brand-hover: #9b6517;
  --brand-ink: #8a5a14;
  --brand-soft: #f8eedd;
  --focus: 0 0 0 3px rgba(183, 121, 31, .30);

  --sidebar-bg: #1e1712;
  --sidebar-ink: #d8cec3;
  --sidebar-muted: #9a8c7e;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(212, 154, 59, .16);
  --sidebar-line: rgba(255, 255, 255, .07);

  --ok: #0c6b35;      --ok-bg: #e8f4ec;      --ok-line: #bfe0cb;
  --warn: #8a5a00;    --warn-bg: #fdf3dc;    --warn-line: #f1d9a3;
  --danger: #b42318;  --danger-bg: #fdeceb;  --danger-line: #f3c5c1;
  --info: #1c5cab;    --info-bg: #e8f1fc;    --info-line: #c4dbf6;

  /* Datos (paleta de referencia validada: superficie clara #fcfcfb) */
  --viz-surface: #fdfdfc;
  --viz-1: #2a78d6;
  --viz-1-wash: rgba(42, 120, 214, .10);
  --viz-prev: #8f8a82;   /* gris de de-énfasis: ≥ 3:1 sobre la superficie clara */
  --viz-grid: #ebe8e2;
  --viz-axis: #c3c2b7;
  --viz-text: #6f6960;
  --stage-oi: #86b6ef; --stage-oa: #3987e5; --stage-oad: #1c5cab; --stage-pdp: #0d366b; --stage-otras: #bdb8ae;
  --map-0: #f6ecdb; --map-1: #ecc98e; --map-2: #d49a3b; --map-3: #9b5f16; --map-4: #5a320b; --map-none: #ece8e1; --map-border: #fdfdfc;
  --status-good: #0ca30c; --status-warning: #fab219; --status-serious: #ec835a; --status-critical: #d03b3b;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0e0d;
  --surface: #1a1a19;
  --surface-2: #1f1e1c;
  --surface-3: #282623;
  --ink: #f2eee8;
  --ink-2: #c3bcb2;
  --muted: #8f877d;
  --line: #2c2a27;
  --line-2: #3b3834;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
  --brand: #d69a3c;
  --brand-hover: #e3ad55;
  --brand-ink: #e8b865;
  --brand-soft: #2d2415;
  --focus: 0 0 0 3px rgba(214, 154, 60, .35);
  --sidebar-bg: #141110;
  --sidebar-line: rgba(255, 255, 255, .06);
  --ok: #3ccf74;      --ok-bg: #0f2a19;      --ok-line: #1d4a2e;
  --warn: #f2bd4b;    --warn-bg: #2d220c;    --warn-line: #4d3a13;
  --danger: #f0776c;  --danger-bg: #2f1413;  --danger-line: #52211e;
  --info: #7fb2f0;    --info-bg: #102238;    --info-line: #1e3a5f;
  --viz-surface: #1a1a19;
  --viz-1: #3987e5;
  --viz-1-wash: rgba(57, 135, 229, .14);
  --viz-prev: #6d6a64;
  --viz-grid: #2c2c2a;
  --viz-axis: #383835;
  --viz-text: #9b958c;
  --stage-oi: #184f95; --stage-oa: #256abf; --stage-oad: #3987e5; --stage-pdp: #86b6ef; --stage-otras: #57534d;
  --map-0: #f3cf8f; --map-1: #d09335; --map-2: #9e5f18; --map-3: #6b390d; --map-4: #381a06; --map-none: #1f1e1c; --map-border: #2c2a27;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0; }
small { font-size: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
::selection { background: rgba(183, 121, 31, .28); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
.icon.fill { fill: currentColor; stroke: none; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.hide { display: none !important; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ shell */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar-w); display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--sidebar-ink); border-right: 1px solid var(--sidebar-line);
  transition: width .18s ease, transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 12px; height: var(--topbar-h); padding: 0 18px; border-bottom: 1px solid var(--sidebar-line); flex: none; }
.brand img { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; flex: none; }
.brand-name { font-weight: 750; font-size: 15px; letter-spacing: .2px; color: #fff; white-space: nowrap; }
.brand-sub { font-size: 10.5px; color: var(--sidebar-muted); letter-spacing: .4px; white-space: nowrap; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; scrollbar-width: thin; scrollbar-color: #3a2f27 transparent; }
.nav-section { font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--sidebar-muted); padding: 16px 10px 6px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; margin: 1px 0; border-radius: var(--r);
  color: var(--sidebar-ink); font-size: 13.5px; white-space: nowrap; position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #d49a3b; }
.nav-item .icon { color: var(--sidebar-muted); }
.nav-item.active .icon, .nav-item:hover .icon { color: #e3b264; }
.nav-foot { padding: 12px 18px; border-top: 1px solid var(--sidebar-line); font-size: 11px; color: var(--sidebar-muted); flex: none; white-space: nowrap; }
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .18s ease; }

.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; flex: 1; }
.crumbs > * { white-space: nowrap; }
.crumbs > :not(.here):not(.sep) { overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--line-2); }
.crumbs .here { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-trigger {
  display: flex; align-items: center; gap: 10px; width: min(360px, 34vw); height: 36px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); color: var(--muted); cursor: pointer; font: inherit; font-size: 13px;
}
.search-trigger:hover { border-color: var(--line-2); color: var(--ink-2); }
.search-trigger span { flex: 1; text-align: left; }
kbd { font-family: var(--font); font-size: 11px; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; color: var(--ink-2); background: var(--surface); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r); border: 1px solid transparent;
  background: transparent; color: var(--ink-2); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: 12px; flex: none; }
.user-chip b { display: block; font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-chip small { display: block; color: var(--muted); font-size: 11px; line-height: 1.2; }
.mobile-only { display: none; }

.content { width: 100%; max-width: 1520px; margin: 0 auto; padding: 24px 28px 48px; flex: 1; transition: opacity .15s ease; }
.content.loading { opacity: .55; pointer-events: none; }
.footer { text-align: center; color: var(--muted); font-size: 11.5px; padding: 16px; border-top: 1px solid var(--line); }

/* barra de progreso de navegación */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 100; pointer-events: none; }
.progress::before { content: ""; position: absolute; inset: 0; transform-origin: left; transform: scaleX(0); background: var(--brand); opacity: 0; transition: transform .25s ease, opacity .3s ease; }
.progress.on::before { opacity: 1; transform: scaleX(.7); transition: transform 6s cubic-bezier(.1, .7, .1, 1), opacity .1s; }
.progress.done::before { opacity: 0; transform: scaleX(1); transition: transform .2s ease, opacity .35s ease .15s; }

/* barra lateral colapsada */
.sidebar-collapsed .sidebar { width: 68px; }
.sidebar-collapsed .main { margin-left: 68px; }
.sidebar-collapsed .brand-text, .sidebar-collapsed .nav-section, .sidebar-collapsed .nav-item span, .sidebar-collapsed .nav-foot { display: none; }
.sidebar-collapsed .nav-section + .nav-item { margin-top: 12px; }
.sidebar-collapsed .nav-item { justify-content: center; }
.sidebar-collapsed .brand { justify-content: center; padding: 0; }

/* ------------------------------------------------------------------ cabecera de página */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { outline: none; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--brand-ink); margin-bottom: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ tarjetas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid > .card + .card { margin-top: 0; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
:root[data-theme="dark"] .btn.primary { color: #1a1205; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { color: var(--danger); border-color: var(--danger-line); background: var(--surface); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ok { color: var(--ok); border-color: var(--ok-line); }
.btn.ok:hover { background: var(--ok-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; gap: 5px; border-radius: var(--r-sm); }
.btn.icon-only { width: 36px; padding: 0; }
.btn.sm.icon-only { width: 30px; }
.btn .count { font-size: 11px; color: var(--muted); font-weight: 500; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--r) 0 0 var(--r); }
.btn-group .btn:last-child { border-radius: 0 var(--r) var(--r) 0; }
.btn-group .btn + .btn { margin-left: -1px; }

/* control segmentado */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r); background: var(--surface-3); border: 1px solid var(--line); }
.segmented button, .segmented a {
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 12.5px; font-weight: 550; height: 28px; padding: 0 10px;
  border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none !important;
}
.segmented button:hover, .segmented a:hover { color: var(--ink); }
.segmented [aria-pressed="true"], .segmented .on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* menú desplegable */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 220px; padding: 6px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
}
.menu-pop.left { right: auto; left: 0; }
.menu-pop a, .menu-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); border: 0; background: none;
  color: var(--ink); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; text-decoration: none !important;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-3); }
.menu-pop .icon { color: var(--muted); }
.menu-pop .desc { display: block; font-size: 11.5px; color: var(--muted); }
.menu-pop hr { margin: 6px 4px; }
.menu-pop .danger { color: var(--danger); }
.menu-pop form { margin: 0; }

/* ------------------------------------------------------------------ insignias */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); border: 1px solid transparent; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge.outline { background: transparent; border-color: var(--line-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--muted); }
.fam { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; color: var(--ink-2); font-weight: 550; }
.fam::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--stage-otras); flex: none; }
.fam.OI::before { background: var(--stage-oi); }
.fam.OA::before { background: var(--stage-oa); }
.fam.OAD::before { background: var(--stage-oad); }
.fam.PDP::before { background: var(--stage-pdp); }
.sexo { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-size: 12.5px; }
.estado { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 550; }
.estado::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.estado.e1::before { background: var(--status-good); }
.estado.e0::before { background: var(--status-critical); }
.estado.e2::before { background: var(--line-2); border: 1px solid var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: 12px; font-weight: 550; }
.chip a { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: inherit; }
.chip a:hover { background: rgba(0, 0, 0, .08); text-decoration: none; }

/* ------------------------------------------------------------------ alertas y toasts */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); margin-bottom: 16px; font-size: 13.5px; }
.flash .icon { margin-top: 1px; }
.flash.success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.flash.error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.flash.warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.flash.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.flash .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; padding: 0; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(400px, calc(100vw - 40px)); }
.toast { box-shadow: var(--shadow-pop); margin: 0; animation: toast-in .22s ease; }
.toast.out { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }
.callout.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.callout.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }

/* ------------------------------------------------------------------ tablas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); text-align: left; font-size: 11.5px; font-weight: 650;
  letter-spacing: .3px; text-transform: uppercase; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr[data-href] { cursor: pointer; }
.table .strong { font-weight: 600; color: var(--ink); }
.table .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.act { text-align: right; white-space: nowrap; width: 1%; }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--ink); text-decoration: none; }
.table th a.on { color: var(--ink); }
.table.compact td { padding: 7px 12px; }
.table.compact th { padding: 8px 12px; }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; }
.cell-bar { position: relative; display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.cell-bar i { display: block; height: 6px; border-radius: 0 3px 3px 0; background: var(--viz-1); min-width: 2px; }
.cell-bar .track { width: 90px; background: var(--surface-3); border-radius: 3px; height: 6px; display: flex; }

/* paginación */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; align-items: center; }
.pager .pages a, .pager .pages span {
  min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: var(--r-sm); color: var(--ink-2);
  font-size: 13px; font-variant-numeric: tabular-nums; text-decoration: none !important;
}
.pager .pages a:hover { background: var(--surface-3); color: var(--ink); }
.pager .pages .on { background: var(--ink); color: var(--surface); font-weight: 650; }
.pager .pages .dis { opacity: .4; }
.pager select { height: 30px; }

/* estados vacíos */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; color: var(--line-2); margin-bottom: 8px; }
.empty h3 { color: var(--ink); margin-bottom: 4px; }
.empty p { max-width: 420px; margin: 0 auto 12px; font-size: 13px; }

/* ------------------------------------------------------------------ edición Desarrollador */
.dev-barra { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 16px; font-size: 12px; letter-spacing: .3px;
  background: repeating-linear-gradient(135deg, #2b2116, #2b2116 12px, #33271a 12px, #33271a 24px); color: #f5d9a8; }
.dev-barra > span { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; }
.dev-barra .btn { background: rgba(255, 255, 255, .08); color: #f5d9a8; border-color: rgba(245, 217, 168, .35); }
.dev-docs { display: none; position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 40; overflow: auto;
  padding: 16px 18px 24px; background: var(--surface); border-left: 1px solid var(--line-2); box-shadow: var(--shadow-pop); font-size: 13px; line-height: 1.5; }
html.docs-abiertas .dev-docs { display: block; }
.dev-docs-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.dev-docs-head b { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.dev-docs-head .icon-btn { margin-left: auto; }
.dev-docs-head .mono { font-size: 11px; }
.dev-docs h4 { margin: 14px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.dev-docs ul, .dev-docs ol { margin: 0; padding-left: 18px; }
.dev-docs li + li { margin-top: 4px; }
.dev-docs .badge { margin: 0 2px 4px 0; }
.dev-metricas { margin-top: 24px; padding-top: 8px; border-top: 1px dashed var(--line-2); font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.atajos kbd, .menu-pop kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); }

/* ------------------------------------------------------------------ calibración de impresión */
.cal-herramientas { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.cal-escenario { overflow: auto; max-height: 70vh; padding: 16px; border-radius: var(--r); background: var(--surface-3);
  background-image: radial-gradient(var(--line-2) 1px, transparent 1px); background-size: 14px 14px; }
.cal-zoom { position: relative; }
.cal-papel { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .22); user-select: none; touch-action: none; }
.cal-papel .cert-pagina { position: absolute; left: 0; top: 0; background: transparent; }
.cal-fondo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.cal-grilla { position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(to right, rgba(183, 121, 31, .28) 1px, transparent 1px), linear-gradient(to bottom, rgba(183, 121, 31, .28) 1px, transparent 1px),
                    linear-gradient(to right, rgba(183, 121, 31, .12) 1px, transparent 1px), linear-gradient(to bottom, rgba(183, 121, 31, .12) 1px, transparent 1px);
  background-size: 10mm 10mm, 10mm 10mm, 5mm 5mm, 5mm 5mm; }
.cal-papel .cal-campo { outline: 1px dashed rgba(200, 60, 60, .55); outline-offset: 1px; cursor: move; min-width: 3mm; min-height: 2mm; }
.cal-papel .cal-campo:hover { outline-color: rgba(200, 60, 60, .9); background: rgba(255, 236, 200, .35); }
.cal-papel .cal-campo.sel { outline: 2px solid var(--brand); background: rgba(183, 121, 31, .12); z-index: 2; }
.cal-papel .cal-campo.oculto { opacity: .35; outline-style: dotted; }
.cal-papel .cal-campo.fila { cursor: default; opacity: .7; }
.cal-lista { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.cal-lista li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.cal-lista li.sel { background: var(--brand-soft); }
.cal-lista .cal-nombre { flex: 1; text-align: left; background: none; border: 0; padding: 4px 0; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; }
#calImpresion .cert-pagina { margin: 0; }
#calImpresion .cal-cruz { position: absolute; width: 8mm; height: 8mm; transform: translate(-50%, -50%); }
#calImpresion .cal-cruz::before, #calImpresion .cal-cruz::after { content: ""; position: absolute; background: #000; }
#calImpresion .cal-cruz::before { left: 0; right: 0; top: 50%; height: .25mm; transform: translateY(-50%); }
#calImpresion .cal-cruz::after { top: 0; bottom: 0; left: 50%; width: .25mm; transform: translateX(-50%); }
#calImpresion .cal-nota { position: absolute; left: 16mm; top: 6mm; font: 7pt Arial, sans-serif; color: #555; }

/* ------------------------------------------------------------------ formularios */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 18px; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-9 { grid-column: span 9; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.req { color: var(--danger); font-weight: 700; }
.help { font-size: 12px; color: var(--muted); }
.help.err { color: var(--danger); }
.help.ok { color: var(--ok); }
.input, .select, .textarea, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 14px; transition: border-color .12s, box-shadow .12s;
}
.field textarea, .textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.field select, .select { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23857e75' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }
.input:focus, .select:focus, .textarea:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.field input[readonly], .input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.field input:disabled, .field select:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.field input.invalid, .field select.invalid { border-color: var(--danger); }
.input-group { display: flex; align-items: stretch; }
.input-group > :first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > :last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.input-group .addon { display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2); font-weight: 650; border-radius: var(--r) 0 0 var(--r); font-size: 13px; white-space: nowrap; }
.input-group .addon + input { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
/* valor que asigna el sistema (N.º de registro, prenombre, fundo único): se ve, no se edita */
.auto-value { min-height: 38px; display: flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--surface-2); color: var(--ink); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.auto-value.empty { color: var(--muted); font-weight: 400; }
.auto-value .tag { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
/* escala de calificación 1–5 (evaluación de campo) */
.rating { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.rating label { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 1px solid var(--line-2); border-radius: var(--r); cursor: pointer; background: var(--surface); text-align: center; transition: border-color .12s, background .12s; }
.rating label b { font-size: 16px; }
.rating label span { font-size: 11px; color: var(--muted); line-height: 1.2; }
.rating input { position: absolute; opacity: 0; pointer-events: none; }
.rating label:hover { border-color: var(--brand); }
.rating input:focus-visible + b { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.rating label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.rating label:has(input:checked) span { color: var(--brand-ink); }
.dictamen { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dictamen label { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--r); cursor: pointer; background: var(--surface); }
.dictamen label small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }
.dictamen label:has(input[value=aprobado]:checked) { border-color: var(--ok); background: var(--ok-bg); }
.dictamen label:has(input[value=observado]:checked) { border-color: var(--warn-line); background: var(--warn-bg); }
@media (max-width: 560px) { .rating { grid-template-columns: repeat(5, minmax(44px, 1fr)); } .rating label span { display: none; } .dictamen { grid-template-columns: 1fr; } }
.fieldset { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; background: var(--surface); }
.fieldset + .fieldset { margin-top: 16px; }
.fieldset-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.fieldset-head .step { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; background: var(--brand-soft); color: var(--brand-ink); flex: none; }
.fieldset-head h2 { font-size: 15px; }
.fieldset-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding-top: 16px; }
.form-actions.sticky { position: sticky; bottom: 0; z-index: 5; margin: 16px -28px -48px; padding: 12px 28px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 16px rgba(40, 28, 16, .06); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.repeat-row { display: grid; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.repeat-row + .repeat-row { margin-top: 10px; }
.fundo-row { grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)) auto; }
.rep-row { grid-template-columns: repeat(3, minmax(0, 1fr)) 140px auto; }
.num-tag { font-size: 11px; font-weight: 700; color: var(--muted); }

/* autocompletar */
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; max-height: 320px; overflow-y: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop);
}
.ac-opt { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--r-sm); border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; }
.ac-opt b { font-weight: 600; font-size: 13.5px; }
.ac-opt small { display: block; color: var(--muted); font-size: 12px; }
.ac-opt.on, .ac-opt:hover { background: var(--surface-3); }
.ac-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.ac-selected { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--ok-line); background: var(--ok-bg); border-radius: var(--r); color: var(--ink); font-size: 13.5px; margin-top: 6px; }
.ac-selected .icon { color: var(--ok); }
.ac-selected small { color: var(--muted); display: block; }

/* diálogo */
dialog { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 14, 9, .5); backdrop-filter: blur(2px); }
.dialog-head { padding: 18px 20px 6px; }
.dialog-head p { color: var(--muted); margin-top: 4px; font-size: 13px; }
.dialog-body { padding: 10px 20px; }
.dialog-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* paleta de comandos */
.palette { width: min(640px, calc(100vw - 32px)); margin-top: 10vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.palette-input input { flex: 1; border: 0; outline: none; background: none; font: inherit; font-size: 16px; color: var(--ink); }
.palette-results { max-height: 60vh; overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r); color: var(--ink); text-decoration: none !important; }
.palette-item .icon { color: var(--muted); }
.palette-item b { font-weight: 600; font-size: 13.5px; }
.palette-item small { display: block; color: var(--muted); font-size: 12px; }
.palette-item.on { background: var(--surface-3); }
.palette-item.baja b { color: var(--muted); }
.palette-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ filtros */
.filters { display: flex; flex-direction: column; gap: 12px; }
.filters-main { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters-main .grow { flex: 1 1 260px; }
.filters-more { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.search-input { position: relative; }
.search-input .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input input { padding-left: 36px !important; }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; border: 0; background: none; font: inherit; font-size: 13.5px;
  color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; text-decoration: none !important;
}
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs .on, .tabs [aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }
.tabs .count { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tabs .on .count { background: var(--brand-soft); color: var(--brand-ink); }
.tab-panel[hidden] { display: none; }

/* ------------------------------------------------------------------ KPIs y panel */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; box-shadow: var(--shadow); position: relative; }
.kpi .k-label { font-size: 12.5px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; color: var(--ink); }
.kpi.hero .k-value { font-size: 34px; }
.kpi .k-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-height: 20px; flex-wrap: wrap; }
.kpi .spark { height: 28px; margin-top: 2px; }
.kpi a.k-link { position: absolute; inset: 0; border-radius: inherit; }
.kpi a.k-link:hover { background: rgba(183, 121, 31, .04); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--info-bg); overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; background: var(--viz-1); border-radius: 3px; }
.skeleton { display: inline-block; height: 1em; width: 60%; border-radius: 4px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.widget { position: relative; transition: opacity .2s; }
.widget.refreshing { opacity: .55; }
.widget-error { color: var(--danger); font-size: 13px; padding: 16px; }
.dash-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-filters .select { height: 34px; width: auto; min-width: 160px; font-size: 13.5px; }
.dash-meta { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { width: 16px; height: 2px; border-radius: 1px; }

/* gráficos SVG */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; border-radius: 4px; }
.chart .grid-line { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-line { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart text { fill: var(--viz-text); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .hover-col { fill: var(--ink); opacity: 0; }
.chart .hover-col.on { opacity: .04; }
.chart .crosshair { stroke: var(--viz-axis); stroke-width: 1; }
.viz-tip {
  position: absolute; z-index: 20; pointer-events: none; min-width: 150px; padding: 8px 10px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-pop); font-size: 12.5px; color: var(--ink); transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap;
}
.viz-tip .t-title { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.viz-tip .t-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.viz-tip .t-row b { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 44px; }
.viz-tip .t-row span { color: var(--muted); }
.viz-tip .t-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.viz-tip .t-key.box { height: 10px; width: 10px; border-radius: 3px; }
.viz-table { margin-top: 12px; }

/* barras horizontales (rankings) */
.hbars { display: flex; flex-direction: column; gap: 2px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 7px 8px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none !important; align-items: center; }
a.hbar:hover { background: var(--surface-2); }
.hbar .h-label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hbar .h-label small { color: var(--muted); font-size: 12px; margin-left: 4px; }
.hbar .h-value { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.hbar .h-track { grid-column: 1 / -1; height: 6px; border-radius: 0 3px 3px 0; background: transparent; }
.hbar .h-track i { display: block; height: 6px; border-radius: 0 3px 3px 0; background: var(--viz-1); min-width: 2px; transition: width .4s ease; }
.hbar .rank { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--surface-3); font-size: 11px; font-weight: 700; color: var(--ink-2); margin-right: 8px; }

/* embudo del programa de mejoramiento */
.stages { display: flex; flex-direction: column; gap: 12px; }
.stage { display: grid; grid-template-columns: 150px minmax(0, 1fr) 90px; gap: 12px; align-items: center; }
.stage .s-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.stage .s-name small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.stage .s-bar { height: 22px; border-radius: 0 4px 4px 0; min-width: 3px; transition: width .5s ease; }
.stage .s-val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.stage .s-val small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.stage.OI .s-bar { background: var(--stage-oi); }
.stage.OA .s-bar { background: var(--stage-oa); }
.stage.OAD .s-bar { background: var(--stage-oad); }
.stage.PDP .s-bar { background: var(--stage-pdp); }
.stage-arrow { font-size: 11.5px; color: var(--muted); padding-left: 162px; margin: -6px 0; display: flex; align-items: center; gap: 4px; }

/* mapa */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.map-svg { position: relative; min-height: 320px; }
.map-svg canvas { display: block; margin: 0 auto; cursor: pointer; }
.map-scale { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.map-scale .bar { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--map-0), var(--map-1), var(--map-2), var(--map-3), var(--map-4)); }
.map-detail { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }

/* línea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: start; }
.timeline li:last-child { border-bottom: 0; }
.timeline .t-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.timeline .t-ico.registro { background: var(--info-bg); color: var(--info); }
.timeline .t-ico.transferencia { background: var(--brand-soft); color: var(--brand-ink); }
.timeline .t-ico.estado { background: var(--warn-bg); color: var(--warn); }
.timeline .t-ico.socio { background: var(--ok-bg); color: var(--ok); }
.timeline a { color: var(--ink); font-weight: 550; font-size: 13.5px; }
.timeline small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline time { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* checks de calidad */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks .c-ico.good { color: var(--status-good); }
.checks .c-ico.warning { color: var(--warn); }
.checks .c-ico.critical { color: var(--status-critical); }
.checks b { font-weight: 600; font-size: 13.5px; display: block; }
.checks small { color: var(--muted); font-size: 12px; }
.checks .c-val { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.checks .c-val a { font-weight: 500; font-size: 12px; display: block; }

/* ------------------------------------------------------------------ ficha / perfil */
.profile-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.profile-mark { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-size: 18px; font-weight: 750; flex: none; }
.profile-mark.stage-OI { background: var(--stage-oi); color: #0d2a4d; }
.profile-mark.stage-OA { background: var(--stage-oa); color: #fff; }
.profile-mark.stage-OAD { background: var(--stage-oad); color: #fff; }
.profile-mark.stage-PDP { background: var(--stage-pdp); color: #fff; }
:root[data-theme="dark"] .profile-mark.stage-PDP { color: #0d2a4d; }
.profile-title { flex: 1; min-width: 260px; }
.profile-title h1 { font-size: 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-title .reg { font-family: var(--mono); font-size: 15px; color: var(--muted); font-weight: 500; }
.profile-meta { display: flex; gap: 8px 16px; flex-wrap: wrap; margin-top: 8px; color: var(--ink-2); font-size: 13px; align-items: center; }
.profile-meta .sep { width: 1px; height: 14px; background: var(--line-2); }
.facts { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 0; font-size: 13.5px; }
.facts dt, .facts dd { padding: 9px 0; border-bottom: 1px solid var(--line); margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.facts dt:last-of-type, .facts dd:last-of-type { border-bottom: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; margin-bottom: 16px; }
.mini-stats > div { padding: 12px 16px; border-right: 1px solid var(--line); }
.mini-stats > div:last-child { border-right: 0; }
.mini-stats b { display: block; font-size: 20px; font-weight: 650; }
.mini-stats span { font-size: 12px; color: var(--muted); }
.stackbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface); }
.stackbar i { display: block; height: 100%; }

/* árbol genealógico (llaves) */
.pedigree { display: grid; grid-template-columns: minmax(150px, .9fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(170px, 1.1fr); gap: 0 22px; min-width: 820px; }
.ped-col { display: flex; flex-direction: column; justify-content: space-around; gap: 6px; }
.ped-node {
  position: relative; display: block; padding: 7px 10px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface);
  font-size: 12.5px; line-height: 1.35; color: var(--ink); text-decoration: none !important; min-height: 44px;
}
a.ped-node:hover { border-color: var(--brand); box-shadow: var(--focus); }
.ped-node .p-role { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.ped-node .p-reg { font-family: var(--mono); font-size: 11.5px; color: var(--brand-ink); }
.ped-node b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ped-node.empty { border-style: dashed; color: var(--muted); background: transparent; display: flex; align-items: center; }
.ped-node.self { border-color: var(--brand); background: var(--brand-soft); }
.ped-node.M { border-left: 3px solid var(--viz-1); }
.ped-node.H { border-left: 3px solid #d55181; }
.ped-col:not(:first-child) .ped-node::before { content: ""; position: absolute; left: -12px; top: 50%; width: 12px; border-top: 1px solid var(--line-2); }
.ped-g4 .ped-node { min-height: 34px; padding: 4px 8px; }
.ped-g4 .ped-node b { font-size: 11.5px; }
.completeness { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.completeness .meter { width: 120px; margin: 0; }

/* tarjetas de selección (tipo de registro, formatos) */
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.choice {
  display: flex; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink);
  text-decoration: none !important; transition: border-color .12s, box-shadow .12s; align-items: flex-start;
}
.choice:hover { border-color: var(--brand); box-shadow: var(--focus); }
.choice .c-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); flex: none; }
.choice b { display: block; font-size: 14.5px; margin-bottom: 2px; }
.choice p { font-size: 12.5px; color: var(--muted); }
.choice.sel { border-color: var(--brand); background: var(--brand-soft); }
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.steps a { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); text-decoration: none !important; background: var(--surface); }
.steps a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .steps a.on { color: #1a1205; }
.side-panel { position: sticky; top: calc(var(--topbar-h) + 16px); }
.animal-card { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.animal-card .profile-mark { width: 40px; height: 40px; font-size: 13px; border-radius: 10px; }
.animal-card b { display: block; }
.animal-card small { color: var(--muted); display: block; }
.dup-list { list-style: none; margin: 8px 0 0; padding: 0; }
.dup-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--warn-line); }

/* ------------------------------------------------------------------ login */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); background: var(--surface); }
.login-art { position: relative; background: #1e1712; color: #f2e8dc; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.login-art::after { content: ""; position: absolute; right: -140px; bottom: -140px; width: 420px; height: 420px; border-radius: 50%; border: 1px solid rgba(212, 154, 59, .22); box-shadow: 0 0 0 60px rgba(212, 154, 59, .04), 0 0 0 120px rgba(212, 154, 59, .03); }
.login-art h2 { font-size: 30px; line-height: 1.2; font-weight: 700; max-width: 460px; color: #fff; }
.login-art p { color: #cbbcab; max-width: 460px; margin-top: 12px; font-size: 15px; line-height: 1.6; }
.login-stats { display: flex; gap: 32px; flex-wrap: wrap; position: relative; z-index: 1; }
.login-stats b { display: block; font-size: 24px; color: #e3b264; font-weight: 700; }
.login-stats span { font-size: 12.5px; color: #b3a393; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--bg); }
.login-card { width: min(380px, 100%); }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card .btn { height: 42px; font-size: 14.5px; }

/* ------------------------------------------------------------------ responsivo */
@media (max-width: 1360px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .g-main, .g-side, .map-wrap { grid-template-columns: minmax(0, 1fr); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-more { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side-panel { position: static; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: 272px; box-shadow: var(--shadow-pop); }
  .sidebar-open .sidebar { transform: none; }
  .main, .sidebar-collapsed .main { margin-left: 0; }
  .sidebar-collapsed .sidebar { width: 272px; }
  .sidebar-collapsed .brand-text, .sidebar-collapsed .nav-section, .sidebar-collapsed .nav-item span, .sidebar-collapsed .nav-foot { display: revert; }
  .mobile-only { display: inline-grid; }
  .desktop-only { display: none !important; }
  .topbar { padding: 0 12px; }
  .content { padding: 16px 14px 40px; }
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .user-chip div { display: none; }
  .g-2, .g-3, .g-4 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-more { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid > * { grid-column: span 12 !important; }
  .fundo-row, .rep-row { grid-template-columns: minmax(0, 1fr); }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-stats > div:nth-child(2) { border-right: 0; }
  .mini-stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stage { grid-template-columns: 110px minmax(0, 1fr) 76px; }
  .stage-arrow { padding-left: 122px; }
  .login-page { grid-template-columns: minmax(0, 1fr); }
  .login-art { display: none; }
  .facts { grid-template-columns: 130px minmax(0, 1fr); }
  .form-actions.sticky { margin: 16px -14px -40px; padding: 12px 14px; }
  .choice-grid { grid-template-columns: minmax(0, 1fr); }
  .table th, .table td { padding: 9px 10px; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .filters-more { grid-template-columns: minmax(0, 1fr); }
  .page-head .actions { width: 100%; }
}
.scrim { position: fixed; inset: 0; background: rgba(20, 14, 9, .45); z-index: 35; }

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

/* ------------------------------------------------------------------ impresión de pantallas normales */
@media print {
  .sidebar, .topbar, .footer, .no-print, .toasts, .actions, .form-actions { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
