/* Modo oscuro de M2: grafito cálido, suave a la vista. Se activa con html[data-theme="oscuro"].
   Capas (de más oscura a más clara): menú #171615 · fondo #1f1e1c · tarjetas #282624 · encabezados y hover #312f2c.
   Texto arena grisáceo #bbb3a8 (contraste 7:1, sin brillo), secundario #969087. Acento de marca: arena aclarada #c9b59c para que contraste.
   Botones: bronce cálido #655544 con texto marfil suave #e0d8ce (nunca blancos). */

/* Elementos restringidos por rol (el portero los muestra) */
[data-rol][hidden]{display:none!important}

/* Cobranza: el botón de menú plegable ya no se usa (el menú siempre está abierto); su estilo lo mostraba como un cuadro negro */
#cobranza-menu-toggle[hidden]{display:none!important}

/* Interruptor en el menú (visible en ambos modos) */
#m2-tema{margin-top:auto;display:flex;align-items:center;gap:10px;width:100%;padding:10px;background:none;border:0;border-top:1px solid #24211f;color:#8a8178;font:300 13.5px Jost,"Helvetica Neue",Arial,sans-serif;letter-spacing:.02em;cursor:pointer;text-align:left}
#m2-tema:hover{color:#fff}
#m2-tema:focus-visible{outline:1px solid #9d8b77;outline-offset:2px}
#m2-tema + #m2-sesion{margin-top:0!important}
@media(max-width:760px){#m2-tema{width:auto;margin:0 0 0 auto;padding:8px;border:0}#m2-tema span{display:none}#m2-tema + #m2-sesion{margin-left:0!important}}

/* Paleta */
html[data-theme="oscuro"]{
  --negro:#bbb3a8; --beige:#3d3833; --arena:#c9b59c; --blanco:#282624; --fondo:#1f1e1c;
  --gris:#969087; --oxford:#aaa298; --linea:#3b3835; --tenue:#2f2d2a; --reticula:#423e3a;
  --azul:#86a6cf; --verde:#9cc493; --rojo:#e0948a; --naranja:#d9ae68;
  color-scheme:dark; background:#1f1e1c!important; color:#bbb3a8!important;
}
html[data-theme="oscuro"] body{background:#1f1e1c;color:#bbb3a8;-webkit-font-smoothing:antialiased}

/* Menú lateral: un tono más profundo que el fondo, sin llegar a negro */
html[data-theme="oscuro"] .menu,html[data-theme="oscuro"] #cobranza-menu{background:#171615!important}
html[data-theme="oscuro"] .menu a[aria-current="page"],html[data-theme="oscuro"] #cobranza-menu .menu-sub a[aria-current]{background:#262422!important;box-shadow:inset 2px 0 0 #c9b59c!important}
html[data-theme="oscuro"] #m2-sesion,html[data-theme="oscuro"] #m2-tema{border-top-color:#2b2927}

/* Menú: sin blanco puro */
html[data-theme="oscuro"] .menu,html[data-theme="oscuro"] #cobranza-menu{color:#a39b91!important}
html[data-theme="oscuro"] body :is(.menu a:hover,.menu a[aria-current="page"],#cobranza-menu a:hover,#cobranza-menu .menu-actual,#cobranza-menu .menu-sub a[aria-current],#cobranza-menu .menu-modulos a:hover,.m2-sesion-nombre,#m2-tema:hover,.m2-sesion-salir:hover){color:#c9c1b6!important}
html[data-theme="oscuro"] body .m2-sesion-salir{color:#a39b91!important;border-color:#3b3835!important}

/* Inicio: asistente */
html[data-theme="oscuro"] .enviar{background:#655544;color:#e0d8ce}
html[data-theme="oscuro"] .enviar:hover:not(:disabled){background:#715f4c}
html[data-theme="oscuro"] .barra{box-shadow:0 4px 24px rgba(0,0,0,.25)}
html[data-theme="oscuro"] .barra:focus-within{border-color:#4e4945;box-shadow:0 6px 28px rgba(0,0,0,.3)}
html[data-theme="oscuro"] .nota,html[data-theme="oscuro"] .barra-pie span{color:#8a837c}
/* Texto guía de la barra ("¿En qué te puedo ayudar?"): más claro que la caja para que se lea, sin llegar al tono del texto escrito */
html[data-theme="oscuro"] .barra textarea::placeholder{color:#a39b91;opacity:1}
html[data-theme="oscuro"] .sugerencias button:hover{border-color:#4e4945}
html[data-theme="oscuro"] .msg.usuario{background:#36322e}
html[data-theme="oscuro"] .msg.error{background:#3a2724;color:#e0aaa0}

/* Contratos */
html[data-theme="oscuro"] tbody tr:hover td{background:#312f2c}
html[data-theme="oscuro"] .proyecto:hover .nombre{color:#c4b7a4}
html[data-theme="oscuro"] .imagen{background:#312f2c}
html[data-theme="oscuro"] .imagen svg,html[data-theme="oscuro"] .imagen img{filter:brightness(.85) contrast(1.02)}
html[data-theme="oscuro"] .pista{background:#3a3632}
html[data-theme="oscuro"] .pista i{background:#c9b59c}
html[data-theme="oscuro"] .prueba{background:#3a3632;color:#c4b7a4}
html[data-theme="oscuro"] .signo,html[data-theme="oscuro"] .nota,html[data-theme="oscuro"] .datos-proyecto .ultimo{color:#8a837c}

/* Cobranza (la página tiene colores fijos, por eso los ajustes llevan !important) */
html[data-theme="oscuro"] main{color:#bbb3a8!important}
html[data-theme="oscuro"] main :where(h1,h2,h3,h4,h5,td,dd,label,li,summary,strong,b,legend,caption,output,a):not([class*="pill"]):not([class*="tag"]):not([class*="status"]):not([class*="bad"]):not([class*="warn"]){color:inherit!important}
html[data-theme="oscuro"] main :where(p,small,.note,th,dt){color:#969087!important}
html[data-theme="oscuro"] #page-title{color:#bbb3a8!important}
html[data-theme="oscuro"] :is(.card,.project-link,#accounts,#account-card,.condition-card,#legal-metrics .card){background:#282624!important;border-color:#3b3835!important}
html[data-theme="oscuro"] dialog{background:#282624!important;color:#bbb3a8!important;border-color:#3b3835!important}
html[data-theme="oscuro"] dialog::backdrop{background:rgba(10,9,8,.55)}
html[data-theme="oscuro"] :is(main,dialog) :is(input,select,textarea){background:#1f1e1c!important;color:#bbb3a8!important;border-color:#423e3a!important}
html[data-theme="oscuro"] #search{background:#282624!important;border-color:#3b3835!important;box-shadow:0 4px 18px rgba(0,0,0,.2)!important}
html[data-theme="oscuro"] td{border-bottom-color:#2f2d2a!important}
html[data-theme="oscuro"] :is(#projects thead th,.portfolio-project-detail th,#legal-table th,#legal-upcoming th){background:#171615!important;color:#c4b7a4!important}
html[data-theme="oscuro"] #projects thead th{background:transparent!important;color:#969087!important;border-bottom-color:#3b3835!important}
html[data-theme="oscuro"] #projects tbody tr:hover td{background:#312f2c!important}
html[data-theme="oscuro"] #projects tbody td:last-child{background:#2b2927!important}
html[data-theme="oscuro"] #projects tbody tr:hover td:last-child{background:#36332f!important}
html[data-theme="oscuro"] #projects .account-money span:first-child{color:#8a837c}
html[data-theme="oscuro"] #account-projects{border-top-color:#3b3835!important}
html[data-theme="oscuro"] #account-projects .project-link{background:transparent!important;border-bottom-color:#3b3835!important}
html[data-theme="oscuro"] #account-projects .project-link:hover{background:#312f2c!important}
html[data-theme="oscuro"] #account-project-summary:not([hidden]){background:#312f2c!important}
html[data-theme="oscuro"] .project-link-metrics dt{color:#969087!important}
html[data-theme="oscuro"] .project-link-metrics dd{color:#bbb3a8!important}
html[data-theme="oscuro"] #accounts th{background:#2b2927!important;color:#969087!important}
html[data-theme="oscuro"] :is(#accounts td:nth-child(2),#accounts thead tr:nth-child(2) th:nth-child(2),#accounts tbody td:first-child,#accounts thead tr:nth-child(2) th:first-child){background:#2d2b28!important;box-shadow:1px 0 #3b3835!important}
html[data-theme="oscuro"] :is(#accounts tfoot td,#accounts tfoot td:first-child,#accounts tfoot td:nth-child(2)){background:#312f2c!important}
html[data-theme="oscuro"] #accounts .account-open-row:hover td{background-color:#312f2c!important}
html[data-theme="oscuro"] #accounts .account-open-row:hover td:nth-child(-n+2){background-color:#36332f!important}
html[data-theme="oscuro"] .account-card-top{background:#171615!important}
html[data-theme="oscuro"] .account-card-toolbar{border-bottom-color:#3b3835!important}
html[data-theme="oscuro"] .condition-tag{background:#3a3632!important;color:#c4b7a4!important}
html[data-theme="oscuro"] .condition-table :is(th,td):first-child{background:#2d2b28!important;box-shadow:1px 0 #3b3835!important}
html[data-theme="oscuro"] .condition-table :is(th,td):is(:nth-child(4),:nth-child(5)){background:#2b2927!important;color:#b3aba1!important}
html[data-theme="oscuro"] .condition-table :is(th,td):nth-child(6){background:#312f2c!important;color:#bbb3a8!important}
html[data-theme="oscuro"] :is(#account-export,#account-card-export,#figures-download,.figures-preview-toolbar button,#figures-email){background:#282624!important;border-color:#423e3a!important;color:#bbb3a8!important}
html[data-theme="oscuro"] .legal-toolbar button#legal-new{background:#655544!important;color:#e0d8ce!important;border-color:#8a7660!important}
html[data-theme="oscuro"] progress,html[data-theme="oscuro"] progress::-webkit-progress-bar{background:#3a3632!important}
html[data-theme="oscuro"] progress.is-paid{--payment-color:#c9b59c;accent-color:#c9b59c!important}

/* ===== Capa suave: unifica los tonos fijos de cada pantalla con la misma paleta ===== */

/* Tarjetas y paneles: todos en la misma superficie */
html[data-theme="oscuro"] body :is(.panel,.paso,.programa,.glosario div,.indicador,.flujo-panel,.tabla-caja,.fichas-lista,.fichas-ok a,.embudo,.panel-filtros,.pedir-opcion,.vistas button,.cifras .cifra,main > section .cifra){background:#282624!important;border-color:#3b3835!important}
html[data-theme="oscuro"] body :is(.detalle th,.hoja th[scope="row"],.grid thead th,.historial th,.fl-tabla th){background:#2b2927!important;color:#969087!important}
html[data-theme="oscuro"] body :is(.detalle td,.hoja td,.grid td,.fl-tabla td){border-color:#2f2d2a!important}
html[data-theme="oscuro"] body :is(.detalle tr:hover td,.ficha:hover){background:#312f2c!important}
html[data-theme="oscuro"] body :is(.hoja tr.grupo th){background:#36322e!important;color:#bbb3a8!important}
html[data-theme="oscuro"] body :is(.grid .total th,.grid .total td,.grid td.total,.fl-tabla tr.fl-total td){background:#312f2c!important}
html[data-theme="oscuro"] body .volver{background:#282624!important;border-color:#3b3835!important;color:#bbb3a8!important}

/* Botones principales: bronce cálido (arena oscurecida) con texto marfil; nunca blancos */
html[data-theme="oscuro"] body :is(.boton:not(.claro):not(.rojo),.m2-boton-incidencias,.m2-vista button.activo,#diagnostico-abrir,.vistas button[aria-pressed="true"]){background:#655544!important;color:#e0d8ce!important;border-color:#8a7660!important}
html[data-theme="oscuro"] body :is(.boton:not(.claro):not(.rojo),.m2-boton-incidencias,#diagnostico-abrir,#ver-portal-cliente,.legal-toolbar button#legal-new):hover{background:#715f4c!important}
html[data-theme="oscuro"] body .boton.claro{background:transparent!important;color:#bbb3a8!important;border-color:#4e4945!important}
html[data-theme="oscuro"] body :is(.boton.rojo,#alertas-abrir){background:#9e4137!important;border-color:#9e4137!important;color:#f3e2de!important}

/* Ligas y cifras con liga: azul suave que no deslumbra */
html[data-theme="oscuro"] body :is(a.liga,a.adjunto-liga,a.cliente-liga,.ficha-nombre,.grid button.cifra,.pasos button.cifra,.pasos-nota button.cifra,.quitar,.tabla-scroll .liga,.exp-doc .liga){color:#86a6cf!important;text-decoration-color:#86a6cf!important}

/* Estados: verde, ámbar y rojo apagados, legibles sobre grafito */
html[data-theme="oscuro"] body :is(.chip.vendido,.etiqueta.vendida,.estado.activo,.exp-ok,.est-chip.pagado){background:#2c3a2a!important;color:#a5c69c!important}
html[data-theme="oscuro"] body :is(.chip.disponible){background:#263447!important;color:#a0b9db!important}
html[data-theme="oscuro"] body :is(.chip.reservado,.chip.apartado,.est-chip.parcial){background:#3e3222!important;color:#d9b77e!important}
html[data-theme="oscuro"] body :is(.etiqueta.cancelada,.chip.fuera,.m2-cancelado,.est-chip.vencido){background:#3f2724!important;color:#dea398!important}
html[data-theme="oscuro"] body :is(.est-chip.en_revision){background:#3d3520!important;color:#d6bd79!important}
html[data-theme="oscuro"] body :is(span.cep-no-aplica,.mensaje.ok,.resultado-ok){color:#9abf91!important}
html[data-theme="oscuro"] body :is(.mensaje.error,.resultado-mal,.falta.rojo){color:#e0948a!important}

/* Alertas e incidencias: rojo de fondo muy tenue para no cansar la vista */
html[data-theme="oscuro"] body :is(.alerta:not(.neutral):not(.verde),div.resumen > .tarjeta:not(.neutral):not(.verde),.tarjeta.roja,.seccion.roja){background:#2d2321!important;border-color:#553632!important;border-left-color:#c45a4e!important}
html[data-theme="oscuro"] body .alerta:not(.neutral):not(.verde) td,html[data-theme="oscuro"] body .seccion.roja td{background:#302624!important;color:#c4b8b3!important;border-bottom-color:#3f2f2c!important}
html[data-theme="oscuro"] body .alerta:not(.neutral):not(.verde) th,html[data-theme="oscuro"] body .seccion.roja th{background:#3a2a27!important;color:#dea398!important}
html[data-theme="oscuro"] body :is(.alerta.verde,.tarjeta.verde){background:#232a22!important;border-color:#3a4a37!important;border-left-color:#7d9e77!important}
html[data-theme="oscuro"] body :is(.alerta.neutral,.tarjeta.neutral,.seccion:not(.roja),.tarjeta:not(.roja):not(.verde)){border-color:#3b3835!important}
html[data-theme="oscuro"] body #account-card-conditions .condition-table tr.pago-tercero td{background:#3a2724!important}
html[data-theme="oscuro"] body #account-card-conditions .condition-table tr.extraordinaria td{background:#312f2c!important}

/* Ficha del estado de cuenta (encabezado claro en modo día) */
html[data-theme="oscuro"] body #account-card .account-card-top{background:#282624!important;border-bottom-color:#3b3835!important}
html[data-theme="oscuro"] body #account-card #account-card-name,html[data-theme="oscuro"] body #account-card .account-card-balances dd,html[data-theme="oscuro"] body #formas-pago-resumen :is(.fp-monto,.fp-titulo b){color:#bbb3a8!important}
html[data-theme="oscuro"] body #account-card #account-card-back{background:#312f2c!important;border-color:#423e3a!important;color:#bbb3a8!important}
html[data-theme="oscuro"] body #account-card .account-card-balances,html[data-theme="oscuro"] body #account-card .account-card-balances > div{border-color:#3b3835!important}
html[data-theme="oscuro"] body #formas-pago-resumen .fp-barra{background:#3a3632!important}
html[data-theme="oscuro"] body #ver-portal-cliente{background:#655544!important;color:#e0d8ce!important;border-color:#8a7660!important}

/* Diagramas del módulo Sistema */
html[data-theme="oscuro"] body .fl-t{fill:#bbb3a8}
html[data-theme="oscuro"] body .fl-s{fill:#969087}
html[data-theme="oscuro"] body .fl-n8n{fill:#36322e;stroke:#c9b59c}
html[data-theme="oscuro"] body .fl-supa{fill:#282624;stroke:#b3aba1}
html[data-theme="oscuro"] body .fl-bd{fill:#312f2c;stroke:#bbb3a8}
html[data-theme="oscuro"] body .fl-pausa{fill:#282624;stroke:#7a746e}
html[data-theme="oscuro"] body .fl-aud{fill:#22303b;stroke:#6f9fc4}
html[data-theme="oscuro"] body .fl-dec{fill:#655544;stroke:#8a7660}
html[data-theme="oscuro"] body .fl-dec-t{fill:#e0d8ce}
html[data-theme="oscuro"] body .fl-dec-s{fill:#cdbfae}
html[data-theme="oscuro"] body .mapa .nodo rect{fill:#282624;stroke:#3b3835}

/* Selección de texto y barras de desplazamiento */
html[data-theme="oscuro"] ::selection{background:#5a4f42;color:#e0d8ce}
html[data-theme="oscuro"] *{scrollbar-color:#4e4945 #1f1e1c}

/* ===== Jerarquía por rol (equivalencias del modo día) =====
   Blanco (tarjetas y cuerpo de tablas) → #242220 · beige tenue (encabezados y columnas fijas) → #2d2a26
   beige de acento (tarjeta resumen, etiquetas) → #3a332b · líneas negras de acento → arena #a08c74
   Líneas entre renglones → #2e2b28 · bordes → #3a3632. Los gráficos conservan su color. */
html[data-theme="oscuro"] body :is(#accounts,#projects table,.condition-table){background:#242220!important}
html[data-theme="oscuro"] body :is(#accounts td,#projects tbody td,.condition-table td,#legal-table td,#legal-upcoming td,#agreements td){border-bottom-color:#2e2b28!important}
html[data-theme="oscuro"] body :is(#accounts th,#accounts thead tr:first-child th){background:#2d2a26!important;color:#a89a88!important;border-bottom:1px solid #3a3632!important}
html[data-theme="oscuro"] body #accounts thead tr:first-child th{color:#c2ae95!important;letter-spacing:.04em}
html[data-theme="oscuro"] body :is(#accounts tbody td:first-child,#accounts tbody td:nth-child(2),#accounts thead tr:nth-child(2) th:first-child,#accounts thead tr:nth-child(2) th:nth-child(2)){background:#2d2a26!important;box-shadow:1px 0 #3a3632!important}
html[data-theme="oscuro"] body :is(#accounts tfoot td,#accounts tfoot td:first-child,#accounts tfoot td:nth-child(2)){background:#34302b!important;color:#c9c1b6!important;border-top:1px solid #3a3632!important}
html[data-theme="oscuro"] body #accounts .account-open-row:hover td{background-color:#2f2c28!important}
html[data-theme="oscuro"] body #accounts .account-open-row:hover td:nth-child(-n+2){background-color:#36322d!important}
html[data-theme="oscuro"] body #accounts .payment-summary td{background:#2a2724!important}

/* Tarjeta resumen del proyecto: beige del modo día → taupe oscuro, texto arena legible */
html[data-theme="oscuro"] body #account-project-summary:not([hidden]){background:#3a332b!important;color:#d6c9b6!important}
html[data-theme="oscuro"] body #account-project-summary :is(.project-link-title,h2,strong,dd){color:#d6c9b6!important}
html[data-theme="oscuro"] body #account-project-summary dt{color:#a89a88!important}
html[data-theme="oscuro"] body :is(#account-projects .project-link-title,#account-projects a.project-link){color:#bbb3a8!important}

/* Cartera por proyecto: líneas de acento en arena en lugar de negro */
html[data-theme="oscuro"] body #projects thead th{border-bottom-color:#3a3632!important}
html[data-theme="oscuro"] body #projects thead th:is(:nth-child(4),:nth-child(5),:nth-child(6),:nth-child(7),:nth-child(8),:nth-child(9)){box-shadow:inset 0 2px 0 #6b5d4e!important}
html[data-theme="oscuro"] body #projects thead th:last-child{box-shadow:inset 0 2px 0 #a08c74!important;color:#c2ae95!important}
html[data-theme="oscuro"] body #projects tbody td:last-child{background:#2d2a26!important}
html[data-theme="oscuro"] body :is(#agreements th,#legal-table th,#legal-upcoming th){border-bottom-color:#a08c74!important}

/* Condiciones de pago */
html[data-theme="oscuro"] body .condition-table th{background:#2d2a26!important;color:#a89a88!important;border-bottom:1px solid #3a3632!important}
html[data-theme="oscuro"] body .condition-table :is(th,td):first-child{background:#2d2a26!important}
html[data-theme="oscuro"] body .condition-card{border-color:#3a3632!important}
html[data-theme="oscuro"] body .condition-tag{background:#3a332b!important;color:#d6c9b6!important}

/* Gráficos: conservan su color, adaptado a fondo oscuro */
html[data-theme="oscuro"] body :is(.planned,.key.planned){background:#6b5d4e!important}
html[data-theme="oscuro"] body :is(.paid,.key.paid){background:#c8ad85!important}
html[data-theme="oscuro"] body .bar-label{color:#a89a88!important}
html[data-theme="oscuro"] body :is(.ep-barra i,.pista i){background:#c8ad85!important}
html[data-theme="oscuro"] body :is(progress)::-webkit-progress-value{background:#c8ad85}
html[data-theme="oscuro"] body #account-card-conditions .condition-status progress:not(.completo)::-webkit-progress-value{background:#d99a52!important}
html[data-theme="oscuro"] body #account-card-conditions .condition-status progress.completo::-webkit-progress-value{background:#6fa865!important}
html[data-theme="oscuro"] body #account-card-conditions .condition-status progress:not(.completo)::-moz-progress-bar{background:#d99a52!important}
html[data-theme="oscuro"] body #account-card-conditions .condition-status progress.completo::-moz-progress-bar{background:#6fa865!important}
/* Formas de pago (colores puestos por la página): misma lectura, tonos para fondo oscuro */
html[data-theme="oscuro"] body :is(.fp-barra,.fp-lista,.formas-barra,.formas-lista) [style*="rgb(75, 79, 82)"]{background:#8d9cab!important}
html[data-theme="oscuro"] body :is(.fp-barra,.fp-lista,.formas-barra,.formas-lista) [style*="rgb(157, 139, 119)"]{background:#c8ad85!important}
html[data-theme="oscuro"] body :is(.fp-barra,.fp-lista,.formas-barra,.formas-lista) [style*="rgb(194, 174, 152)"]{background:#a3907a!important}
html[data-theme="oscuro"] body :is(.fp-barra,.fp-lista,.formas-barra,.formas-lista) [style*="rgb(224, 211, 197)"]{background:#6f655a!important}
html[data-theme="oscuro"] body :is(.fp-barra,.fp-lista,.formas-barra,.formas-lista) [style*="rgb(217, 130, 43)"]{background:#d99a52!important}
/* Avance del Diagnóstico */
html[data-theme="oscuro"] body :is(.avance-barra i.ok,.avance-leyenda .ok::before,.ficha-barra i){background:#6fa865!important}
html[data-theme="oscuro"] body :is(.avance-barra i.falta,.avance-leyenda .falta::before){background:#d99a52!important}
html[data-theme="oscuro"] body :is(.avance-barra i.sin,.avance-leyenda .sin::before){background:#c45a4e!important}
html[data-theme="oscuro"] body :is(.avance-barra,.ficha-barra){background:#2d2a26!important}
/* La sección de estados de cuenta no es tarjeta en modo día: tampoco en modo noche */
html[data-theme="oscuro"] body #estados.account-section{background:transparent!important;border:0!important}
