/* =====================================================================
   Presupuestos, catálogo de partidas e importación BC3
   (canvas E-Documento, G-Catalogo, G-ImportarBC3)
   ===================================================================== */

/* ---- Cabecera del documento: total con IVA a la derecha ---- */
.pres-total-cabecera { text-align: right; margin-right: 8px; }
.pres-total-cabecera span { display: block; font-size: 11px; color: var(--texto-3); }
.pres-total-cabecera b { font-family: var(--fuente-numeros); font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; white-space: nowrap; }
.pres-version select { display: inline-block; width: auto; padding: 1px 26px 1px 8px; font-size: 12px; height: auto; }
.pres-solo-lectura { color: var(--tono-aviso-fg); font-weight: 600; }

/* ---- Documento: árbol + detalle lateral ---- */
.pres-documento { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.pres-documento.sin-detalle { grid-template-columns: minmax(0, 1fr); }
.pres-documento.sin-detalle .pres-detalle { display: none; }
@media (max-width: 1199.98px) {
    .pres-documento { grid-template-columns: minmax(0, 1fr); }
}

.pres-barra { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 13px; border-bottom: 1px solid var(--linea-suave); font-size: 12.5px; color: var(--texto-2); }

.pres-arbol { width: 100%; }
.pres-arbol td.pres-codigo { font-family: var(--fuente-numeros); font-size: 11.5px; white-space: nowrap; color: var(--texto-2); width: 1%; }
.pres-arbol tr.pres-cap > td { background: var(--superficie-2); font-weight: 700; color: var(--texto); }
.pres-arbol tr.pres-sub > td { font-weight: 600; color: var(--texto); }
.pres-arbol tr.pres-partida { cursor: pointer; }
.pres-arbol tr.pres-partida > td:first-child { box-shadow: inset 3px 0 0 transparent; }
.pres-arbol tr.pres-partida:hover > td { background: var(--superficie-2); }
.pres-arbol tr.pres-partida.activa > td { background: #eef6fa; }
.pres-arbol tr.pres-partida.activa > td:first-child { box-shadow: inset 3px 0 0 var(--brand-600); }
.pres-arbol .pres-nombre { min-width: 220px; }
.pres-arbol .pres-nivel-1 { padding-left: 16px; }
.pres-arbol .pres-nivel-2 { padding-left: 32px; }
.pres-arbol .pres-nivel-3 { padding-left: 48px; }
.pres-arbol .pres-ud { color: var(--texto-2); white-space: nowrap; }
.pres-plegar { border: none; background: none; padding: 0; font: inherit; color: inherit; display: inline-flex; gap: 6px; align-items: center; text-align: left; }
.pres-plegar i { font-size: 11px; color: var(--texto-3); transition: transform .15s ease; }
.pres-plegar[aria-expanded="false"] i { transform: rotate(-90deg); }
.pres-arbol tr.oculta { display: none; }

/* Coste interno: oculto hasta pulsar "Ver coste interno" (solo Administrador) */
.pres-col-coste { display: none; }
.con-coste .pres-col-coste { display: table-cell; color: var(--restringido-fg, var(--texto-2)); background: var(--restringido-bg); }

.pres-arbol tfoot td { padding: 7px 13px; font-size: 12.5px; border-top: 1px solid var(--linea-suave); }
.pres-arbol tfoot tr:first-child td { border-top: 1px solid var(--linea); }
.pres-arbol tfoot .pres-pie-etiqueta { text-align: right; color: var(--texto-2); }
.pres-arbol tfoot tr.pres-pie-total td { font-weight: 700; font-size: 14px; color: var(--texto); }

/* ---- Panel de detalle de la partida ---- */
.pres-detalle { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.pres-detalle-cab { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pres-detalle-cab h2 { font-size: 15px; font-weight: 700; margin: 2px 0 0; }
.pres-detalle-texto { font-size: 12.5px; color: var(--texto-2); margin: 10px 0 12px; white-space: pre-line; }
.pres-detalle-cifras { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px 0; border-top: 1px solid var(--linea-suave); border-bottom: 1px solid var(--linea-suave); }
.pres-detalle-cifras span { display: block; font-size: 11px; color: var(--texto-3); }
.pres-detalle-cifras b { font-family: var(--fuente-numeros); font-size: 13px; white-space: nowrap; }
.pres-detalle h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #6b7a84; margin: 14px 0 6px; }
.pres-detalle-fila { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--linea-suave); font-size: 12.5px; }
.pres-detalle-fila small { display: block; font-family: var(--fuente-numeros); font-size: 11px; color: var(--texto-3); }
.pres-detalle-fila .num { font-weight: 600; }
.pres-detalle-suma { display: flex; justify-content: space-between; padding: 7px 0 0; font-weight: 700; font-size: 12.5px; }
.pres-detalle-vacio { font-size: 12.5px; color: var(--texto-3); }

/* ---- Editor de líneas ---- */
.pres-editor-barra { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 13px; border-bottom: 1px solid var(--linea-suave); }
.pres-editor-barra .separador { flex: 1 1 auto; }
.pres-editor-total { font-size: 12.5px; color: var(--texto-2); }
.pres-editor-total b { font-family: var(--fuente-numeros); color: var(--texto); font-size: 14px; }
.pres-editor { width: 100%; }
.pres-editor td { vertical-align: middle; }
.pres-editor .form-control { padding: 3px 6px; font-size: 12.5px; height: auto; }
.pres-editor .pres-in-codigo { width: 92px; font-family: var(--fuente-numeros); }
.pres-editor .pres-in-ud { width: 58px; }
.pres-editor .pres-in-num { width: 96px; text-align: right; font-family: var(--fuente-numeros); }
.pres-editor tr.pres-cap > td { background: var(--superficie-2); }
.pres-editor tr.pres-cap .pres-in-nombre, .pres-editor tr.pres-sub .pres-in-nombre { font-weight: 600; }
.pres-editor tr.seleccionada > td { background: #eef6fa; }
.pres-editor tr.seleccionada > td:first-child { box-shadow: inset 3px 0 0 var(--brand-600); }
.pres-editor .pres-acciones { white-space: nowrap; text-align: right; width: 1%; }
.pres-editor .pres-acciones .btn { padding: 2px 6px; }
.pres-editor .pres-importe { font-family: var(--fuente-numeros); text-align: right; white-space: nowrap; }
.pres-editor .pres-marca-medicion { font-size: 10.5px; color: var(--brand-600); display: block; text-align: right; }
.pres-editor-vacio { padding: 22px; text-align: center; color: var(--texto-3); font-size: 12.5px; }

.pres-sublista { width: 100%; font-size: 12.5px; }
.pres-sublista th { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #6b7a84; padding: 4px; }
.pres-sublista td { padding: 3px 4px; }
.pres-sublista .form-control { padding: 3px 6px; font-size: 12.5px; }
.pres-sublista .num-in { text-align: right; font-family: var(--fuente-numeros); }

.pres-catalogo-lista { max-height: 55vh; overflow: auto; }
.pres-catalogo-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-bottom: 1px solid var(--linea-suave); font-size: 12.5px; }
.pres-catalogo-item small { display: block; color: var(--texto-3); font-size: 11px; }

/* ---- Importar BC3 ---- */
.bc3-pasos { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.bc3-paso { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--linea); border-radius: 999px; background: var(--superficie); font-size: 12.5px; color: var(--texto-3); }
.bc3-paso span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--tono-neutro-bg); font-family: var(--fuente-numeros); font-size: 11px; font-weight: 700; }
.bc3-paso.actual { border-color: var(--brand-600); color: var(--brand-600); font-weight: 700; background: #e7f1f5; }
.bc3-paso.actual span { background: var(--brand-600); color: #fff; }
.bc3-paso.hecho { color: var(--tono-ok-fg); }
.bc3-paso.hecho span { background: var(--tono-ok-bg); color: var(--tono-ok-fg); }

.bc3-destinos { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.bc3-destino { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--linea); border-radius: var(--radius-md); cursor: pointer; font-size: 12.5px; }
.bc3-destino:has(input:checked) { border-color: var(--brand-600); background: #f3f8fb; }
.bc3-destino small { display: block; color: var(--texto-3); }

.bc3-revision { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1199.98px) { .bc3-revision { grid-template-columns: minmax(0, 1fr); } }
.bc3-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bc3-chip { padding: 3px 9px; border-radius: 999px; background: var(--tono-neutro-bg); font-size: 12px; }
.bc3-chip b { font-family: var(--fuente-numeros); }
.bc3-chips .bc3-total { margin-left: auto; font-size: 12.5px; }
.bc3-chips .bc3-total b { font-family: var(--fuente-numeros); font-size: 14px; }
.pres-arbol tr.bc3-nueva > td { background: var(--tono-ok-bg); }
.pres-arbol td.bc3-cambia { background: var(--tono-aviso-bg); }
.bc3-cambio { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--linea-suave); font-size: 12.5px; }
.bc3-cambio .mono { font-size: 11.5px; color: var(--texto-2); }
.bc3-diferencia { display: flex; justify-content: space-between; padding-top: 8px; font-weight: 700; font-size: 12.5px; }
.bc3-avisos { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--tono-aviso-fg); }
.bc3-confirmar { list-style: none; padding: 0; margin: 0 0 12px; font-size: 13px; }
.bc3-confirmar li { display: flex; gap: 8px; padding: 4px 0; }
.bc3-confirmar i { color: var(--tono-ok-fg); }
.bc3-pie { display: flex; gap: 8px; align-items: center; }
.bc3-pie .separador { flex: 1 1 auto; }

/* ---- Catálogo ---- */
.cat-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1399.98px) { .cat-layout { grid-template-columns: 230px minmax(0, 1fr); } .cat-layout > .cat-detalle { grid-column: 1 / -1; } }
@media (max-width: 767.98px) { .cat-layout { grid-template-columns: minmax(0, 1fr); } }
.cat-arbol { padding: 8px; font-size: 12.5px; }
.cat-arbol ul { list-style: none; margin: 0; padding: 0; }
.cat-arbol ul ul { padding-left: 12px; }
.cat-arbol a { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 5px; color: var(--texto-2); text-decoration: none; }
.cat-arbol a:hover { background: var(--superficie-2); color: var(--texto); }
.cat-arbol a.actual { background: #e7f1f5; color: var(--brand-600); font-weight: 600; }
.cat-arbol .cat-capitulo > a { font-weight: 700; color: var(--texto); }
.cat-arbol small { font-family: var(--fuente-numeros); color: var(--texto-3); }
.cat-cabecera { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; padding: 12px 13px; border-bottom: 1px solid var(--linea-suave); }
.cat-cabecera h2 { font-size: 15px; font-weight: 700; margin: 0; }
.cat-cabecera .acciones { margin-left: auto; display: flex; gap: 6px; }
.table-app tr.cat-partida { cursor: pointer; }
.table-app tr.cat-partida.activa > td { background: #eef6fa; }
.table-app tr.cat-partida.activa > td:first-child { box-shadow: inset 3px 0 0 var(--brand-600); }
.table-app tr.cat-inactiva > td, .cat-arbol .cat-inactiva { color: var(--texto-3); }
.cat-partida a.cat-enlace { color: inherit; text-decoration: none; }
.cat-partida a.cat-enlace:hover { color: var(--brand-600); }
.cat-switch { display: inline-flex; width: 30px; height: 17px; border-radius: 999px; background: #c7d2d8; border: none; padding: 2px; justify-content: flex-start; }
.cat-switch::after { content: ""; width: 13px; height: 13px; border-radius: 50%; background: #fff; }
.cat-switch.activo { background: var(--tono-ok-fg); justify-content: flex-end; }
.cat-coste { color: var(--restringido-fg, var(--texto-2)); }
.cat-usos { margin-top: 12px; padding: 9px 10px; border-radius: var(--radius-sm); background: var(--tono-info-bg); color: var(--tono-info-fg); font-size: 12px; }

/* ---- Versión imprimible (Presupuestos/Imprimir) ---- */
.pres-impresion { max-width: 900px; margin: 24px auto; padding: 0 16px; font-size: 12px; color: #111; background: #fff; }
.pres-impresion h1 { font-size: 20px; margin: 0 0 4px; }
.pres-impresion .datos { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 16px; color: #444; }
.pres-impresion table { width: 100%; border-collapse: collapse; }
.pres-impresion th, .pres-impresion td { padding: 4px 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
.pres-impresion th { text-align: left; font-size: 10.5px; text-transform: uppercase; color: #555; }
.pres-impresion .num { text-align: right; white-space: nowrap; font-family: var(--fuente-numeros); }
.pres-impresion tr.cap td { font-weight: 700; background: #f3f5f6; }
.pres-impresion tr.sub td { font-weight: 600; }
.pres-impresion .desc { color: #555; font-size: 11px; }
.pres-impresion .totales td { border: none; font-weight: 600; }
.pres-impresion .acciones-impresion { margin-bottom: 12px; }
@media print { .pres-impresion .acciones-impresion { display: none; } .pres-impresion { margin: 0; } }

/* Coste interno dentro del panel de detalle */
.pres-coste-detalle { display: none; margin-top: 8px; padding: 7px 10px; border-radius: var(--radius-sm); background: var(--restringido-bg); font-size: 12px; }
.con-coste .pres-coste-detalle { display: flex; justify-content: space-between; gap: 8px; }
.pres-texto-libre { white-space: pre-line; font-size: 12.5px; }
.pres-panel-partida { --bs-offcanvas-width: min(640px, 100vw); }
