/* Subsana · sistema visual base
   Concepto: tinta naval + verde azulado de control + ámbar de alerta. Los cuatro portones son el
   motivo que se repite: pastillas numeradas 1-2-3-4 con su estado. Tipografía: Bricolage Grotesque
   para títulos, Figtree para texto, JetBrains Mono para códigos y montos. */

:root {
  --ink: #0e1b2e;
  --ink-2: #26344d;
  --text: #1d2939;
  --muted: #5d6b80;
  --soft: #8a96a8;
  --line: #dde3eb;
  --line-2: #c9d2de;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;

  --teal: #0b7a78;
  --teal-600: #08605f;
  --teal-50: #e2f3f2;
  --teal-100: #c4e7e5;
  --amber: #b7790f;
  --amber-50: #fbf1dc;
  --red: #b42318;
  --red-50: #fdeae8;
  --green: #1d7a4a;
  --green-50: #e2f3e9;
  --blue: #2c5aa0;
  --blue-50: #e6edf8;
  --violet: #5b45a8;
  --violet-50: #eeeaf9;

  --f-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --f-body: 'Figtree', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow-1: 0 1px 2px rgba(14, 27, 46, 0.06), 0 1px 1px rgba(14, 27, 46, 0.04);
  --shadow-2: 0 10px 30px -12px rgba(14, 27, 46, 0.25), 0 2px 6px rgba(14, 27, 46, 0.06);
  /* Foco de teclado: anillo sólido de 2 px con separación (≥3:1 sobre el fondo). En zonas oscuras
     se cambia a menta con --focus-ring. */
  --focus-ring: #0b7a78;
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus-ring);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.55;
}
img,
svg {
  max-width: 100%;
}
a {
  color: var(--teal);
}
h1,
h2,
h3,
h4 {
  font-family: var(--f-display);
  color: var(--ink);
  line-height: 1.12;
  margin: 0;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
p {
  margin: 0;
}
code,
.mono {
  font-family: var(--f-mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}
.num {
  font-variant-numeric: tabular-nums;
}
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 6px;
}
body.site .nav,
body.site .mobile-nav,
body.site .hero,
body.site .section-dark,
.footer,
.login-side,
.side {
  --focus-ring: #8ce9cf;
}
/* Con una ventana abierta, la página de atrás no se desplaza. */
html.modal-open {
  overflow: hidden;
}
/* Volver a la sección madre, sobre el título. */
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-bottom: 4px;
  color: var(--teal-600);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.back-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
[hidden] {
  display: none !important;
}

/* ── Botones ─────────────────────────────────────────────────────────────── */
.btn {
  --b: var(--surface);
  --c: var(--ink);
  --bd: var(--line-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--bd);
  background: var(--b);
  color: var(--c);
  font: 600 15px/1.2 var(--f-body);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--ink-2);
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled],
.btn.is-busy {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  --b: var(--teal);
  --c: #fff;
  --bd: var(--teal);
}
.btn-primary:hover {
  --b: var(--teal-600);
  --bd: var(--teal-600);
}
.btn-dark {
  --b: var(--ink);
  --c: #fff;
  --bd: var(--ink);
}
.btn-dark:hover {
  --b: var(--ink-2);
}
.btn-danger {
  --b: var(--red);
  --c: #fff;
  --bd: var(--red);
}
.btn-ghost {
  --b: transparent;
  --bd: transparent;
}
.btn-ghost:hover {
  --b: rgba(14, 27, 46, 0.06);
  --bd: transparent;
}
.btn-sm {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 13.5px;
  border-radius: 8px;
}
.btn-lg {
  min-height: 50px;
  padding: 12px 22px;
  font-size: 16.5px;
  border-radius: 12px;
}

/* ── Formularios ─────────────────────────────────────────────────────────── */
.field {
  display: grid;
  gap: 6px;
}
.field > span,
.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.input,
select.input,
textarea.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  font: 15px/1.4 var(--f-body);
  color: var(--text);
}
textarea.input {
  min-height: 92px;
  resize: vertical;
}
.input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: var(--focus);
}
.hint {
  font-size: 12.5px;
  color: var(--muted);
}

