/* deploy-hash: 20260523T034500 */

/* Fuentes AUTO-HOSPEDADAS (Inter, Geist, JetBrains Mono) — auditoría 2026-07-04 (I3).
   Antes se cargaban de Google Fonts (fuga de IP/Referer a un tercero + dependencia
   externa). Ahora viven en /shared/fonts/ y se declaran en fonts.css. Toda página que
   importa base.css hereda las 3 familias; font-display:swap evita bloquear el render.
   ⚠ El @import DEBE ir antes de cualquier regla de estilo (spec CSS) — por eso al tope. */
@import url('/shared/fonts/fonts.css?v=301');

/* =====================================================
   GATE ANTI-FLASH (pre-paint) — ver auth-gate.js
   =====================================================
   El head-script marca <html class="gate-hold"> cuando la cache NO confirma
   acceso a la página (config/módulo). Mantiene el body oculto hasta que el
   guard async confirme (revela quitando la clase) o redirija. Returning users
   con cache positiva NO reciben la clase → pintan al instante (sin flash).
   .mod-write: revela los controles de escritura (data-write-only, ej. botón
   "Nueva") solo a encargado/admin; el solo-lectura nunca los ve parpadear. */
html.gate-hold body { visibility: hidden !important; }
html:not(.mod-write) [data-write-only] { display: none !important; }

/* =====================================================
   BASE.CSS — Paleta de Obra (modo claro, alta visibilidad)
   =====================================================
   Diseñado para legibilidad bajo sol caribeño, pantallas
   sucias, y reflejos típicos de uso en exteriores.

   Inspiración visual:
   - Planos de ingeniería (blueprint blue #0F172A)
   - Maquinaria pesada (Caterpillar yellow #EAB308)
   - Materiales base (gris cemento #F8FAFC)

   Reglas de oro:
   - Modo claro por default. Dark NO es opción para obra.
   - Tipografía bold (500+ base, 700 para títulos).
   - Contraste WCAG AA mínimo en todo texto crítico.
   - Cero glass / blur que se pierde bajo sol directo.
   - Shadows sutiles + borders nítidos para definición.
   ===================================================== */

