/* =====================================================================
   BKB · Sistema de gestión — estilos con la identidad de empresabkb.cl
   (azul noche + naranjo salmón; Space Grotesk / IBM Plex Sans / IBM Plex Mono)
   ===================================================================== */
:root {
  --bg: #f1f5f9; --card: #fff; --text: #0f172a; --muted: #5b6778; --border: #e2e8f0; --border-2: #cbd5e1;
  /* marca BKB */
  --salmon: #fa5a36; --salmon-600: #e04825; --salmon-700: #c2410c; --salmon-300: #ffa580; --salmon-soft: #fff4ee;
  --noche-950: #05080e; --noche-900: #080c14; --noche-800: #0f172a; --noche-700: #162035;
  --pizarra-900: #1e293b; --pizarra-700: #334155; --pizarra-500: #64748b; --pizarra-100: #f1f5f9; --pizarra-50: #f8fafc;
  --azul-suave: #eef2f7; --azul-borde: #d7dee8; --azul-texto: #1e3a5f;
  --primary: var(--salmon); --primary-d: var(--salmon-600); --primary-bg: var(--salmon-soft);
  --ok: #1e6b47; --ok-bg: #e6f4ec; --warn: #b85d0a; --warn-bg: #fef3e6; --err: #a8271b; --err-bg: #fdeeed;
  /* colores de cada módulo (franja superior de las tarjetas) */
  --c-trab: #f59e0b; --c-cont: #10b981; --c-pago: #ef4444; --c-resp: #0ea5e9;
  --radio: 14px; --radio-s: 9px;
  --sombra: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 6px rgba(15, 23, 42, .05);
  --sombra-2: 0 10px 30px rgba(15, 23, 42, .14);
  --anillo: 0 0 0 3px rgba(250, 90, 54, .22);
  --fuente: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --titulos: "Space Grotesk", var(--fuente);
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--fuente); font-size: 14px; line-height: 1.5; background: var(--bg); color: var(--text); }
a { color: var(--salmon-700); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--salmon-600); }
.icono { flex: none; }

/* ------------------------------------------------------------ encabezado y menú */
.barra { position: sticky; top: 0; z-index: 50; background: #fff; border-bottom: 2px solid var(--salmon);
         box-shadow: 0 4px 14px rgba(15, 23, 42, .06); }
.barra-sup { display: flex; align-items: center; gap: 16px; padding: 10px 28px; color: var(--pizarra-900); }
.barra-marca, .barra-marca:hover { color: var(--pizarra-900); text-decoration: none; }
.barra-empresa { color: var(--pizarra-500); font: 500 12px var(--mono); letter-spacing: .06em; text-transform: uppercase;
                 padding-left: 16px; border-left: 1px solid var(--border); }
.spacer { flex: 1; }

.marca { display: inline-flex; align-items: center; gap: 12px; }
.marca-logo { width: 40px; height: 40px; border-radius: 50%; display: block; filter: drop-shadow(0 4px 12px rgba(250, 90, 54, .28)); }
.marca-texto { display: flex; flex-direction: column; line-height: 1.1; }
.marca-texto b { font: 700 19px var(--titulos); letter-spacing: .02em; }
.marca-texto small { font: 500 10.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--salmon-700); margin-top: 2px; }

