/* SINLEAF · estilo común. Paleta del logo SINFAB: azul marino (#03344f) y azul acero (#5b8ba8), con grises fríos. */
:root {
  --marino-950: #011a29; --marino-900: #02263b; --marino: #03344f; --marino-700: #0b4766; --marino-600: #165a7e;
  --acero: #5b8ba8; --acero-600: #3d7393; --acero-300: #a9c6d8; --acero-200: #cddfea; --acero-100: #e5eff5; --acero-50: #f2f7fa;
  --tinta: #0f1d27; --suave: #5b6a76; --tenue: #8a97a2; --linea: #e1e8ee; --linea-fuerte: #cbd5de;
  --fondo: #f3f6f9; --papel: #fff;
  --ok: #1d7f57; --ok-suave: #e3f3ec; --aviso: #a8620b; --aviso-suave: #fdf1df; --peligro: #b42318; --peligro-suave: #fdecea;
  --marca: rgba(255, 196, 0, .38); --marca-activa: rgba(255, 140, 0, .5); --marca-hecha: rgba(29, 127, 87, .18);
  --r-s: 8px; --r: 12px; --r-l: 18px;
  --sombra-s: 0 1px 2px rgba(2, 38, 59, .06);
  --sombra: 0 1px 2px rgba(2, 38, 59, .05), 0 4px 14px rgba(2, 38, 59, .07);
  --sombra-l: 0 8px 30px rgba(2, 38, 59, .16), 0 2px 6px rgba(2, 38, 59, .08);
  --anillo: 0 0 0 3px rgba(91, 139, 168, .35);
  --transicion: .16s cubic-bezier(.3, .7, .4, 1);
  --barra-alto: 60px;
  font-family: "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", sans-serif;
  color: var(--tinta); -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--acero-600); text-decoration: none; }
a:hover { color: var(--marino); }
h1, h2, h3 { color: var(--marino-900); letter-spacing: -.01em; }
::selection { background: rgba(91, 139, 168, .3); }

/* ---------------------------------------------------------------- iconos (sprite iconos.svg) */
.i { width: 18px; height: 18px; flex: none; vertical-align: -.2em; }
.i.g { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- controles */
button, select, input, textarea { font: inherit; color: inherit; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--linea-fuerte); background: var(--papel); border-radius: var(--r-s);
  padding: 7px 13px; cursor: pointer; font-weight: 500; color: var(--marino-900); line-height: 1.3;
  transition: background var(--transicion), border-color var(--transicion), box-shadow var(--transicion), color var(--transicion);
}
button:hover { border-color: var(--acero-300); background: var(--acero-50); }
button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible { outline: none; box-shadow: var(--anillo); }
button.primario { background: var(--marino); border-color: var(--marino); color: #fff; }
button.primario:hover { background: var(--marino-700); border-color: var(--marino-700); }
button.fantasma { border-color: transparent; background: transparent; }
button.fantasma:hover { background: var(--acero-100); border-color: transparent; }
button.enlace { border: 0; background: none; padding: 4px 8px; color: var(--suave); border-radius: 6px; font-weight: 500; font-size: 13.5px; }
button.enlace:hover { color: var(--marino); background: var(--acero-100); }
button.icono { padding: 0; width: 38px; height: 38px; border-radius: 10px; }
button:disabled { opacity: .5; cursor: default; transform: none; }
input, select, textarea {
  border: 1px solid var(--linea-fuerte); border-radius: var(--r-s); padding: 8px 11px; background: var(--papel);
  transition: border-color var(--transicion), box-shadow var(--transicion);
}
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background: var(--papel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6a76' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center / 16px;
}
textarea { width: 100%; resize: vertical; min-height: 76px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acero); box-shadow: var(--anillo); }
input::placeholder, textarea::placeholder { color: var(--tenue); }

/* control segmentado (vistas, filtros, tipo de documento) */
.segmento { display: inline-flex; background: var(--acero-100); border-radius: 11px; padding: 3px; gap: 2px; }
.segmento button {
  border: 0; background: transparent; border-radius: 8px; padding: 6px 14px; color: var(--suave); font-size: 14px; white-space: nowrap;
}
.segmento button:hover { color: var(--marino); background: rgba(255, 255, 255, .55); }
.segmento button.activa { background: var(--papel); color: var(--marino); box-shadow: var(--sombra-s), 0 0 0 1px rgba(2, 38, 59, .04); font-weight: 600; }

/* ---------------------------------------------------------------- barra superior y marca */
.barra {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  height: var(--barra-alto); padding: 0 20px; background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--linea);
}
.barra .hueco { flex: 1; }
.logo { display: inline-flex; align-items: center; gap: 9px; color: var(--marino); text-decoration: none; flex: none; }
.logo img { width: 34px; height: 34px; display: block; }
.palabra { font-size: 20px; line-height: 1; letter-spacing: .06em; color: var(--marino); white-space: nowrap; }
.palabra b { font-weight: 800; }
.palabra span { font-weight: 300; }
.logo:hover { color: var(--marino); }