:root {
  /* ===== FONDOS — gris cemento, NO blanco puro ===== */
  --bg: #F8FAFC;              /* Fondo base — gris cemento suave */
  --bg-elev: #FFFFFF;          /* Cards, modals, surfaces elevadas */
  --bg-soft: #F1F5F9;          /* Hover de inputs, secciones secundarias */
  --bg-input: #FFFFFF;
  --bg-input-hover: #F8FAFC;

  /* ===== TEXTO — azul plano profundo dominante ===== */
  --text: #0F172A;             /* Azul plano (blueprint) — títulos y montos */
  --text2: #334155;            /* Gris acero — texto secundario importante */
  --text3: #64748B;            /* Gris acero claro — meta, fechas, códigos */
  --text-soft: #94A3B8;        /* Placeholders, deshabilitado */

  /* ===== BORDERS — gris cemento medio ===== */
  --border: #E2E8F0;           /* Border default — cards, inputs */
  --border-strong: #CBD5E1;    /* Border más visible para énfasis */
  --border-hover: #94A3B8;     /* Hover de inputs */

  /* ===== ACENTOS — paleta de obra ===== */
  --amber: #EAB308;            /* Amarillo Caterpillar — acciones primarias */
  --amber-deep: #CA8A04;       /* Amarillo más oscuro para hover */
  --amber-soft: #FEF3C7;       /* Background suave para alerts amber */
  --amber-glow: rgba(234, 179, 8, 0.25);

  --orange: #EA580C;           /* Naranja vial — acciones críticas alternas */
  --orange-soft: #FFEDD5;
  --orange-deep: #9A3412;      /* Naranja oscuro — texto sobre orange-soft */

  /* Navy de marca Mabrick (sesión 22 F2.5). Acentos sutiles que refuerzan
     identidad: bordes de cards destacadas, valores monetarios principales,
     links secundarios. NO usar para CTAs (eso sigue amber). */
  --navy: #1A2547;             /* Navy del logo MABRICK */
  --navy-soft: #E0E7FF;        /* Tint para badges/highlights */
  --navy-glow: rgba(26, 37, 71, 0.15);

  --red: #DC2626;              /* Rojo seguridad — alertas críticas */
  --red-soft: #FEE2E2;
  --red-deep: #991B1B;

  --green: #15803D;            /* Verde aprobado — confirmaciones */
  --green-soft: #DCFCE7;
  --green-deep: #14532D;

  --blue: #0F172A;             /* Azul plano (mismo que text para coherencia) */

  /* ===== BRAND (override por org via JS si quieren branding propio) ===== */
  --brand-primary: var(--amber);
  --brand-text: var(--text);

  /* Altura estándar de un control de formulario de una línea (text/select/number).
     Centraliza la altura para igualar los date/time (que renderizan más altos). */
  --control-h: 44px;
  /* ===== RADIUS + TIPOGRAFÍA ===== */
  --r: 12px;                   /* Radius default — cards, inputs, botones */
  --r-sm: 8px;                 /* Botones secundarios, badges */
  --r-lg: 16px;                /* Modals, large cards */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  /* ===== SHADOWS — sutiles pero presentes ===== */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 2px 4px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 8px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.04);
  --shadow-amber: 0 4px 12px rgba(234, 179, 8, 0.3), 0 1px 2px rgba(234, 179, 8, 0.2);

  /* ===== ELEVACIÓN EN CAPAS (sombras tintadas en navy, no negro) =====
     Sistema premium reusable: e1 = reposo de card, e3 = card en hover/elevada,
     e4 = modal/popover. Tintado en el navy de marca para armonizar. Centralizado:
     cualquier superficie de la app puede adoptar var(--e1..e4). */
  --shadow-navy: 222deg 39% 18%;
  --e1: 0 1px 1px hsl(var(--shadow-navy) / .04), 0 2px 4px hsl(var(--shadow-navy) / .05);
  --e2: 0 1px 1px hsl(var(--shadow-navy) / .05), 0 3px 6px hsl(var(--shadow-navy) / .06), 0 6px 12px hsl(var(--shadow-navy) / .05);
  --e3: 0 1px 1px hsl(var(--shadow-navy) / .05), 0 6px 10px hsl(var(--shadow-navy) / .08), 0 14px 24px hsl(var(--shadow-navy) / .09), 0 22px 38px hsl(var(--shadow-navy) / .06);
  --e4: 0 2px 4px hsl(var(--shadow-navy) / .06), 0 8px 16px hsl(var(--shadow-navy) / .09), 0 18px 36px hsl(var(--shadow-navy) / .10), 0 30px 60px hsl(var(--shadow-navy) / .08);

  /* ===== SPACING ===== */
  --sp1: 4px;
  --sp2: 8px;
  --sp3: 12px;
  --sp4: 16px;
  --sp5: 24px;
  --sp6: 32px;
  --sp7: 48px;
}

* { box-sizing: border-box; }
/* Sin el flash gris nativo de iOS al tocar: nuestras animaciones :active dan el feedback. */
* { -webkit-tap-highlight-color: transparent; }

/* =====================================================
   MOVIMIENTO — utilidades centralizadas (entrada escalonada) + accesibilidad.
   .reveal: la usa el Hub (y cualquier grilla) para que sus items entren con
   fade+rise escalonado vía --i. Solo transform/opacity = GPU, 60fps en iOS.
   ===================================================== */
@keyframes mk-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.reveal { opacity: 0; animation: mk-rise .55s cubic-bezier(.22, 1, .36, 1) forwards; animation-delay: calc(var(--i, 0) * 70ms); }

