/* Onfarmanet SAS · FarmaGuard — Design System: COMPONENTS («Estación clínica de sello», v4).
 * Depende de tokens.css + base.css. Cargar al final. CSP-safe (sin estilos inline en templates).
 * Grilla 4px estricta en padding/margin/gap; radios 8/999 de chrome (+4px en extremos de dato);
 * una sola sombra de reposo; versalitas SOLO en rótulos (eyebrow, KPI, columna, viz__title). */

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  font-size: var(--fs-base); line-height: var(--lh-body); font-weight: 600; white-space: nowrap;
  min-height: 36px; padding: var(--s-2) var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface-raised); color: var(--ink);
  cursor: pointer; text-decoration: none;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.btn:hover { text-decoration: none; border-color: var(--ink-subtle); background: var(--surface); color: var(--ink); }
.btn:active { background: var(--surface-sunken); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn--primary:active { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn--secondary { background: var(--surface-raised); color: var(--ink); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-tint); }
.btn--secondary:active { background: var(--brand-soft); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-muted); }
.btn--ghost:hover { background: var(--surface-sunken); border-color: transparent; color: var(--ink); }
.btn--ghost:active { background: var(--border); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-text); border-color: var(--danger-text); color: #fff; }
.btn--danger:active { background: var(--danger-deep); }
/* Variante contenida para el disparador de la ficha: el rojo sólido queda reservado para el botón
   de confirmación del interstitial (donde la decisión realmente se toma). */
.btn--outline-danger { background: transparent; color: var(--danger); border-color: currentColor; }
.btn--outline-danger:hover { background: var(--danger-soft); color: var(--danger-text); border-color: currentColor; }
.btn--block { display: flex; width: 100%; }
.btn--sm { min-height: 28px; padding: var(--s-1) var(--s-3); font-size: var(--fs-sm); line-height: 1.2308; }
.btn--lg { min-height: 40px; padding: var(--s-2) var(--s-5); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--surface-sunken); color: var(--ink-subtle); border-color: var(--border); cursor: not-allowed; }

/* ── Tarjetas ── */
.card {
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s-4); box-shadow: var(--shadow-xs);
}
.card--pad-lg { padding: var(--s-6); }
.card__title { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); line-height: 1.2308; font-weight: 600; letter-spacing: -0.01em; margin-bottom: var(--s-2); }
.card__title .icon { color: var(--brand); }
/* 0-2-0 A PROPÓSITO: dentro de .stack/.stack-lg (0-1-0) las cards contiguas y el grid
   pegado a su section-head se ABRAZAN (el espaciado lo dan section-head/card-grid). */
.card + .card { margin-top: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(264px, 1fr)); gap: var(--s-4); }

/* ── Encabezado de sección + KPI ── */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); margin: var(--s-2) 0 0; }
.section-head h2, .section-head h3 { font-size: var(--fs-sm); line-height: 1.2308; letter-spacing: -0.01em; }
.section-head + .kpi-grid, .section-head + .card-grid { margin-top: 0; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s-4); }
.kpi { display: flex; align-items: flex-start; gap: var(--s-3); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); box-shadow: var(--shadow-xs); }
.kpi__text { display: flex; flex-direction: column; min-width: 0; gap: var(--s-1); flex: 1; }
/* Numeral display: 700 con tracking −0.03em (la firma tipográfica del sello). El rótulo va
   ARRIBA en versalitas 11/16 (patrón label-arriba, decidido por el dueño). */
.kpi__label { order: -1; font-size: var(--fs-2xs); line-height: 1.4545; font-weight: 500; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--ink-subtle); }
.kpi__value { font-size: var(--fs-2xl); line-height: 1.25; font-weight: 700; letter-spacing: var(--tracking-num); color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi__hint { font-size: var(--fs-xs); line-height: 1.3333; color: var(--ink-muted); }
.kpi--vacio .kpi__value { color: var(--ink-subtle); font-weight: 400; }
.kpi--danger .kpi__value { color: var(--danger-text); }
.kpi--link { text-decoration: none; color: inherit; transition: border-color var(--ease), background var(--ease); }
.kpi--link:hover { border-color: var(--border-strong); background: var(--surface); }
.kpi--link:active { background: var(--surface-sunken); }
.kpi__chev { margin-left: auto; align-self: center; color: var(--ink-subtle); flex: none; transition: color var(--ease), transform var(--ease); }
.kpi--link:hover .kpi__chev { color: var(--brand-strong); transform: translateX(2px); }
/* 6 KPIs (Actividad): 3+3, nunca 4+2 con dos huérfanos (viuda de layout). */
.kpi-grid:has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, 1fr); }