.usuario { display: flex; align-items: center; gap: 10px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font: 600 12px var(--fuente);
          background: linear-gradient(135deg, var(--salmon), var(--salmon-700)); color: #fff; }
.usuario-nombre { font-size: 13px; font-weight: 600; color: var(--pizarra-900); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usuario form { margin: 0; }
.btn-salir { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; cursor: pointer;
             font: 600 13px var(--fuente); color: var(--pizarra-700); background: #fff; border: 1px solid var(--border-2); }
.btn-salir:hover { background: var(--err-bg); border-color: #f7c6c2; color: var(--err); }

.menu { display: flex; gap: 4px; padding: 0 22px; background: #fff; border-top: 1px solid var(--pizarra-100);
        overflow-x: auto; scrollbar-width: none; }
.menu::-webkit-scrollbar { display: none; }
.menu a { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 12px 12px 11px; white-space: nowrap;
          text-decoration: none; color: var(--pizarra-500); font-weight: 600; font-size: 13.5px; transition: color .15s, background .15s; }
.menu a::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; border-radius: 2px;
                 background: var(--salmon); transform: scaleX(0); transition: transform .2s; }
.menu a:hover { color: var(--pizarra-900); background: var(--pizarra-50); }
.menu a:hover::after { transform: scaleX(.5); }
.menu a.active, .menu a.active:hover { color: var(--salmon-700); background: transparent; }
.menu a.active::after { transform: scaleX(1); }

/* ------------------------------------------------------------ página */
main { padding: 28px; max-width: 1560px; margin: 0 auto; }
h1 { font: 700 26px var(--titulos); letter-spacing: -.01em; margin: 0 0 6px; }
h2 { font-family: var(--titulos); letter-spacing: -.005em; }
.sub { color: var(--muted); margin: 0 0 20px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radio); padding: 20px 22px; margin-bottom: 20px;
        box-shadow: var(--sombra); min-width: 0; overflow-x: auto; }
.card h2 { font-size: 17px; font-weight: 700; margin: 0 0 14px; }
/* sección dentro de una página (ej: Respaldos del trabajo) */
.titulo-seccion { font-size: 20px; font-weight: 700; margin: 30px 0 12px; }
#respaldos { scroll-margin-top: 130px; }
.fila-adjunto { margin-top: 14px; }
.fila-adjunto + .fila-adjunto { padding-top: 14px; border-top: 1px dashed var(--border); }
.mod-trab, .mod-cont, .mod-pago, .mod-resp { border-top-width: 3px; }
.mod-trab { border-top-color: var(--c-trab); }
.mod-cont { border-top-color: var(--c-cont); }
.mod-pago { border-top-color: var(--c-pago); }
.mod-resp { border-top-color: var(--c-resp); }

.flash { padding: 11px 14px; border-radius: var(--radio-s); margin-bottom: 12px; border: 1px solid transparent; border-left-width: 4px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: #c3e6d2; border-left-color: #10b981; }
.flash.warning { background: var(--warn-bg); color: var(--warn); border-color: #fbd6b0; border-left-color: #f59e0b; }
.flash.error { background: var(--err-bg); color: var(--err); border-color: #f7c6c2; border-left-color: #ef4444; }

/* ------------------------------------------------------------ botones (píldora, como el sitio) */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: 999px;
       border: 1px solid var(--salmon); background: var(--salmon); color: #fff; text-decoration: none; cursor: pointer;
       font: 600 14px var(--fuente); line-height: 1.2; box-shadow: 0 4px 14px rgba(250, 90, 54, .25); transition: background .15s, box-shadow .15s, transform .1s; }
.btn:hover { background: var(--salmon-600); border-color: var(--salmon-600); color: #fff; box-shadow: 0 6px 18px rgba(250, 90, 54, .32); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .btn-salir:focus-visible { outline: none; box-shadow: var(--anillo); }
.btn.sec { background: #fff; color: var(--text); border-color: var(--border-2); box-shadow: none; }
.btn.sec:hover { border-color: var(--salmon); color: var(--salmon-700); background: var(--salmon-soft); }
.btn.danger { background: #dc2626; border-color: #dc2626; box-shadow: 0 4px 12px rgba(220, 38, 38, .22); }
.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn.sm { padding: 5px 12px; font-size: 13px; box-shadow: none; }
.btn:disabled, fieldset:disabled .btn { opacity: .5; cursor: not-allowed; }

.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--azul-suave); border: 1px solid var(--azul-borde); border-radius: 999px; }
.tabs a { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13px; }
.tabs a:hover { color: var(--pizarra-900); background: rgba(255, 255, 255, .6); }
.tabs a.active, .tabs a.active:hover { background: #fff; color: var(--salmon-700); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.toolbar.tabs { display: flex; width: fit-content; max-width: 100%; }

/* ------------------------------------------------------------ formularios */
input[type=text], input[type=date], input[type=search], input[type=email], input[type=password], select, textarea {
  font: 14px var(--fuente); padding: 8px 11px; border: 1px solid var(--border-2); border-radius: var(--radio-s); width: 100%;
  background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s; margin: 0; }
/* todos los campos de una línea con la misma altura (texto, fecha, búsqueda y listas) */
input[type=text], input[type=date], input[type=search], input[type=email], input[type=password], select {
  height: 40px; padding-top: 0; padding-bottom: 0; line-height: 38px; vertical-align: middle; }
/* listas con la misma flecha en todos los navegadores */
select { -webkit-appearance: none; appearance: none; padding-right: 34px; cursor: pointer; text-overflow: ellipsis;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6778' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
input[type=date] { line-height: normal; }
input[type=date]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .6; }
textarea { line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: #94a3b8; }
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--salmon); box-shadow: var(--anillo); }
input[type=file] { font: 13px var(--fuente); }
.toolbar input, .toolbar select { width: auto; min-width: 200px; }
/* en las barras de filtros, botones a la misma altura que los campos */
.toolbar > .btn:not(.sm), .toolbar > a.btn:not(.sm) { height: 40px; padding-top: 0; padding-bottom: 0; }
.toolbar label { margin: 0; }
/* etiqueta + campo siempre juntos (no se separan al pasar a otra línea) */
.toolbar .par { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.toolbar .tabs { align-self: center; }
/* dentro de tablas y filas de edición: campos más bajos, a la altura de los botones pequeños */
td input[type=text], td input[type=password], td select { height: 34px; line-height: 32px; font-size: 13px; }
.btn.sm { height: 32px; padding-top: 0; padding-bottom: 0; }
td form .field label { white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.grid .wide { grid-column: span 2; }
label { display: block; font: 600 11px var(--mono); letter-spacing: .05em; text-transform: uppercase; color: #475569; margin-bottom: 6px; }
/* etiqueta en una sola línea: así los campos de una misma fila quedan alineados */
.grid .field label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid { align-items: start; }
.field.err input, .field.err select, .field.err textarea { border-color: #ef4444; background: #fff8f7; }
.field .msg { color: var(--err); font-size: 12px; margin-top: 4px; }
.field.next input { border-color: #f59e0b; background: #fffbeb; box-shadow: 0 0 0 3px rgba(245, 158, 11, .15); }
input.sugerido { background: #fffbeb; border-color: #f59e0b; font-style: italic; }
fieldset { border: 1px solid var(--border); border-radius: var(--radio); padding: 14px 18px 18px; margin: 0 0 16px; }
legend { font: 700 15px var(--titulos); padding: 0 8px; color: var(--text); }
legend .muted { font-family: var(--fuente); }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ------------------------------------------------------------ tablas */
/* barra horizontal y vertical dentro de la tabla: el encabezado y los totales quedan a la vista al desplazarse */
.tbl-wrap { overflow: auto; max-height: max(320px, calc(100vh - 340px)); border: 1px solid var(--border); border-radius: 12px;
            scrollbar-width: auto; scrollbar-color: #94a3b8 #eef2f7; }
.tbl-wrap::-webkit-scrollbar { width: 12px; height: 12px; }
.tbl-wrap::-webkit-scrollbar-track { background: #eef2f7; }
.tbl-wrap::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 8px; border: 2px solid #eef2f7; }
.tbl-wrap::-webkit-scrollbar-thumb:hover { background: #64748b; }
.tbl-wrap::-webkit-scrollbar-corner { background: #eef2f7; }
.tbl-wrap thead th { z-index: 2; }
.tbl-wrap tfoot td { position: sticky; bottom: 0; z-index: 2; }
/* etiqueta de empresa según el estado de facturación del trabajo */
.badge.empresa.sem-rojo { background: var(--err); border-color: var(--err); color: #fff; }
.badge.empresa.sem-amarillo { background: #facc15; border-color: #eab308; color: #422006; }
.badge.empresa.sem-azul { background: #2563eb; border-color: #1d4ed8; color: #fff; }
.badge.empresa.sem-verde { background: var(--ok); border-color: var(--ok); color: #fff; }
.badge.empresa.sem-parpadea { animation: parpadeo 1s steps(2, jump-none) infinite; }
@keyframes parpadeo { to { opacity: .2; } }
@media (prefers-reduced-motion: reduce) {
  .badge.empresa.sem-parpadea { animation: none; outline: 2px solid var(--err); outline-offset: 2px; }
  .badge.empresa.sem-parpadea::before { content: "⚠ "; }
}
.filtro-tabla { margin: 12px 0 10px; }
.btn-atras { margin-bottom: 10px; }
/* trabajo pagado por completo: fila verde */
tbody tr.pagado td { background: #bbf0cc; }
tbody tr.pagado:hover td { background: #a3e8b9; }
tbody tr.pagado td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
/* Exportar HES: vista de la tabla tal como se pegará en el correo */
.vista-correo { background: #fff; border: 1px dashed var(--border-2); border-radius: 10px; padding: 16px; overflow-x: auto; margin: 6px 0 14px; }
/* contadores de trabajos parpadeando por empresa (lista de Trabajos) */
.contador-parpadeo { font-size: 12px; padding: 5px 10px; text-decoration: none; }
/* botón de orden: muestra la Cot más alta; al pasar el mouse (o tocarlo) aparecen las opciones */
.orden-menu { position: relative; outline: none; }
.orden-boton { height: 40px; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; cursor: default; font-size: 13px; padding: 0 12px; }
.orden-opciones { display: none; position: absolute; right: 0; top: 100%; z-index: 30; min-width: 220px; padding: 6px;
                  background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 30px rgba(15, 23, 42, .15); }
.orden-menu:hover .orden-opciones, .orden-menu:focus-within .orden-opciones { display: block; }
.orden-titulo { display: block; padding: 4px 10px 6px; font: 600 10.5px var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.orden-opciones a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 13.5px; }
.orden-opciones a:hover { background: var(--pizarra-50); }
.orden-opciones a.activo { color: var(--salmon-700); font-weight: 700; }
.orden-opciones a.activo::before { content: "✓ "; }
.cabecera-pagina { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cot-clientes { display: flex; gap: 12px; flex-wrap: wrap; }
.cot-cliente { display: flex; flex-direction: column; align-items: flex-end; padding: 8px 16px; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .06); }
.cot-cliente span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.cot-cliente b { font: 700 22px var(--titulos); line-height: 1.2; }
@media (max-width: 760px) { .cot-clientes { width: 100%; } .cot-cliente { flex: 1; align-items: flex-start; } }
.contador-parpadeo.activo { outline: 2px solid var(--pizarra-900); outline-offset: 2px; }
/* Notas */
.campos-nota { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 2fr); }
.campos-nota textarea { min-height: 96px; }
.btn.nota-sino, .badge.nota-sino { min-width: 48px; justify-content: center; font-weight: 800; color: #fff; border: 0; }
.nota-sino.no { background: var(--err); }
.nota-sino.si { background: var(--ok); }
.nota-texto { min-width: 320px; white-space: pre-wrap; }
tbody tr.nota-hecha td { color: var(--muted); }
.nota-archivos { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; text-decoration: none; }
.subir-nota { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.nota-rapida-pagina { background: var(--bg); min-height: 100vh; }
.nota-rapida-barra { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #fff; border-bottom: 2px solid var(--salmon-700, #c2410c); }
.nota-rapida-usuario { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50vw; }
.nota-rapida { max-width: 640px; margin: 0 auto; padding: 16px; }
.nota-rapida h1 { margin: 4px 0 12px; }
.nota-rapida .card { display: flex; flex-direction: column; gap: 14px; }
.nota-rapida input, .nota-rapida select, .nota-rapida textarea { font-size: 16px; }   /* 16px: el celular no hace zoom al escribir */
.nota-rapida textarea { min-height: 150px; }
.nota-rapida-guardar { width: 100%; justify-content: center; padding: 14px; font-size: 17px; }
.nota-estado { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (max-width: 760px) { .campos-nota { grid-template-columns: minmax(0, 1fr); } }
/* paginación: 15 registros por página */
.paginacion { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 10px; }
.paginacion .muted { margin-right: auto; font-size: 13px; }
.paginacion .muted + .btn, .paginacion .btn + .muted { margin-right: 0; }
.paginacion .btn { min-width: 36px; }
.paginacion .btn[disabled] { opacity: .45; cursor: default; }
table { border-collapse: separate; border-spacing: 0; width: 100%; background: #fff; }
th, td { padding: 10px 12px; border-bottom: 1px solid #edf1f6; text-align: left; white-space: nowrap; vertical-align: middle; }
th { background: #f8fafc; font: 600 11px var(--mono); color: #475569; text-transform: uppercase; letter-spacing: .05em;
     position: sticky; top: 0; border-bottom-color: var(--border); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 220px; }
tbody tr:hover td { background: #fff8f4; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; background: #f8fafc; border-top: 1px solid var(--border); border-bottom: 0; }
.card > table { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
/* columnas fijas a la derecha (montos clave + botón), siempre visibles aunque la tabla sea ancha */
table .fx { position: sticky; background: #fff; box-sizing: border-box; }
tbody tr:hover td.fx { background: #fff8f4; }
table thead .fx { background: #f8fafc; z-index: 3 !important; }
table tfoot .fx { background: #f8fafc; z-index: 3 !important; }
table tbody .fx { z-index: 1; }
table .fx1 { right: 0; width: 190px; min-width: 190px; }
table .fx2 { right: 190px; width: 140px; min-width: 140px; }
table .fx3 { right: 330px; width: 130px; min-width: 130px; box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .25); }
.fx1.accion { white-space: normal; box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .25); }
td.fx1.accion .alerta { margin-top: 4px; line-height: 1.3; }
table .fx-editar { right: 0; box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .25); }

/* ------------------------------------------------------------ etiquetas */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
         line-height: 1.6; background: #f1f5f9; color: #334155; white-space: nowrap; }
.e1, .e2, .e3 { background: #ebf3f9; color: #1b5887; }
.e4, .e5 { background: #ede9fe; color: #5b21b6; }
.e6, .e7 { background: var(--salmon-soft); color: var(--salmon-700); }
.e8, .e9 { background: var(--warn-bg); color: var(--warn); }
.e10, .CANCELADO { background: var(--ok-bg); color: var(--ok); }
.PENDIENTE { background: var(--err-bg); color: var(--err); }
.ABONO { background: var(--warn-bg); color: var(--warn); }
/* cotización sin valor: PENDIENTE llamativo */
.badge.pendiente-cot { background: var(--err); color: #fff; font-weight: 800; letter-spacing: .06em;
                       box-shadow: 0 0 0 3px rgba(168, 39, 27, .18); animation: pendiente-latido 1.6s ease-in-out infinite; }
label .badge.pendiente-cot { font-size: 10.5px; padding: 0 8px; margin-left: 4px; vertical-align: middle; }
@keyframes pendiente-latido { 50% { box-shadow: 0 0 0 6px rgba(168, 39, 27, .05); } }
@media (prefers-reduced-motion: reduce) { .badge.pendiente-cot { animation: none; } }
.alerta { color: var(--err); font-size: 12px; }
.rol-admin { background: var(--salmon-soft); color: var(--salmon-700); }
tbody tr.monitor-alerta td { background: #fff5f5; }
.badge.monitor-ok { background: #dcfce7; color: #166534; }
.badge.monitor-fallo { background: #fee2e2; color: #991b1b; }
.badge.monitor-info { background: #e2e8f0; color: #334155; }
td.mono { font-family: var(--mono, "IBM Plex Mono", monospace); font-size: 12px; }
.rol-super { background: var(--salmon-700); color: #fff; }
.badge.empresa { background: var(--azul-suave); color: var(--azul-texto); border: 1px solid var(--azul-borde); font-weight: 600; }
.toolbar .filtro-empresa { border-color: var(--salmon-300); font-weight: 600; }
.falta { color: var(--err); font-weight: 600; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------ resumen */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radio); padding: 14px 16px; box-shadow: var(--sombra); }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font: 700 20px var(--titulos); margin-top: 4px; }
.kpi.bad .v { color: var(--err); }
.bloques { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-bottom: 20px; }
/* resumen: 4 bloques por fila y el de gastos y cajas abajo a lo ancho */
.bloques.tarjetas { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 0; }
@media (max-width: 1150px) { .bloques.tarjetas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .bloques.tarjetas { grid-template-columns: minmax(0, 1fr); } }
.bloque { background: #fff; border: 1px solid var(--border); border-radius: var(--radio); overflow: hidden; box-shadow: var(--sombra); min-width: 0; }
.bloque .bt { font: 600 11.5px var(--mono); letter-spacing: .08em; padding: 11px 16px; color: #1e293b; }
.bloque .bc { font-size: 12px; color: var(--muted); padding: 8px 16px 0; }
.bloque table { background: transparent; }
.bloque table td { border: 0; padding: 6px 16px; white-space: normal; }
.bloque table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bloque tbody tr:hover td { background: transparent; }
.bloque.b-ga { grid-column: 1 / -1; }
.bloque.b-ga .cuerpo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 24px; align-items: start; }
@media (max-width: 760px) { .bloque.b-ga .cuerpo { grid-template-columns: 1fr; } }
.bloque form.cajas { display: flex; gap: 10px; align-items: flex-end; padding: 10px 16px 16px; flex-wrap: wrap; }
.bloque form.cajas .field { flex: 1; min-width: 130px; }
.bloque form.cajas input { text-align: right; }
/* botón "Flujo de caja": suma de las cajas de las empresas */
.flujo-caja { padding: 0 16px 16px; }
.flujo-resultado { margin-top: 10px; border: 1px solid #c3e6d2; background: var(--ok-bg); border-radius: 10px; overflow: hidden; }
.flujo-resultado table { background: transparent; }
.flujo-resultado td { padding: 7px 14px; border: 0; }
.flujo-resultado tr.tot td { font: 700 17px var(--titulos); color: var(--ok); border-top: 1px solid #c3e6d2; }
.bloque tr.tot td { font: 700 17px var(--titulos); border-top: 1px solid var(--border); padding-top: 10px; padding-bottom: 10px; }
.bloque tr.tot td span { font-family: var(--fuente); }
.bloque tr.neg td { color: var(--err); }
.bloque tr.caja td { color: var(--ok); background: var(--ok-bg); }
.bloque tr.proy td { color: var(--pizarra-900); background: var(--salmon-soft); border-top: 1px solid #fbd9cb; }
.bloque tr.proy td:last-child { color: var(--salmon-700); }
.bloque tr.tot + tr.tot td { border-top: 0; }
.b-xf .bt { background: #fef3c7; border-bottom: 1px solid #fde68a; }
.b-fa .bt { background: #e6f4ec; border-bottom: 1px solid #c3e6d2; }
.b-pa .bt { background: #fdeeed; border-bottom: 1px solid #f7c6c2; }
.b-to .bt { background: #f1f5f9; border-bottom: 1px solid var(--border); }
.b-ga .bt { background: var(--azul-suave); color: var(--azul-texto); border-bottom: 2px solid var(--salmon); }
/* secciones del resumen que se ocultan con la flecha */
details.bloque > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; }
details.bloque > summary::-webkit-details-marker { display: none; }
details.bloque > summary::before { content: "›"; font-size: 18px; line-height: 1; color: var(--salmon); transition: transform .15s; }
details.bloque[open] > summary::before { transform: rotate(90deg); }
details.bloque > summary:hover { filter: brightness(.97); }
details.bloque:not([open]) > summary { border-bottom-color: transparent; }
/* las 4 tarjetas de arriba se ocultan juntas con una sola flecha */
.grupo-tarjetas { margin-bottom: 20px; }
.grupo-tarjetas > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: #fff; border: 1px solid var(--border); border-radius: var(--radio); box-shadow: var(--sombra);
  font: 700 15px var(--titulos); color: var(--text); user-select: none; }
.grupo-tarjetas > summary .muted { font: 500 12px var(--fuente); }
.grupo-tarjetas > summary::-webkit-details-marker { display: none; }
.grupo-tarjetas > summary::before { content: "›"; font-size: 20px; line-height: 1; color: var(--salmon); transition: transform .15s; }
.grupo-tarjetas[open] > summary::before { transform: rotate(90deg); }
.grupo-tarjetas[open] > summary { margin-bottom: 14px; }
.grupo-tarjetas > summary:hover { background: var(--pizarra-50); }
/* el ajuste de gastos y cajas queda aparte, a lo ancho */
details.bloque.b-ga { margin-bottom: 20px; }
details.card > summary h2 { display: inline; margin: 0; }
details.card > summary { cursor: pointer; font-size: 15px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "›"; display: inline-block; font-size: 20px; line-height: 1; color: var(--salmon); transition: transform .15s; }
details.card[open] > summary::before { transform: rotate(90deg); }
details.card[open] > summary { margin-bottom: 14px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cols > * { min-width: 0; }
.cols > .card { margin-bottom: 20px; }
@media (max-width: 960px) { .cols { grid-template-columns: 1fr; } .grid .wide { grid-column: span 1; } }
.bar { height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--salmon-300), var(--salmon)); }
.bar.p { background: linear-gradient(90deg, #94a3b8, var(--pizarra-700)); }
.resumen-fact { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.resumen-fact div { min-width: 150px; padding: 10px 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 12px;
                    font: 600 10.5px var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.resumen-fact b { display: block; font: 700 18px var(--titulos); letter-spacing: 0; text-transform: none; color: var(--text);
                  margin-top: 3px; font-variant-numeric: tabular-nums; }
.resumen-fact b.falta { color: var(--err); }
pre { font: 12.5px var(--mono); }

/* ------------------------------------------------------------ previsualizador de adjuntos (pestaña aparte) */
.visor { position: fixed; inset: 0; z-index: 100; background: var(--noche-950); display: flex; flex-direction: column; }
.visor[hidden] { display: none; }
.visor-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: #fff; flex-wrap: wrap; border-bottom: 2px solid var(--salmon); background: var(--noche-900); }
.visor-top .spacer { flex: 1; }
.visor-top .badge { color: var(--text); }
.visor-trabajo { color: #94a3b8; font: 500 12px var(--mono); }
.visor-nota { color: #cbd5e1; }
.visor-cuerpo { flex: 1; min-height: 0; display: flex; align-items: center; gap: 12px; padding: 12px; }
.visor-contenido { flex: 1; height: 100%; min-width: 0; display: flex; align-items: center; justify-content: center; }
.visor-contenido img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; border-radius: 6px; box-shadow: var(--sombra-2); }
.visor-contenido iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 8px; }
.visor-sin { background: #fff; padding: 28px 32px; border-radius: var(--radio); text-align: center; }
.visor-flecha { flex: none; width: 52px; height: 52px; border-radius: 50%; border: 1px solid rgba(250, 90, 54, .5); cursor: pointer;
                background: rgba(255, 255, 255, .05); color: #fff; font-size: 32px; line-height: 1; transition: background .15s; }
.visor-flecha:hover { background: var(--salmon); }
.visor-flecha:disabled { opacity: .25; cursor: default; background: transparent; }

/* ------------------------------------------------------------ ingreso */
.pagina-login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
                background: radial-gradient(900px 520px at 85% 15%, rgba(250, 90, 54, .10) 0%, transparent 60%),
                            radial-gradient(700px 500px at 5% 100%, rgba(30, 58, 95, .10) 0%, transparent 70%), var(--pizarra-100); }
.login-marco { display: grid; grid-template-columns: 1.05fr 1fr; width: 100%; max-width: 940px; background: #fff;
               border-radius: 20px; overflow: hidden; box-shadow: 0 24px 60px rgba(15, 23, 42, .16); }
.login-panel { display: flex; flex-direction: column; justify-content: space-between; gap: 28px; padding: 40px; color: #cbd5e1;
               background: radial-gradient(500px 300px at 50% 0%, rgba(250, 90, 54, .18), transparent 70%),
                           linear-gradient(170deg, #2b4466, var(--azul-texto) 75%); border-right: 2px solid var(--salmon); }
.login-logo { width: 180px; height: 180px; align-self: center; filter: drop-shadow(0 12px 40px rgba(250, 90, 54, .3)); }
.etiqueta { display: inline-block; font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--salmon-300);
            border: 1px solid rgba(250, 90, 54, .45); background: rgba(250, 90, 54, .1); border-radius: 999px; padding: 4px 12px; margin-bottom: 14px; }
.login-panel h2 { color: #fff; font: 700 27px/1.2 var(--titulos); margin: 0 0 18px; }
.login-panel h2 em { font-style: normal; color: var(--salmon); }
.login-panel ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 11px; }
.login-panel li { display: flex; gap: 10px; align-items: flex-start; }
.login-panel li .icono { color: var(--salmon); margin-top: 3px; }
.login-panel small { color: #7d8aa0; font: 500 11px var(--mono); letter-spacing: .05em; }
.login-form { padding: 48px 42px; display: flex; flex-direction: column; justify-content: center; }
.login-form h1 { font-size: 30px; }
.login-form .field { margin-bottom: 16px; }
.login-form input { height: 46px; padding: 0 14px; font-size: 15px; }
.btn-grande { width: 100%; padding: 13px 18px; font-size: 15px; margin-top: 6px; }
.login-solo-movil { display: none; margin-bottom: 18px; }
.login-solo-movil .marca-texto b { color: var(--text); }
.login-solo-movil .marca-texto small { color: var(--salmon-700); }

/* ------------------------------------------------------------ pantallas chicas */
@media (max-width: 760px) {
  main { padding: 16px; }
  h1 { font-size: 21px; }
  .barra-sup { padding: 9px 14px; }
  .barra-empresa, .usuario-nombre, .btn-salir span { display: none; }
  .menu { padding: 0 6px; }
  .menu a { padding: 11px 10px 10px; }
  .card { padding: 14px; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 160px; }
  .login-marco { grid-template-columns: 1fr; max-width: 420px; }
  .login-panel { display: none; }
  .login-form { padding: 32px 24px; }
  .login-solo-movil { display: block; }
}

/* ------------------------------------------------------------ celular: tablas como tarjetas */
@media (max-width: 760px) {
  main { padding: 12px; }
  .card { padding: 14px 12px; border-radius: 14px; }
  /* la tabla ocupa el largo de la página (sin caja con barras propias) */
  .tbl-wrap { max-height: none; overflow: visible; border: 0; border-radius: 0; }
  table.apilable, table.apilable tbody, table.apilable tfoot { display: block; width: 100%; background: transparent; }
  table.apilable thead { display: none; }
  table.apilable tr { display: block; background: #fff; border: 1px solid var(--border); border-radius: 12px;
                      padding: 4px 12px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
  table.apilable tr[hidden] { display: none; }
  table.apilable tr.pagado { background: #bbf0cc; border-color: var(--ok); }
  table.apilable td { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right;
                      white-space: normal; padding: 8px 0; border-bottom: 1px dashed #e6ebf2; min-width: 0;
                      position: static !important; width: auto !important; min-width: 0 !important; box-shadow: none !important;
                      background: transparent !important; }
  table.apilable td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font: 600 10.5px var(--mono);
                              letter-spacing: .05em; text-transform: uppercase; color: #64748b; }
  table.apilable td:not([data-label])::before { content: none; }
  table.apilable td:not([data-label]) { justify-content: flex-start; text-align: left; }
  table.apilable td:last-child { border-bottom: 0; }
  table.apilable td:empty { display: none; }
  table.apilable td.wrap { min-width: 0; }
  /* nada más ancho que la tarjeta: textos y etiquetas largas bajan de línea, los botones pasan a la línea siguiente */
  table.apilable td > * { max-width: 100%; min-width: 0; overflow-wrap: anywhere; }
  table.apilable td[data-label] > * { max-width: 62%; }
  table.apilable td .badge { white-space: normal; text-align: right; line-height: 1.35; }
  table.apilable td:not([data-label]) { flex-wrap: wrap; gap: 6px; }
  table.apilable td > form, table.apilable td > div { justify-content: flex-end; flex-wrap: wrap; }
  table.apilable td[colspan] { justify-content: flex-start; }
  table.apilable tfoot tr { background: #f8fafc; }
  table.apilable tfoot td { font-weight: 700; }
  tbody tr:hover td { background: transparent; }
  /* acciones de cada fila (Editar, Previsualizar…) a lo ancho */
  table.apilable td.fx1, table.apilable td.fx-editar { justify-content: flex-end; flex-wrap: wrap; }
  .paginacion { justify-content: center; }
  .paginacion .muted:first-child { flex-basis: 100%; text-align: center; margin: 0 0 4px; }
  /* ficha del trabajo: título y dato uno debajo del otro, en dos columnas */
  table.ficha, table.ficha tbody { display: block; }
  table.ficha tr { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 60%); }
  table.ficha th, table.ficha td { white-space: normal; word-break: break-word; }
  /* textos largos y botones en pantallas angostas */
  .toolbar > .btn, .toolbar > a.btn { flex: 1 1 auto; justify-content: center; }
  .tabs { flex-wrap: wrap; }
  .resumen-fact div { min-width: calc(50% - 6px); flex: 1 1 calc(50% - 6px); }
  .resumen-fact b { font-size: 16px; }
  h2 { font-size: 16px; }
  .titulo-seccion { font-size: 18px; margin-top: 22px; }
}