/* Respeta a quien pide menos movimiento (Ajustes de iOS/macOS). Backstop global
   además de los fallbacks por componente. */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; animation: none; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* =====================================================
   .lift-card — patrón de tarjeta premium CENTRALIZADO (una sola definición,
   cero drift entre módulos). Se AÑADE a cualquier card existente (que ya trae su
   bg/border/radius/padding); aporta: elevación en capas + acento del color `--mod`
   en el borde izquierdo, spotlight que sigue el cursor (::before, desktop), y
   sombra profunda + anillo ámbar en hover (::after, crossfade por opacidad = GPU).
   El JS setea `--mod` por card y llama `attachSpotlight()` (ui.js) tras render.
   La card NO debe declarar su propio box-shadow (lo gana el de aquí).
   ===================================================== */
.lift-card {
  position: relative; isolation: isolate;
  box-shadow: inset 3px 0 0 var(--mod, var(--amber)), var(--e1);
  transition: transform .22s cubic-bezier(.22, 1, .36, 1);
}
.lift-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  opacity: 0; transition: opacity .3s; z-index: 0;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--mod, var(--amber)) 15%, transparent), transparent 60%);
}
.lift-card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  opacity: 0; transition: opacity .25s; z-index: -1;
  box-shadow: var(--e3), 0 0 0 1px hsl(48 90% 50% / .35);
}
.lift-card > * { position: relative; z-index: 1; }
@media (hover: hover) {
  .lift-card:hover { transform: translateY(-5px); }
  .lift-card:hover::before { opacity: 1; }
  .lift-card:hover::after { opacity: 1; }
}
.lift-card:active { transform: translateY(-2px) scale(.997); }

/* Hover de fila para TABLAS DE DATOS (opt-in: clase .data-table en el <table>).
   Última superficie plana de la fase visual: resalte sutil al recorrer filas.
   - Opt-in para NO tocar las tablas de reporte PDF (caja/reportes, personal/reportes).
   - Excluye la fila propia (.is-me, resalte ámbar) para no pisarla.
   - `> td` ⇒ solo filas de datos; el thead (th) queda intacto.
   - Gateado a hover:hover ⇒ sin hover pegajoso en táctil. */
@media (hover: hover) {
  .data-table tr { transition: background-color .12s ease; }
  .data-table tr:not(.is-me):hover > td { background: var(--bg-soft); }
}

html, body { margin: 0; padding: 0; }
html { background: var(--bg); }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  font-size: 15px;
  font-weight: 500;            /* BOLD por default para legibilidad en obra */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

/* =====================================================
   TIPOGRAFÍA — bold dominante, jerarquía clara
   ===================================================== */
h1, h2, h3, h4 {
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--sp3);
  letter-spacing: -0.02em;
}
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.2; }
h1, h2 { font-family: var(--font-display); }   /* F2.6 — Geist display en títulos (h3=eyebrow y h4 se quedan en Inter) */
h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  font-weight: 700;
}
h4 { font-size: 14px; font-weight: 600; }

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--amber);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: opacity 0.15s;
  font-weight: 600;
}
a:hover { opacity: 0.75; }