/* ── Auth (login/2FA): tarjeta limpia sobre papel; el fondo ya es la identidad ── */
.card--auth { padding: var(--s-6); }

/* ── Formularios ── */
.field { display: block; }
.field + .field { margin-top: var(--s-4); }
.label { display: block; font-size: var(--fs-2xs); line-height: 1.4545; font-weight: 500; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--ink-subtle); margin-bottom: var(--s-1); }
.input, .select, .textarea {
  width: 100%; min-height: 36px; background: var(--surface-raised); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3); font-size: var(--fs-base); line-height: var(--lh-body);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.input::placeholder { color: var(--ink-subtle); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-subtle); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring-glow); }
.textarea { min-height: 80px; resize: vertical; }
.input--code { font-family: var(--font-mono); font-size: var(--fs-xl); line-height: var(--lh-tight); letter-spacing: 0.4em; text-align: center; padding-left: var(--s-3); }
.field__hint { font-size: var(--fs-xs); line-height: 1.3333; color: var(--ink-muted); margin-top: var(--s-1); }
.field__hint--error { color: var(--danger-text); font-weight: 500; }
.checkline { display: flex; align-items: center; gap: var(--s-2); min-height: 24px; font-size: var(--fs-base); color: var(--ink); cursor: pointer; }
.checkline input[type="checkbox"], .checkline input[type="radio"] { width: 24px; height: 24px; margin: 0; accent-color: var(--brand); flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; margin-top: var(--s-4); }
.input-group { display: flex; gap: var(--s-2); align-items: stretch; }
.input-group .input { flex: 1; }
/* Defensa para markup de allauth/Django sin clase */
input[type="text"]:not(.input), input[type="email"]:not(.input),
input[type="password"]:not(.input), input[type="search"]:not(.input) {
  width: 100%; min-height: 36px; background: var(--surface-raised); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3); font-size: var(--fs-base); line-height: var(--lh-body);
}
input[type="text"]:not(.input):focus, input[type="email"]:not(.input):focus,
input[type="password"]:not(.input):focus, input[type="search"]:not(.input):focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring-glow);
}
button:not(.btn):not(.topbar__link), input[type="submit"]:not(.btn), input[type="reset"]:not(.btn) {
  display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-base); line-height: var(--lh-body); font-weight: 600;
  min-height: 36px; padding: var(--s-2) var(--s-4); border-radius: var(--r-md); cursor: pointer;
  background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border-strong);
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}
button:not(.btn):not(.topbar__link):hover, input[type="submit"]:not(.btn):hover, input[type="reset"]:not(.btn):hover {
  border-color: var(--brand); color: var(--brand-strong); background: var(--brand-tint);
}

/* ── Tablas ── */
.table-wrap {
  overflow-x: auto; position: relative; border: 1px solid var(--border); border-radius: var(--r-md);
  background:
    linear-gradient(90deg, var(--surface-raised) 40%, rgba(255, 255, 255, 0)) left / 36px 100%,
    linear-gradient(270deg, var(--surface-raised) 40%, rgba(255, 255, 255, 0)) right / 36px 100%,
    radial-gradient(farthest-side at 0 50%, rgba(16, 32, 28, 0.16), transparent) left / 12px 100%,
    radial-gradient(farthest-side at 100% 50%, rgba(16, 32, 28, 0.16), transparent) right / 12px 100%,
    var(--surface-raised);
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
  box-shadow: var(--shadow-xs);
}
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); line-height: var(--lh-body); font-variant-numeric: tabular-nums; }
.table th, .table td { padding: var(--s-3) var(--s-4); text-align: left; vertical-align: top; }
.table td.fecha { white-space: nowrap; font-size: var(--fs-sm); line-height: 1.5385; color: var(--ink-muted); }
.table thead th {
  font-size: var(--fs-2xs); line-height: 1.4545; font-weight: 500; text-transform: uppercase; letter-spacing: var(--tracking-wide);
  color: var(--ink-subtle); background: transparent; border-bottom: 1px solid var(--border-strong); padding-top: var(--s-2); padding-bottom: var(--s-2);
}
.table tbody tr + tr td { border-top: 1px solid var(--border); }
.table tbody tr { transition: background var(--ease); }
.table tbody tr:hover td { background: var(--surface); }
.table td.num, .table th.num { text-align: right; }
.table td { color: var(--ink); }
.table--compact th, .table--compact td { padding: var(--s-2) var(--s-3); }
.table--defs th, .table--defs td { vertical-align: top; }
.table td.num, .codes > li { font-feature-settings: "zero" 1; }
.table .row--total td { font-weight: 700; border-top: 2px solid var(--border-strong); background: var(--brand-tint); }
.table tbody tr.row--total:hover td { background: var(--brand-tint); }  /* misma clase de bug que cell--alerta (r7) */
/* Celda de ALARMA local (cobertura: EPS/semana sobre el umbral de no resueltos): familia danger
   completa, texto + fondo — en una matriz densa el tinte solo no basta (paridad v1). El override
   de hover es OBLIGATORIO: el hover genérico de fila (0-2-3) le ganaba a la celda (0-2-1) y
   apagaba la alarma justo al inspeccionarla (Codex 2026-08-16 ronda 7 — defecto ya presente
   en v1, corregido aquí de raíz). */