/* ---------------------------------------------------------------- avatares, etiquetas y chips */
.avatar {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff;
  font-size: 11px; font-weight: 700; flex: none; letter-spacing: .02em;
}
.etiqueta {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; background: var(--acero-100); color: var(--marino-700);
  font-size: 12.5px; font-weight: 500; margin: 0 4px 4px 0; border: 1px solid transparent; line-height: 1.5;
}
button.etiqueta { cursor: pointer; }
button.etiqueta:hover { border-color: var(--acero-300); background: var(--acero-100); }
.etiqueta.activa, button.etiqueta.activa:hover { background: var(--marino); color: #fff; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 1px 8px;
  background: var(--acero-100); color: var(--marino-700); white-space: nowrap; line-height: 1.6;
}
.chip .i { width: 12px; height: 12px; }
.chip.ok { color: var(--ok); background: var(--ok-suave); }
.chip.aviso { color: var(--aviso); background: var(--aviso-suave); }
.chip.marino { background: var(--marino); color: #fff; }
.tenue { color: var(--suave); }
.error { color: var(--peligro); min-height: 1.4em; font-size: 14px; }
.oculto { display: none !important; }

/* ---------------------------------------------------------------- menús emergentes (escritorio) y hojas inferiores (móvil) */
.pop-fondo { position: fixed; inset: 0; z-index: 60; }
.pop {
  position: fixed; z-index: 61; min-width: 240px; max-width: min(380px, calc(100vw - 16px)); max-height: min(70vh, 560px); overflow: auto;
  background: var(--papel); border-radius: var(--r); box-shadow: var(--sombra-l); border: 1px solid var(--linea); padding: 6px;
  animation: aparecer .14s ease-out; transform-origin: top right;
}
@keyframes aparecer { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.pop .op {
  display: flex; width: 100%; align-items: center; gap: 11px; border: 0; background: none; text-align: left; justify-content: flex-start;
  padding: 10px 12px; border-radius: 9px; font-weight: 500; color: var(--tinta);
}
.pop .op:hover, .pop .op:focus-visible { background: var(--acero-100); box-shadow: none; }
.pop .op .i { color: var(--suave); }
.pop .op.peligro, .pop .op.peligro .i { color: var(--peligro); }
.pop .op.peligro:hover { background: var(--peligro-suave); }
.pop hr { border: 0; border-top: 1px solid var(--linea); margin: 6px 4px; }
.pop .tit { font-size: 11.5px; font-weight: 700; color: var(--tenue); text-transform: uppercase; letter-spacing: .07em; padding: 10px 12px 4px; }
.pop .asa { display: none; }
@media (max-width: 640px) {
  .pop-fondo { background: rgba(1, 26, 41, .4); animation: fundido .2s ease-out; }
  .pop {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; max-width: none; width: 100%; max-height: 82vh;
    border-radius: 20px 20px 0 0; padding: 4px 10px calc(14px + env(safe-area-inset-bottom)); animation: subir .22s cubic-bezier(.2, .8, .3, 1);
  }
  .pop .asa { display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--linea-fuerte); margin: 6px auto 8px; }
  .pop .op { padding: 13px 12px; font-size: 16px; }
}
@keyframes subir { from { transform: translateY(100%); } }
@keyframes fundido { from { opacity: 0; } }

/* ---------------------------------------------------------------- diálogos */
.modal-fondo {
  position: fixed; inset: 0; background: rgba(1, 26, 41, .45); display: grid; place-items: center; z-index: 70; padding: 16px;
  animation: fundido .18s ease-out; backdrop-filter: blur(2px);
}
.modal {
  background: var(--papel); border-radius: var(--r-l); padding: 24px; width: min(400px, 100%); box-shadow: var(--sombra-l);
  animation: aparecer .18s ease-out;
}
.modal h2 { margin: 0 0 4px; font-size: 19px; }
.modal p { margin: 0 0 12px; color: var(--suave); font-size: 14px; }
.modal label { display: block; margin: 12px 0 5px; color: var(--suave); font-size: 13.5px; font-weight: 500; }
.modal input { width: 100%; }
.modal .acciones { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* aviso breve abajo */
.tostada {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80;
  background: var(--marino-900); color: #fff; padding: 10px 18px; border-radius: 999px; box-shadow: var(--sombra-l); font-size: 14px;
  display: flex; align-items: center; gap: 8px; animation: aparecer .2s ease-out; max-width: calc(100vw - 32px);
}

/* táctil: objetivos de 40 px o más */
@media (pointer: coarse) {
  button { min-height: 40px; }
  button.enlace { min-height: 36px; }
  .segmento button { min-height: 36px; }
  input, select { min-height: 42px; font-size: 16px; }
  textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- botón y menú de cuenta */
.avatar.g { width: 42px; height: 42px; font-size: 15px; }
button.cuenta { padding: 4px 10px 4px 4px; border-radius: 999px; gap: 8px; border-color: var(--linea); background: var(--papel); }
button.cuenta:hover { border-color: var(--acero-300); background: var(--acero-50); }
button.cuenta .avatar { width: 32px; height: 32px; font-size: 12px; }
button.cuenta .flecha { width: 16px; height: 16px; color: var(--suave); }
.cuenta-nombre { font-size: 14px; font-weight: 600; }
.menu-cuenta { min-width: 270px; }
.cuenta-cab { display: flex; align-items: center; gap: 12px; padding: 10px 12px 6px; }
.cuenta-quien { font-weight: 700; color: var(--marino-900); }
.cuenta-cab .tenue { font-size: 13px; display: flex; align-items: center; }
@media (max-width: 640px) {
  .cuenta-nombre, button.cuenta .flecha { display: none; }
  button.cuenta { padding: 3px; }
}

/* opción con título y detalle */
.op-textos { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.op-tit { font-weight: 600; color: var(--marino-900); }
.op-det { font-size: 12.5px; color: var(--suave); font-weight: 400; margin-top: 1px; }

/* nada puede ensanchar la página en el móvil (descuadra todo y las hojas inferiores salen fuera de la vista) */
html, body { overflow-x: clip; }

/* pie con la versión (portada, cuenta y ajustes) */
.pie { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--tenue); font-size: 12.5px; padding-top: 10px; padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.pie img { width: 18px; height: 18px; opacity: .8; }