.muted { color: var(--text3); font-weight: 500; }
.mono { font-family: var(--mono); font-weight: 600; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-bold { font-weight: 700; }

/* Códigos de proyecto / referencias en mono */
.code-ref {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text2);
  background: var(--bg-soft);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* =====================================================
   INPUTS — blanco con border fuerte, focus amarillo
   ===================================================== */
/* :where() mantiene la especificidad de este reset en (0,0,1): así cualquier
   clase local (.hrs, .seed-account-input, etc.) puede ajustar ancho/padding de
   un input chico sin pelear contra los 4 :not([type]) (que la inflaban a (0,4,1)
   y clobbeaban los overlays locales). El filtro de tipos es idéntico. */
input:where(:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file])),
select,
textarea {
  font-family: var(--font);
  /* 16px es el umbral: con <16px, iOS Safari hace ZOOM al enfocar el campo y eso
     descuadra la página (no se recompone hasta navegar). NUNCA bajar de 16px en
     controles de formulario. Era la causa del "desfase al escribir". */
  font-size: 16px;
  font-weight: 500;
  background: var(--bg-input);
  color: var(--text);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  width: 100%;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) {
  border-color: var(--border-hover);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-glow);
}
input::placeholder, textarea::placeholder {
  color: var(--text-soft);
  font-weight: 500;
}
/* Los <input type=date|time|datetime-local|month|week> renderizan ~2px MÁS altos
   que text/select/number (su edición interna ::-webkit-datetime-edit impone la
   altura) → desalinea las filas de filtros (Desde/Hasta vs Obra/Buscar) y sus
   labels. Medido en preview: text/select/number=44px, date=46px. Fijar el date a
   la altura estándar lo iguala. Macro: aplica a TODA la app (date/time nunca son
   compactos, así que un height fijo es seguro). --control-h centraliza el valor. */
input[type=date], input[type=time], input[type=datetime-local],
input[type=month], input[type=week] { height: var(--control-h); }

/* =====================================================
   FIELDS
   ===================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: var(--sp4);
}
.field:last-child { margin-bottom: 0; }

.lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: var(--sp4); /* ritmo vertical: separa la fila del campo siguiente */
}
.grid2 .field { margin-bottom: 0; }

/* Fila de campos lado-a-lado en formularios/modales (Fecha+Monto, NCF+Reporte…).
   ESTÁNDAR centralizado: antes se duplicaba en el <style> de cada página y derivaba
   (un .grid2-form sin margin-bottom dejaba el campo siguiente PEGADO — ej. FUENTE en
   Ingresos). Mismo ritmo vertical que .field. NO redefinir por página. */
.grid2-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp4); /* mismo 16px que el ritmo vertical: al apilar en móvil queda parejo */
  margin-bottom: var(--sp4);
}
.grid2-form .field { margin-bottom: 0; }
@media (max-width: 768px) {
  .grid2-form { grid-template-columns: 1fr; }
}

/* Alinea los controles (input/combobox) al FONDO de cada campo cuando un form se
   mantiene multi-columna (override inline de grid-template-columns) y algún label
   envuelve a 2 líneas: así los recuadros quedan en una sola línea aunque los labels
   midan distinto. Los campos igualan altura por el grid; el último hijo (input o .cmb)
   baja con margin-top:auto, conservando el gap mínimo de .field. Reutilizable. */
.fields-bottom .field > :last-child { margin-top: auto; }

/* =====================================================
   WSEARCH — buscador en vivo con lupa + botón ✕ para limpiar.
   Centralizado (antes vivía local en personal/nomina.html). Lo usan la pestaña
   Trabajadores de la nómina y la página Trabajadores; cualquier lista futura
   con búsqueda en vivo lo hereda. Markup: <div class="wsearch[ has-q]">
     <svg lupa/> <input id="..."/> <button class="wsearch-clear">✕</button>
   </div>. La clase .has-q (set por JS cuando hay texto) revela el ✕.
   ===================================================== */
.wsearch { position: relative; margin-bottom: 10px; }
.wsearch svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-soft); pointer-events: none; }
.wsearch input { width: 100%; font: inherit; font-size: 16px; font-weight: 600; color: var(--text); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 34px 10px 36px; }
.wsearch input::placeholder { color: var(--text-soft); font-weight: 500; }
.wsearch input:focus { outline: none; border-color: var(--border-hover); }
.wsearch .wsearch-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border: 0; background: transparent; color: var(--text-soft); font-size: 17px; line-height: 1; cursor: pointer; display: none; }
.wsearch.has-q .wsearch-clear { display: block; }