.table td.cell--alerta { color: var(--danger-text); font-weight: 600; background: var(--danger-soft); }
.table tbody tr:hover td.cell--alerta { background: var(--danger-soft); }
/* Espina de severidad (firma estructural del sello): borde izquierdo de 3px en filas de casos.
   SIEMPRE acompaña a un badge textual — jamás es la única codificación. */
/* Espina con DOBLE clase (0-2-0): gana a cualquier componente huésped (tabla, .itx) que
   redeclare el shorthand border-left con una sola clase, sin depender del orden del archivo
   (Codex 2026-08-16 ronda 6: .itx, declarado después, apagaba la espina por cascada). */
.caso { border-left: 3px solid transparent; }
.caso.caso--critical { border-left-color: var(--danger); }
.caso.caso--high { border-left-color: var(--danger-line); }
.caso.caso--moderate { border-left-color: var(--warning); }
.caso.caso--none { border-left-color: transparent; }

/* ── Badges de severidad (siempre etiqueta + color, nunca color solo) ── */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  font-size: var(--fs-xs); line-height: 1.3333; font-weight: 600;
  min-height: 24px; padding: 0 var(--s-3); border-radius: var(--r-pill);
  border: 1px solid transparent; white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; stroke-width: 2; }
.badge--critical { background: var(--danger); color: #fff; }
.badge--high { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-line); }
.badge--moderate { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-line); }
.badge--low { background: var(--caution-soft); color: var(--caution-text); border-color: var(--caution-line); }
.badge--none { background: var(--success-soft); color: var(--success-text); border-color: var(--success-line); }
.badge--neutral { background: var(--surface-sunken); color: var(--ink-muted); border-color: var(--border-strong); }
/* Estado administrativo BORRADOR: borde discontinuo (metáfora de boceto) — distinto de neutral
   sin robarle color a la severidad (§6b crítica 2026-07-30: borrador y publicada eran idénticos;
   el rediseño v4 lo había vuelto a igualar — recuperado 2026-08-16). */
.badge--borrador { background: transparent; color: var(--ink-muted); border: 1px dashed var(--border-strong); }

/* ── Callouts ── */
.callout {
  display: flex; gap: var(--s-3); align-items: flex-start;
  border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm); line-height: 1.5385; color: var(--ink-muted); background: var(--surface-raised);
}
.callout > .icon { flex: none; margin-top: 2px; }
.callout strong, .callout b { color: var(--ink); }
/* Variantes semánticas: fondo suave + borde de la familia + espina de 4px en el color fuerte
   (patrón v1 conservado en v4: la prominencia del estado no depende solo del tinte). */
.callout--info { background: var(--info-soft); color: var(--ink-muted); border-color: var(--info-line); border-left: 4px solid var(--info); }
.callout--info > .icon { color: var(--info); }
.callout--success { background: var(--success-soft); color: var(--success-text); border-color: var(--success-line); border-left: 4px solid var(--success); }
.callout--success > .icon { color: var(--success); }
.callout--warning { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-line); border-left: 4px solid var(--warning); }
.callout--warning > .icon { color: var(--warning); }
.callout--warning strong, .callout--warning b { color: var(--warning-text); }
.callout--danger, .callout--error { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-line); border-left: 4px solid var(--danger); }
.callout--danger > .icon, .callout--error > .icon { color: var(--danger); }
.callout--danger strong, .callout--danger b,
.callout--error strong, .callout--error b { color: var(--danger-text); }
.callout--debug { background: var(--surface-sunken); }
.callout__title { display: inline; font-weight: 600; font-size: inherit; color: var(--ink); }
.callout__body { min-width: 0; }
/* Callout ACCIONABLE (§6b.1: la tarea arriba del fold, como enlace completo con chevron). */
.callout--accion { text-decoration: none; align-items: center; transition: border-color var(--ease); }
/* hover: la espina y el texto se intensifican en su familia (warning: es la tarea pendiente) —
   nunca un gris que apague el estado (paridad v1). */