/* ── Etiquetas de estado ─────────────────────────────────────────────────── */
.chip {
  --cb: var(--surface-2);
  --cc: var(--ink-2);
  --cd: var(--line);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--cd);
  background: var(--cb);
  color: var(--cc);
  font: 600 12.5px/1.6 var(--f-body);
  white-space: nowrap;
}
.chip::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.chip.plain::before {
  display: none;
}
.chip.ok {
  --cb: var(--green-50);
  --cc: var(--green);
  --cd: #bfe3cd;
}
.chip.info {
  --cb: var(--blue-50);
  --cc: var(--blue);
  --cd: #c7d6ef;
}
.chip.warn {
  --cb: var(--amber-50);
  --cc: var(--amber);
  --cd: #f0d9a6;
}
.chip.bad {
  --cb: var(--red-50);
  --cc: var(--red);
  --cd: #f6c3bd;
}
.chip.block {
  --cb: var(--surface);
  --cc: var(--ink);
  --cd: var(--ink-2);
}
.chip.teal {
  --cb: var(--teal-50);
  --cc: var(--teal-600);
  --cd: var(--teal-100);
}
.chip.violet {
  --cb: var(--violet-50);
  --cc: var(--violet);
  --cd: #d7cff1;
}
.tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 5px;
  font: 700 10.5px/18px var(--f-mono);
  letter-spacing: 0.04em;
  border: 1px solid currentColor;
}
.tag.ley {
  color: var(--ink);
}
.tag.contrato {
  color: var(--blue);
}
.tag.subsana {
  color: var(--teal-600);
}
.tag.mandante {
  color: var(--violet);
}
.tag.interno {
  color: var(--muted);
}

/* ── Portones ────────────────────────────────────────────────────────────── */
.gates {
  display: inline-flex;
  gap: 4px;
}
.gate-dot {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font: 700 12px/1 var(--f-mono);
  background: var(--surface-2);
  color: var(--soft);
  border: 1px solid var(--line);
}
.gate-dot.ok {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.gate-dot.sub {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.gate-dot.info {
  background: var(--blue-50);
  color: var(--blue);
  border-color: #c7d6ef;
}
.gate-dot.warn {
  background: var(--amber-50);
  color: var(--amber);
  border-color: #f0d9a6;
}
.gate-dot.block {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink-2);
}
.gate-dot.bad {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* ── Utilidades ──────────────────────────────────────────────────────────── */
.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row.wrap-row {
  flex-wrap: wrap;
}
.grow {
  flex: 1;
  min-width: 0;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13.5px;
}
.xsmall {
  font-size: 12.5px;
}
.strong {
  font-weight: 700;
}
.eyebrow {
  font: 700 12.5px/1.4 var(--f-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-600);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 800 21px/1 var(--f-display);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.logo-sub {
  color: var(--teal);
}
/* Sobre fondo oscuro: "Sub" con el verde del logo y "sana" en blanco. */
.logo.light,
.side .logo,
.login-side .logo {
  color: #fff;
}
.logo.light .logo-sub,
.side .logo .logo-sub,
.login-side .logo .logo-sub {
  color: #5fc9c5;
}
.logo svg {
  width: 30px;
  height: 30px;
}

/* ── Notificaciones flotantes ────────────────────────────────────────────── */
.toasts {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 8px;
  z-index: 90;
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  font-size: 14.5px;
  animation: toast-in 0.25s ease;
}
.toast.bad {
  background: var(--red);
}
.toast.ok {
  background: var(--green);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
/* Movimiento reducido: sin desplazamientos ni animaciones, pero los cambios de estado se siguen
   notando con un fundido breve de color u opacidad. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition-property: opacity, color, background-color, border-color, box-shadow !important;
    transition-duration: 0.12s !important;
  }
}
/* En pantallas táctiles los botones chicos igual tienen 44 px de zona útil. */
@media (max-width: 720px), (pointer: coarse) {
  .btn-sm,
  .back-link {
    min-height: 44px;
  }
  .btn-sm {
    padding-inline: 14px;
  }
}