/* =====================================================
   AFEED — feed de actividad / historial (audit-feed.js)
   Usado por el botón "Actividad" de Trabajadores y por la página Usuarios.
   ===================================================== */
.af-sub { color: var(--text3); font-size: 13px; font-weight: 600; margin: -4px 0 12px; }
.af-loading, .af-empty { color: var(--text3); font-size: 14px; text-align: center; padding: 24px 8px; }
.af-item { border-left: 3px solid var(--border-strong); padding: 9px 0 9px 12px; margin-bottom: 4px; }
.af-item + .af-item { border-top: 1px solid var(--border); padding-top: 11px; }
.af-line { font-size: 14px; color: var(--text); line-height: 1.4; }
.af-line b { font-weight: 800; }
.af-worker { font-weight: 700; color: var(--text2); }
.af-create  { border-left-color: #16a34a; }   /* alta = verde */
.af-update  { border-left-color: var(--brand, #b45309); }  /* edición = ámbar */
.af-trash   { border-left-color: #b45309; }
.af-restore { border-left-color: #0e7490; }
.af-delete  { border-left-color: #dc2626; }   /* borrado = rojo */
.af-nav     { border-left-color: var(--text-soft); }   /* navegación (abrió pantalla) = gris neutro */
/* Encabezado de día en el timeline de actividad (panel SA) */
.af-day { font-size: 12px; font-weight: 800; color: var(--text3); letter-spacing: .02em; margin: 18px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.af-day:first-child { margin-top: 2px; }
.af-changes { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.af-changes li { font-size: 13px; color: var(--text2); }
.af-fld { font-weight: 700; color: var(--text3); }
.af-from { color: var(--text3); }
.af-arrow { color: var(--text-soft); }
.af-to { font-weight: 700; color: var(--text); }
.af-when { font-size: 12px; color: var(--text-soft); font-weight: 600; margin-top: 5px; }
.af-seed { font-size: 11px; font-weight: 700; color: var(--text-soft); background: var(--bg-soft); border-radius: 999px; padding: 1px 7px; }
/* Tarjeta de CLASIFICACIÓN del usuario (panel SA) — encabeza el timeline con el perfil de uso */
.af-profile { border: 1px solid var(--border); background: var(--bg-elev); border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 14px; }
.af-profile-h { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 9px; }
.af-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.af-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--text2); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; }
.af-chip svg { width: 13px; height: 13px; opacity: .85; }
.af-chip.app { color: var(--green-deep); background: #F0FBF4; border-color: rgba(21,128,61,.3); }
.af-chip.web { color: #1E40AF; background: #EFF4FF; border-color: rgba(37,99,235,.28); }
.af-prof-meta { font-size: 12px; color: var(--text-soft); font-weight: 600; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.af-prof-meta b { font-weight: 800; color: var(--text2); }
/* Contexto por visita (canal/dispositivo/OS/ubicación) bajo cada fila de navegación */
.af-ctx { display: flex; flex-wrap: wrap; gap: 3px 8px; margin-top: 5px; }
.af-ctx .c { font-size: 11px; font-weight: 700; color: var(--text-soft); display: inline-flex; align-items: center; }
.af-ctx .c + .c::before { content: "·"; margin-right: 8px; color: var(--border-strong); }
.af-ctx .c.app { color: var(--green-deep); }
.af-ctx .c.web { color: #1E40AF; }
/* Barra "Descargar PDF/TXT" del modal de actividad (centralizada, los 3 módulos) */
.af-export { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.af-export-lbl { font-size: 12px; font-weight: 700; color: var(--text3); }
.af-export .btn { width: auto; min-width: 0; padding: 6px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }

/* =====================================================
   BUTTONS — primarios amarillo Caterpillar, texto azul plano
   Acción visible incluso con pantalla sucia.
   ===================================================== */
.btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 12px 18px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  transition: all 0.12s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  min-height: 44px;            /* Apple HIG mínimo touch */
}
.btn:hover {
  background: var(--bg-soft);
  border-color: var(--border-hover);
}
.btn:active { transform: scale(0.98); }
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Primario — Amarillo Caterpillar con texto azul plano */
.btn-primary {
  background: var(--amber);
  color: var(--text);
  border-color: var(--amber);
  box-shadow: var(--shadow-amber);
}
.btn-primary:hover {
  background: var(--amber);
  border-color: var(--amber-deep);
  box-shadow: 0 6px 16px rgba(234, 179, 8, 0.4), 0 2px 4px rgba(234, 179, 8, 0.2);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 4px rgba(234, 179, 8, 0.25);
}

/* Naranja vial — alternativa de acción crítica */
.btn-orange {
  background: var(--orange);
  color: #FFFFFF;
  border-color: var(--orange);
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
}
.btn-orange:hover {
  background: #C2410C;
  border-color: #C2410C;
}

/* Verde — confirmaciones (aprobar, guardar) */
.btn-green {
  background: var(--green);
  color: #FFFFFF;
  border-color: var(--green);
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.25);
}
.btn-green:hover {
  background: var(--green-deep);
  border-color: var(--green-deep);
}

/* Rojo — acciones destructivas */
.btn-red {
  background: var(--bg-elev);
  color: var(--red);
  border-color: var(--red);
}
.btn-red:hover {
  background: var(--red-soft);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text2);
}
.btn-ghost:hover {
  background: var(--bg-soft);
  color: var(--text);
}

/* PDF (rojo) / Excel (verde) — exportación de reportes. Centralizado UNA vez:
   lo heredan Personal, Bitácora y futuros módulos (antes vivía inline en
   personal/reportes.html). Combinar con .btn: <button class="btn btn-pdf"> */
.btn-pdf { background: var(--red); color: #fff; }
.btn-pdf:hover { background: #b91c1c; }
.btn-xls { background: var(--green); color: #fff; }
.btn-xls:hover { background: #166534; }

/* Captura de foto con cámara directa: botón secundario «Elegir de la fototeca»
   bajo la zona de captura (la zona abre la cámara vía capture). Lo inyecta
   caja-photo.js y lo reusa Nómina (prueba de pago). */
.photo-lib-btn { margin-top: 8px; font-size: 12.5px; min-height: 38px; padding: 8px 14px; }
.photo-lib-btn svg { width: 16px; height: 16px; }

/* Botón flotante (FAB) — para "Añadir gasto rápido" en obra */
.btn-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--amber);
  border: 0;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(234, 179, 8, 0.4), 0 2px 6px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  transition: all 0.15s ease;
}
.btn-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(234, 179, 8, 0.5), 0 4px 8px rgba(0, 0, 0, 0.18);
}
.btn-fab:active { transform: scale(0.95); }

.ibtn {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text);
  user-select: none;
  transition: all 0.12s ease;
}
.ibtn:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

/* Volver al listado — chip gris frío (tinte navy del logo). Reusable en CUALQUIER vista
   de detalle (obras, nóminas, futuras). Definido aquí UNA vez = consistente + escalable;
   las páginas solo usan class="back-link", sin redefinir el estilo. */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;   /* es un chip-botón, no un enlace subrayado */
  background: #E7EBF1;
  border: 1px solid #CFD8E3;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 14px;
  padding: 9px 15px 9px 12px;
  border-radius: 100px;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s;
}
.back-link:hover { background: #DCE3EC; }
.back-link svg { width: 18px; height: 18px; }

/* =====================================================
   CARDS — blanco con border + shadow sutil
   ===================================================== */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}
.card-interactive {
  cursor: pointer;
}
.card-interactive:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Card con accent amarillo a la izquierda — para destacar */
.card-accent {
  border-left: 4px solid var(--amber);
}
.card-accent-red { border-left: 4px solid var(--red); }
.card-accent-green { border-left: 4px solid var(--green); }

.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 4px 8px;
  margin-top: 4px;
}

/* =====================================================
   ALERTS — semánticos por color
   ===================================================== */
.alert {
  padding: 14px 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.55;
  border: 1px solid;
}
.alert > * + * { margin-top: 6px; }
.alert-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.alert-msg {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.95;
}
.alert-red {
  background: var(--red-soft);
  border-color: rgba(220, 38, 38, 0.35);
  color: var(--red-deep);
}
.alert-green {
  background: var(--green-soft);
  border-color: rgba(21, 128, 61, 0.35);
  color: var(--green-deep);
}
.alert-amber {
  background: var(--amber-soft);
  border-color: rgba(234, 179, 8, 0.45);
  color: #854D0E;
}
.alert-blue {
  background: #DBEAFE;
  border-color: rgba(59, 130, 246, 0.35);
  color: #1E40AF;
}

/* =====================================================
   BADGES — para estado de factura, status de obra
   ===================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid;
}
.badge-amber { background: var(--amber-soft); color: #854D0E; border-color: rgba(234, 179, 8, 0.4); }
.badge-green { background: var(--green-soft); color: var(--green-deep); border-color: rgba(21, 128, 61, 0.3); }
.badge-red { background: var(--red-soft); color: var(--red-deep); border-color: rgba(220, 38, 38, 0.3); }
.badge-gray { background: var(--bg-soft); color: var(--text2); border-color: var(--border); }

/* =====================================================
   TOAST + LOADING + MODAL
   ===================================================== */
#toast {
  position: fixed;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);          /* Fondo azul plano para alto contraste */
  color: #FFFFFF;
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.25s ease;
  /* z-index 300: por encima de cualquier modal de página.
     - .modal-bg (ui.js global): z-index 80
     - .sa-modal-overlay (admin custom): z-index 200
     - .support-view-banner: z-index 150
     - .modal-bg--top (diálogos confirm/alert/prompt de ui.js): z-index 10000
       — único que queda sobre el toast; sus flujos disparan el toast DESPUÉS
       de cerrarse, así que no compiten.
     El toast es feedback de acción, debe ser SIEMPRE visible aunque
     haya modales abiertos (caso típico: guardar cuota en modal de empresa). */
  z-index: 300;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
  max-width: 88vw;
  text-align: center;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }
#toast.ok { background: var(--green); }

#loader {
  background: rgba(248, 250, 252, 0.92);
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
  z-index: 50;
}
#loader.show { display: flex; }
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 16px;
}
.modal-bg.show { display: flex; }
/* Capa superior para diálogos de confirmación/aviso/prompt de ui.js: pueden
   dispararse desde cualquier modal de página (sa-modal-overlay z-200, modal
   detalle usuarios z-9999 !important), así que deben ganar SIEMPRE. */
.modal-bg--top { z-index: 10000; }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 12px 20px;
  background: var(--bg-elev);
}
.modal-header.has-title { border-bottom: 0; padding-bottom: 4px; }
/* Cuando hay header con título, reducimos padding-top del body para que
   header y body se sientan unidos (antes había un border-bottom separándolos
   y el body abría con 20px de padding-top). */
.modal-header.has-title + .modal-body { padding-top: 12px; }
.modal-header-title { flex: 1; min-width: 0; }
.modal-header-title:empty { display: none; }
.modal-header-title h2,
.modal-header-title h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  text-transform: none;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  font: inherit;
  padding: 0;
  flex-shrink: 0;
}
.modal-close:hover, .modal-close:focus-visible {
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}
.modal-close svg { width: 18px; height: 18px; }
.modal-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 20px 24px 24px;
}