.callout--accion:hover { border-left-color: var(--warning-text); color: var(--warning-text); }
.callout--accion > .icon:last-child { margin-left: auto; }

/* ── Danger zone (confirmar exclusión de alerta clínica / publicar) ── */
.danger-zone { border: 1px solid var(--danger-line); border-left: 4px solid var(--danger); border-radius: var(--r-md); background: var(--danger-soft); padding: var(--s-4); box-shadow: var(--shadow-xs); }
.danger-zone h1, .danger-zone h2 { color: var(--danger-text); }
.danger-zone p { color: var(--ink); }

/* ── Listas de contenido ── */
.list { list-style: none; padding: 0; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-xs); }
.list > li { border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: none; }
.list-link { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); transition: background var(--ease); }
.list-link:hover { background: var(--surface); }
.list-link:active { background: var(--surface-sunken); }
/* .name crece (flex:1) para que meta+chevron queden como columna derecha ESTABLE: con el
   space-between heredado y 3 hijos, «N presentaciones» flotaba a una x distinta por fila
   según el ancho del nombre (defecto latente desde v1, cazado 2026-08-18). */
.list-link .name { display: inline-flex; align-items: center; gap: var(--s-3); flex: 1; font-weight: 600; color: var(--ink); min-width: 0; }
.list-link .name > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list-link .name .icon { color: var(--brand); }
.list-link:hover .name { color: var(--brand-strong); }
.list-link .meta { color: var(--ink-muted); font-size: var(--fs-sm); line-height: 1.5385; white-space: nowrap; font-variant-numeric: tabular-nums; }
.taglist { display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; padding: 0; }
.taglist > li { font-size: var(--fs-2xs); line-height: 1.4545; font-weight: 500; letter-spacing: 0.02em; background: var(--surface-sunken); min-height: 20px; display: inline-flex; align-items: center; padding: 0 var(--s-2); border-radius: var(--r-pill); color: var(--ink-muted); }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-2); list-style: none; padding: 0; }
.codes > li { font-family: var(--font-mono); font-size: var(--fs-base); line-height: var(--lh-body); text-align: center; background: var(--surface-sunken); border-radius: var(--r-xs); padding: var(--s-2) var(--s-3); letter-spacing: 0.1em; color: var(--ink); overflow-wrap: anywhere; }

/* ── Estado vacío: sello-escudo + título + siguiente paso ── */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-1); text-align: center; color: var(--ink-muted); font-size: var(--fs-sm); line-height: 1.5385; padding: var(--s-5) var(--s-4); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); }
.empty .icon { color: var(--brand); }
.empty__icon { width: 40px; height: 40px; border-radius: var(--r-pill); display: grid; place-items: center; background: var(--surface-raised); border: 1.5px solid var(--ink-subtle); margin-bottom: var(--s-1); }
.empty__title { font-weight: 600; color: var(--ink); font-size: var(--fs-base); line-height: var(--lh-body); }
.empty--inline { padding: var(--s-4); border: none; background: none; }

/* ── Resumen de severidad (cabecera de interacciones) ── */
.sev-summary { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-xs); }
.sev-summary__item { display: inline-flex; align-items: center; gap: var(--s-2); }
.sev-summary__n { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); font-size: var(--fs-base); line-height: var(--lh-body); }

/* ── Interacción (kb_detalle) ── */
.itx { border: 1px solid var(--border); border-left: 3px solid transparent; border-radius: var(--r-md); padding: var(--s-4); background: var(--surface-raised); box-shadow: var(--shadow-xs); }
.itx + .itx { margin-top: var(--s-3); }
.itx__head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-2); }
.itx__title { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-base); line-height: var(--lh-body); font-weight: 600; }
.itx__title .icon { color: var(--ink-subtle); }
.itx__via-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border); }

/* ── Paginación ── */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.pagination .btn { font-weight: 600; }
.pagination .spacer { flex: 1; }

