/* Project Huella — estilos base. Colores de marca: Manual We Are Project 2026. */
:root {
  --ink: #1f2328; --muted: #5f6b72; --bg: #f4f6f5; --card: #fff; --line: #dfe5e3;
  --teal: #4f9aab; --green: #62bb8c; --teal-dark: #3b7f8f; --danger: #b60205; --warn: #b7791f;
  --ok: #2f855a; --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Lato, sans-serif; color: var(--ink);
  background: var(--bg); font-size: 14px; line-height: 1.45; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--teal-dark); }
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 20px; color: #fff;
  background: linear-gradient(90deg, var(--teal), var(--green)); }
.logo-marca { display: block; height: 28px; aspect-ratio: 1586 / 416; background: currentColor;
  -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat; }
.topbar .logo-marca { color: #fff; }
.topbar .marca { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.topbar .producto { font-weight: 300; letter-spacing: .32em; text-transform: uppercase; font-size: 13px;
  padding-left: 10px; border-left: 1px solid rgba(255,255,255,.5); }
.topbar nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.topbar nav a { white-space: nowrap; color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-weight: 600; }
.topbar nav a:hover, .topbar nav a.activo { background: rgba(255,255,255,.18); }
.topbar .usuario { font-size: 13px; opacity: .9; }
.topbar .usuario, .topbar a.usuario { color: #fff; }
main.contenedor { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 20px; }
footer.pie { padding: 8px 20px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; border-top: 1px solid var(--line); }
footer.pie a { color: var(--muted); }

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.cabecera { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card h2 { display: flex; justify-content: space-between; align-items: center; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--teal); }
.btn.primario { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primario:hover { background: var(--teal-dark); }
.btn.chico { padding: 4px 10px; font-size: 12px; }
.btn.peligro { color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

label { display: block; font-weight: 600; font-size: 12px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
input[type=text], input[type=number], input[type=date], input[type=search], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(79,154,171,.35); border-color: var(--teal); }
textarea { resize: vertical; }
input[readonly], textarea[readonly], select[disabled], input[disabled], textarea[disabled] { background: #f7f8f8; color: var(--muted); }
.campo { margin-bottom: 12px; }
.campo .ayuda { font-size: 12px; color: var(--muted); margin-top: 3px; }
.campo .error, .errorlist { color: var(--danger); font-size: 12px; margin: 3px 0 0; padding: 0; list-style: none; }
.grilla { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

table.tabla { width: 100%; border-collapse: collapse; background: #fff; }
table.tabla th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfb; }
table.tabla td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tabla tr:hover td { background: #fafcfc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: #eef2f1; color: var(--ink); white-space: nowrap; }
.chip.linea { background: rgba(79,154,171,.14); color: var(--teal-dark); }
.chip.e-oportunidad, .chip.e-precotizacion { background: #eef2f1; }
.chip.e-enviado { background: #e6f0ff; color: #1d4ed8; }
.chip.e-negociacion { background: #fff4e0; color: var(--warn); }
.chip.e-aprobado { background: #e3f6ec; color: var(--ok); }
.chip.e-desestimado { background: #fde8e8; color: var(--danger); }
.chip.e-pausado { background: #f1f1f1; color: var(--muted); }
.chip.congelada { background: #fff4e0; color: var(--warn); }

.mensajes { list-style: none; padding: 0; margin: 0 0 16px; }
.mensajes li { padding: 10px 14px; border-radius: 8px; margin-bottom: 6px; background: #e3f6ec; color: var(--ok); font-weight: 600; }
.mensajes li.error { background: #fde8e8; color: var(--danger); }
.mensajes li.warning { background: #fff4e0; color: var(--warn); }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filtros > * { flex: 0 0 auto; }
.filtros input[type=search] { width: 280px; }
.filtros select { width: 190px; }

/* Editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.lateral { position: sticky; top: 16px; }
.fila { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; background: #fcfdfd; position: relative; }
.fila.borrada { opacity: .45; }
.fila .quitar { position: absolute; top: 8px; right: 8px; }
.fila-costo { display: grid; grid-template-columns: 2fr 2fr .8fr 1.2fr 1fr 1.3fr 1.2fr .7fr 28px; gap: 8px; align-items: end; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.fila-costo.cabeza { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; border-bottom: 1px solid var(--line); padding-top: 0; }
.fila-costo.borrada { opacity: .4; }
.fila-costo .total { font-variant-numeric: tabular-nums; text-align: right; padding-bottom: 8px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 6px; justify-content: center; padding-bottom: 8px; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 6px; }
.x:hover { color: var(--danger); }
.catalogo-picker { display: flex; gap: 8px; margin-top: 10px; }
.catalogo-picker select { flex: 1; }

.resumen table { width: 100%; border-collapse: collapse; }
.resumen td { padding: 4px 0; border-bottom: 1px solid #f0f2f1; }
.resumen td.num { font-weight: 600; }
.resumen tr.destacado td { font-size: 16px; font-weight: 800; border-bottom: 2px solid var(--teal); padding: 8px 0; }
.resumen tr.neta td { color: var(--ok); font-size: 15px; font-weight: 800; }
.resumen tr.neta.negativa td { color: var(--danger); }
.resumen tr.sep td { padding-top: 10px; font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; border: 0; }
.resumen .vivo { font-size: 11px; color: var(--muted); margin-top: 8px; }
.htmx-request .resumen { opacity: .6; }

@media (max-width: 1100px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .lateral { position: static; }
  .fila-costo { grid-template-columns: 1fr 1fr; }
  .fila-costo.cabeza { display: none; }
}
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } .topbar { flex-wrap: wrap; } }

/* Opciones */
.bloque-opcion { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.bloque-opcion summary { cursor: pointer; list-style: revert; }
.bloque-opcion[open] summary { margin-bottom: 6px; }
.fila-opcion .grilla { grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) minmax(0,1fr) auto !important; }
@media (max-width: 700px) { .fila-opcion .grilla { grid-template-columns: 1fr 1fr !important; } }
.fila-opcion { border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fcfdfd; }
.fila-opcion.elegida { border-left-color: var(--ok); background: #f3fbf6; }
@media (min-width: 1101px) {
  .fila-costo.con-opciones { grid-template-columns: 2fr 1.6fr .7fr 1.1fr .9fr 1.2fr 1.1fr 1.2fr .6fr 28px; }
}
.sel-opcion { font-size: 12px; }
.fila-item-grid { grid-template-columns: minmax(0,1fr) 110px 170px; gap: 10px; }
.fila-item-grid.con-opciones { grid-template-columns: minmax(0,1fr) 170px 110px 170px; }
@media (max-width: 900px) { .fila-item-grid, .fila-item-grid.con-opciones { grid-template-columns: minmax(0,1fr) minmax(0,1fr); } }

/* Campanita */
.topbar .campana { position: relative; color: #fff; text-decoration: none; font-size: 18px; padding: 4px 6px; }
.topbar .campana .badge { position: absolute; top: -4px; right: -6px; background: #b60205; color: #fff; font-size: 10px;
  font-weight: 800; border-radius: 999px; padding: 1px 6px; line-height: 1.4; }
.punto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }

/* Buzón de mejoras */
.btn-mejora { position: fixed; right: 18px; bottom: 44px; z-index: 50; border: 0; border-radius: 999px; padding: 10px 16px;
  background: var(--ink); color: #fff; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.btn-mejora:hover { background: var(--teal-dark); }
.dlg { border: 0; border-radius: 12px; padding: 20px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(31,35,40,.45); }
.form-mejora { grid-template-columns: 180px minmax(0,1fr) 140px auto; gap: 8px; align-items: end; }
@media (max-width: 700px) { .form-mejora { grid-template-columns: minmax(0,1fr); } .btn-mejora { bottom: 52px; } }
.chip.s-nueva { background: #eef2f1; } .chip.s-evaluacion { background: #fff4e0; color: var(--warn); }
.chip.s-planificada { background: #e6f0ff; color: #1d4ed8; } .chip.s-hecha { background: #e3f6ec; color: var(--ok); }
.chip.s-descartada { background: #fde8e8; color: var(--danger); }

/* Proveedores */
.kpis-fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-caja { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi-caja small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.kpi-caja b { font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi-caja.alerta { border-color: var(--warn); background: #fffaf0; }
.kpi-caja.alerta b { color: var(--warn); }
.chip.op-pendiente { background: #fff4e0; color: var(--warn); }
.chip.op-aprobada { background: #e6f0ff; color: #1d4ed8; }
.chip.op-pagada { background: #e3f6ec; color: var(--ok); }
.chip.op-anulada, .chip.oc-anulada { background: #f1f1f1; color: var(--muted); text-decoration: line-through; }
.chip.oc-abierta { background: #e6f0ff; color: #1d4ed8; }
.chip.oc-facturada { background: #e3f6ec; color: var(--ok); }
.chip.sin-comp { background: #fde8e8; color: var(--danger); }
td.vencida { color: var(--danger); font-weight: 700; }
.acciones-op { text-align: right; white-space: nowrap; }
.acciones-op details { display: inline-block; text-align: left; }
.acciones-op details summary { list-style: none; }
.acciones-op details summary::-webkit-details-marker { display: none; }
.form-pago { display: grid; gap: 6px; margin-top: 8px; min-width: 220px; }
.barra-part { height: 6px; background: #eef2f1; border-radius: 99px; overflow: hidden; margin-bottom: 2px; }
.barra-part span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--green)); }

table.tabla th.num { text-align: right; }

/* Caja y planificador */
.horizontes { display: flex; gap: 6px; flex-wrap: wrap; }
.veredicto { font-weight: 700; font-size: 13px; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.veredicto.ok { background: #e3f6ec; color: var(--ok); }
.veredicto.demorar { background: #fff4e0; color: var(--warn); }
.veredicto.no { background: #fde8e8; color: var(--danger); }
.resultado-sim { margin-top: 12px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; }
.resultado-sim.ok { background: #f0faf4; border-color: #bfe5cd; }
.resultado-sim.demorar { background: #fffaf0; border-color: #f2d7a6; }
.resultado-sim.no_alcanza { background: #fdf2f2; border-color: #f1c3c3; }
.rojo-txt { color: var(--danger); }
.grafico-caja svg { display: block; overflow: visible; }
.grafico-caja .grilla-l { stroke: var(--line); stroke-width: 1; }
.grafico-caja .eje { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.grafico-caja .area { fill: rgba(79,154,171,.12); }
.grafico-caja .linea { fill: none; stroke: var(--teal); stroke-width: 2; stroke-linejoin: round; }
.grafico-caja .cero { stroke: var(--danger); stroke-width: 1; stroke-dasharray: 4 3; }
.grafico-caja .marca { fill: var(--teal); stroke: #fff; stroke-width: 2; }
.grafico-caja .rojo .marca { fill: var(--danger); }
.grafico-caja .hit { fill: transparent; cursor: pointer; }
.grafico-caja .punto:hover .marca { r: 6; }

/* Proyectos y ficha */
.etapas { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 16px; }
.etapas form { margin: 0; }
.etapa { border: 1px solid var(--line); background: var(--card); color: var(--muted); padding: 7px 14px; font: inherit;
  font-weight: 600; cursor: pointer; margin-left: -1px; }
.etapas form:first-child .etapa { border-radius: 8px 0 0 8px; margin-left: 0; }
.etapas form:last-child .etapa { border-radius: 0 8px 8px 0; }
.etapa:hover { color: var(--ink); background: #f7faf9; }
.etapa.actual { background: var(--teal); border-color: var(--teal); color: #fff; position: relative; z-index: 1; }
.etapa.pausa.actual { background: var(--muted); border-color: var(--muted); }
.ficha-grid { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 16px; align-items: start; }
.nav-secciones { padding: 8px; position: sticky; top: 12px; }
.nav-secciones a { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 7px;
  text-decoration: none; color: var(--ink); font-size: 13px; }
.nav-secciones a:hover { background: #f1f5f4; }
.nav-secciones a.activo { background: rgba(79,154,171,.14); color: var(--teal-dark); font-weight: 700; }
.nav-secciones a small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.nav-secciones a small.completa { color: var(--ok); font-weight: 700; }
.nav-secciones a.apagada { color: var(--muted); font-size: 12px; }
.nav-secciones .sin-usar { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  font-weight: 700; padding: 12px 10px 4px; border-top: 1px solid var(--line); margin-top: 8px; }
.seccion-ficha h3 { font-size: 14px; margin: 18px 0 8px; }
.cabeza-seccion { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.campos-ficha .campo.ancho { grid-column: 1 / -1; }
.opciones-varias { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.opciones-varias .check { font-weight: 400; }
.checklist { margin-top: 8px; }
.grupo-item { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700;
  padding: 12px 0 4px; }
.item-ficha { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 5px 0; border-bottom: 1px solid #eef2f1; }
.item-ficha.e-hecho .t { color: var(--muted); text-decoration: line-through; }
.item-ficha.e-no_aplica .t { color: #9aa4a8; font-style: italic; }
.estados-item { display: flex; margin: 0; }
.est { width: 28px; height: 26px; border: 1px solid var(--line); background: #fff; color: #9aa4a8; cursor: pointer;
  font-size: 13px; margin-left: -1px; padding: 0; }
.estados-item .est:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.estados-item .est:last-child { border-radius: 0 6px 6px 0; }
.est.activo.est-pendiente { background: #eef2f1; color: var(--ink); }
.est.activo.est-en_curso { background: #fff4e0; color: var(--warn); border-color: #f2d7a6; }
.est.activo.est-hecho { background: #e3f6ec; color: var(--ok); border-color: #bfe5cd; font-weight: 700; }
.est.activo.est-no_aplica { background: #f1f1f1; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.texto-item .meta { margin-left: 6px; font-size: 12px; }
.texto-item .chip.vence { background: #fde8e8; color: var(--danger); }
.detalle-item summary { list-style: none; }
.detalle-item summary::-webkit-details-marker { display: none; }
.detalle-item[open] { grid-column: 1 / -1; }
.form-detalle { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.form-detalle select, .form-detalle input { width: auto; flex: 1 1 140px; }
.nuevo-item { display: flex; gap: 8px; margin-top: 12px; }
.nuevo-item input { flex: 1; }
.nuevo-item select { width: auto; }
.datos-vivos { background: #f7faf9; border: 1px solid var(--line); border-radius: 8px; padding: 4px 14px 14px; margin-bottom: 16px; }
.fila-dato { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #eef2f1; font-size: 13px; }
.form-staff { margin-top: 12px; }
.chip.p-escucha, .chip.p-lab, .chip.p-diseno { background: #e6f0ff; color: #1d4ed8; }
.chip.p-produccion, .chip.p-confirmado { background: #fff4e0; color: var(--warn); }
.chip.p-entregado, .chip.p-cierre { background: #e3f6ec; color: var(--ok); }
.chip.p-cerrado, .chip.p-pausado { background: #f1f1f1; color: var(--muted); }
.mes-agenda { font-size: 15px; margin: 18px 0 8px; }
.evento-agenda { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid #eef2f1; text-decoration: none; color: var(--ink); }
.evento-agenda:hover { background: #f7faf9; }
.evento-agenda .dia { text-align: center; line-height: 1.1; }
.evento-agenda .dia b { font-size: 22px; color: var(--teal-dark); display: block; }
.evento-agenda .dia small { color: var(--muted); text-transform: uppercase; font-size: 11px; }
@media (max-width: 900px) { .ficha-grid { grid-template-columns: minmax(0, 1fr); } .nav-secciones { position: static; } }

/* Costos reales y cierre */
a.etapa { display: inline-block; text-decoration: none; }
.etapa[disabled] { cursor: not-allowed; opacity: .6; }
.ok-txt { color: var(--ok); }
.aviso-cierre { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px;
  border-color: #bfe5cd; background: #f0faf4; }
.pendientes { margin: 0 0 12px; padding-left: 18px; color: var(--warn); font-size: 13px; }
.pendientes li { margin-bottom: 4px; }
tr.no-presupuestado td { background: #fffaf0; }

/* Aprobación online (página pública del cliente) */
.publico-main { max-width: 1200px; }
.publico-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.doc-publico { width: 100%; height: 78vh; border: 0; display: block; background: #fff; }
.opcion-publica { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; font-weight: 400; }
.opcion-publica small { display: block; }
.opcion-publica:has(input:checked) { border-color: var(--teal); background: rgba(79,154,171,.08); }
.link-cliente { display: flex; gap: 6px; }
.link-cliente input { flex: 1; font-size: 12px; }
@media (max-width: 900px) { .publico-grid { grid-template-columns: minmax(0, 1fr); } .doc-publico { height: 60vh; } }
.opcion-publica, .publico .check { text-transform: none; letter-spacing: normal; font-size: 14px; color: var(--ink); }

/* Equipo y liquidaciones */
.chip.l-pendiente { background: #fff4e0; color: var(--warn); }
.chip.l-adelantado { background: #e6f0ff; color: #1d4ed8; }
.chip.l-liquidado { background: #e3f6ec; color: var(--ok); }
.chip.liq-a_pagar { background: #fff4e0; color: var(--warn); }
.chip.liq-pagada { background: #e3f6ec; color: var(--ok); }

/* Inicio */
.accesos a.card { text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.accesos a.card:hover { border-color: var(--teal); box-shadow: 0 2px 8px rgba(79,154,171,.15); }
.accesos a.card h2 { margin-bottom: 4px; }

/* Ayuda */
.manual { display: grid; gap: 16px; max-width: 900px; }
.manual ol { padding-left: 20px; margin: 0; }
.manual li { margin-bottom: 8px; }