/* =====================================================
   VISOR DE FOTO (ui.js showPhoto) — único en toda la app
   Reemplaza los lightbox que cada página duplicaba.
   z-index 250: por encima de modales (80) y overlays admin (200),
   por debajo del loader (300).
   ===================================================== */
.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 250;
}
.photo-viewer.show { display: flex; }
.photo-viewer .pv-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  cursor: default;
}
.photo-viewer .pv-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(28, 25, 23, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: background 0.12s;
}
.photo-viewer .pv-close:hover,
.photo-viewer .pv-close:focus-visible {
  background: rgba(28, 25, 23, 0.85);
  outline: none;
}
.photo-viewer .pv-close svg { width: 20px; height: 20px; }

/* =====================================================
   FILA DE RESUMEN DE FILTRO (conteo + total)
   Compartida por las listas de Caja (facturas, ingresos)
   y disponible para futuras páginas con total filtrado.
   ===================================================== */
.filter-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
}
.filter-total-red {
  color: var(--red);
  font-family: var(--mono);
}
.filter-total-green {
  color: var(--green-deep);
  font-family: var(--mono);
}

/* =====================================================
   EMPTY STATE — componente unificado (F2.8)
   UN solo componente para TODA lista vacía de la app. Reemplaza las copias
   locales (.empty-state, .empty-card, .det-empty, .empty-section, .sa-empty,
   .detail-empty, .mod-count-none, texto plano inline…).
   Markup estándar (lo emite emptyState() en ui.js):
     <div class="empty-state [es--card|es--mini]">
       <div class="es-icon">🧾</div>            (emoji o <svg>)
       <div class="es-title">…</div>
       <div class="es-desc">…</div>
       <div class="es-actions"><a class="btn btn-primary">…</a></div>  (opcional)
   El gateo por rol lo decide cada página (pasa actions=[] si no hay permiso).
   ===================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r);
  padding: 44px 24px;
}
.empty-state .es-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 14px;
  color: var(--text-soft);
}
.empty-state .es-icon svg {
  width: 46px; height: 46px; display: block;
  color: var(--text-soft); stroke-width: 1.75;
}
.empty-state .es-title {
  margin: 0 0 6px;
  font-size: 16px; font-weight: 700;
  color: var(--text); letter-spacing: -0.01em; text-transform: none;
}
.empty-state .es-desc {
  margin: 0;
  font-size: 14px; font-weight: 500; line-height: 1.5;
  color: var(--text3); max-width: 420px;
}
.empty-state .es-actions {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  margin-top: 20px;
}
.empty-state .es-actions .btn { width: auto; min-width: 180px; }

/* --card: compacta — tiles del dashboard, detalle de obra, dentro de modales */
.empty-state.es--card { padding: 30px 20px; border-radius: var(--r-sm); }
.empty-state.es--card .es-icon { font-size: 34px; margin-bottom: 10px; }
.empty-state.es--card .es-icon svg { width: 38px; height: 38px; }
.empty-state.es--card .es-title { font-size: 15px; }
.empty-state.es--card .es-desc { font-size: 13px; }
.empty-state.es--card .es-actions { margin-top: 14px; }
.empty-state.es--card .es-actions .btn { min-width: 0; }

/* --mini: en línea — celda de tabla / sub-lista de modal / picker de filtro */
.empty-state.es--mini {
  flex-direction: row; gap: 9px; justify-content: center; align-items: center;
  padding: 16px 14px; border-radius: var(--r-sm);
}
.empty-state.es--mini .es-icon { font-size: 17px; margin: 0; }
.empty-state.es--mini .es-icon svg { width: 18px; height: 18px; }
.empty-state.es--mini .es-title { font-size: 13px; margin: 0; }
.empty-state.es--mini .es-desc { font-size: 12.5px; }
.empty-state.es--mini .es-actions { margin: 0; }

/* =====================================================
   UTILS
   ===================================================== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.center { text-align: center; }

/* Highlight para mostrar montos importantes en azul plano bold */
.amount {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.amount-lg { font-size: 24px; }
.amount-positive { color: var(--green); }
.amount-negative { color: var(--red); }