/* ── QR (setup 2FA) ── */
.qr { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); width: max-content; box-shadow: var(--shadow-xs); }

/* ── Mensajes de Django ── */
.messages { list-style: none; padding: 0; display: grid; gap: var(--s-3); }

/* ── Visualización de datos (SVG server-rendered, CSP-safe) — papel milimetrado bajo el chart ── */
.viz { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); box-shadow: var(--shadow-xs); }
.viz__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.viz__title { font-size: var(--fs-sm); line-height: 1.2308; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; text-transform: none; }
.viz__total { font-size: var(--fs-xs); line-height: 1.3333; color: var(--ink-subtle); font-variant-numeric: tabular-nums; }
.viz__note { font-size: var(--fs-xs); line-height: 1.3333; color: var(--ink-subtle); }
.chart-scroll { overflow-x: auto; background-color: var(--surface-raised); background-image: radial-gradient(circle, var(--border-strong) 1px, transparent 1px); background-size: 16px 16px; border-radius: var(--r-xs); }
.barrow { display: grid; grid-template-columns: minmax(88px, max-content) 1fr minmax(32px, max-content); align-items: center; gap: var(--s-2); }
.barrow + .barrow { margin-top: var(--s-2); }
.barrow__track { width: 100%; height: 16px; display: block; }
.barrow__n { text-align: right; font-size: var(--fs-base); line-height: var(--lh-body); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
/* .funnelrow REUSA .barrow__track/__n (misma anatomía de barra): reuso deliberado. */
.funnelrow { display: grid; grid-template-columns: minmax(150px, 220px) 1fr auto; align-items: center; gap: var(--s-3); }
.funnelrow + .funnelrow { margin-top: var(--s-3); }
.funnelrow__label { font-size: var(--fs-sm); line-height: 1.2308; color: var(--ink-muted); overflow-wrap: break-word; }
.funnelrow__stat { text-align: right; font-size: var(--fs-lg); line-height: 1.4118; font-weight: 700; letter-spacing: -0.01em; }
.funnelrow__delta { display: block; font-size: var(--fs-2xs); line-height: 1.4545; font-weight: 400; letter-spacing: 0; color: var(--ink-subtle); font-variant-numeric: tabular-nums; }
.spark__dot { fill: var(--brand); stroke: var(--surface-raised); stroke-width: 2.5; }
.fill-track { fill: var(--surface-sunken); }
.fill-critical { fill: var(--danger-deep); }
.fill-high { fill: var(--danger); }
.fill-moderate { fill: var(--warning); stroke: var(--warning-text); stroke-width: 0.75; }
.fill-low { fill: var(--caution); stroke: var(--caution-text); stroke-width: 0.75; }
.fill-none { fill: var(--success); stroke: var(--success-text); stroke-width: 0.75; }
.fill-neutral { fill: var(--ink-subtle); stroke: var(--ink-muted); stroke-width: 0.75; }
.fill-brand { fill: var(--brand); }
.fill-area { fill: var(--brand-soft); }
.chart { width: 100%; height: auto; display: block; min-width: 560px; }
.chart__target { fill: transparent; }
.chart__grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.chart__yval, .chart__tick {
  font-family: var(--font-sans); font-size: 11px; font-variant-numeric: tabular-nums;
  fill: var(--ink-muted);
  paint-order: stroke; stroke: var(--surface-raised); stroke-width: 3px; stroke-linejoin: round;
}
.chart__pt { fill: var(--brand); stroke: var(--surface-raised); stroke-width: 1.5; }
.chart__pt--danger { fill: var(--danger); }
.spark__dot--danger { fill: var(--danger); }
.stroke-brand { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.fill-area--danger { fill: var(--danger); opacity: 0.12; }
.stroke-danger { fill: none; stroke: var(--danger); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* ── Disclosure (detalle progresivo) ── */
.disclosure { margin-top: var(--s-3); }
.disclosure > summary { cursor: pointer; font-size: var(--fs-xs); line-height: 1.3333; font-weight: 600; color: var(--brand-strong); min-height: 24px; padding: var(--s-1) 0; list-style: none; display: inline-flex; align-items: center; gap: var(--s-1); border-radius: var(--r-md); }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { text-decoration: underline; }
.disclosure > summary .icon { transition: transform var(--ease); }
.disclosure[open] > summary .icon { transform: rotate(90deg); }

/* ── Utilidades (CSP-safe: el proyecto prohíbe estilos inline; todas en grilla 4px) ── */
.text-muted { color: var(--ink-muted); }
.text-center { text-align: center; }
.text-sm { font-size: var(--fs-sm); line-height: 1.5385; }
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); }
.mb-4 { margin-bottom: var(--s-4); }
.section-title { font-size: var(--fs-lg); line-height: 1.4118; margin-bottom: var(--s-3); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── Prosa larga (páginas legales): ritmo vertical que el reset * {margin:0} le quita ── */
.prose h1 { margin-bottom: var(--s-4); }
.prose h2 { margin: var(--s-6) 0 var(--s-3); }
.prose p, .prose ul, .prose ol { margin-bottom: var(--s-4); color: var(--ink); }
.prose ul, .prose ol { padding-left: var(--s-5); }
.prose li + li { margin-top: var(--s-2); }
.prose a { text-decoration: underline; }

/* ── Logo del documento imprimible ── */
.doc-head__logo { border-radius: var(--r-xs); }

.table-wrap, .chart-scroll { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ── Filtro inline de fechas (GET): fila compacta de labels+inputs+acciones ── */
.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-2); }
.form-inline > .text-sm { align-self: center; }
.form-inline .input, .form-inline .select, .form-inline select { width: auto; max-width: 100%; }
.form-inline .select, .form-inline select { min-height: 36px; padding-top: var(--s-2); padding-bottom: var(--s-2); font-size: var(--fs-base); }
.form-inline__par { display: inline-flex; flex-direction: column; align-items: flex-start; gap: var(--s-1); white-space: nowrap; }
.form-inline input[type="date"] {
  min-height: 36px; padding: var(--s-2) var(--s-3); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font: inherit; font-size: var(--fs-base); line-height: var(--lh-body); color: var(--ink); background: var(--surface-raised);
  font-variant-numeric: tabular-nums;
}
.form-inline input[type="date"]:focus { outline: none; border-color: var(--ring); box-shadow: var(--ring-glow); }
.form-inline .field__label { color: var(--ink-subtle); font-size: var(--fs-2xs); line-height: 1.4545; font-weight: 500; text-transform: uppercase; letter-spacing: var(--tracking-wide); }

/* ══ Responsivo (ÚLTIMA capa, paridad base.css:228: gana por orden de fuente) ══ */
@media (max-width: 720px) {
  .btn { white-space: normal; }
  .kpi-grid, .kpi-grid:has(> :nth-child(6):last-child) { grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
  .kpi__value { font-size: var(--fs-xl); line-height: var(--lh-tight); }
  .kpi-grid > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .form-inline .form-inline__par { width: 100%; }
  .form-inline .form-inline__par input, .form-inline .form-inline__par .select { flex: 1; }
}
@media (max-width: 720px) {
  .table--defs thead { display: none; }
  .table--defs, .table--defs tbody, .table--defs tr, .table--defs td { display: block; width: 100%; }
  .table--defs tr { border-top: 1px solid var(--border); padding: var(--s-3) 0; }
  .table--defs td { padding: var(--s-1) var(--s-4); border: none; }
  .table--defs td:first-child { font-weight: 600; }
}
@media (max-width: 720px) {
  .funnelrow { grid-template-columns: 1fr auto; }
  .funnelrow__label { grid-column: 1 / -1; }
}

/* ── Print de componentes ── AL FINAL DEL ARCHIVO a propósito: un reset de print con el mismo
   selector que su regla de pantalla solo gana si aparece después (cascada por orden de fuente;
   en base.css estos resets perdían — preexistente v1, Codex r9 2026-08-17). */
@media print {
  /* background incluido: la cascada es POR PROPIEDAD y el fondo de pantalla (scrim de scroll
     radial) sobrevivía al print sin esta línea (Codex r10). */
  .table-wrap { background: transparent; border: none; box-shadow: none; border-radius: 0; overflow: visible; }
  .table tbody tr:hover td { background: transparent; }
  .table .row--total td { background: #f0f0f0; }
  /* :hover también en print (0-3-3 de pantalla le ganaba al gris del PDF si se imprimía con el
     cursor encima — Codex r11): mismo selector con el gris del documento. */
  .table tbody tr.row--total:hover td { background: #f0f0f0; }
  .doc-print .table th, .doc-print .table td { border: 1px solid #999; padding: 4px 6px; font-size: 11px; }
  /* Cabecera con fondo (paridad v1): en un documento de 13 columnas separa cabecera de datos. */
  .doc-print .table thead th { background: #f0f0f0; color: var(--ink-muted); }
}
