:root {
  --fondo: #f4f6f9; --panel: #ffffff; --texto: #1b2230; --suave: #5b6576; --borde: #e2e6ee;
  --marca: #0b3fb3; --marca2: #0a2f88; --oro: #f5c400; --lateral: #0a1a3f; --ok: #1f8a4c; --alerta: #c27c0e; --error: #c0392b; --info: #2563eb;
  --radio: 10px; --sombra: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--texto); background: var(--fondo); }
a { color: var(--info); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-size: 15px; margin: 0 0 10px; font-weight: 700; }
p { text-align: justify; }
.cargando { padding: 60px; text-align: center; color: var(--suave); }

/* Estructura */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.lateral { background: var(--lateral); color: #dbe4f3; padding: 16px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.lateral .marca { padding: 0 18px 14px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 8px; }
.lateral .marca b { display: block; color: #fff; font-size: 15px; } .lateral .marca small { color: var(--oro); font-weight: 600; letter-spacing: .04em; }
.lateral .grupo { padding: 12px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8fa3c4; }
.lateral a { display: block; padding: 8px 18px; color: #dbe4f3; border-left: 3px solid transparent; }
.lateral a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.lateral a.activo { background: rgba(255,255,255,.1); border-left-color: var(--oro); color: #fff; font-weight: 600; }
.principal { padding: 20px 26px 60px; min-width: 0; }
.barra-sup { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.barra-sup h1 { margin: 0; font-size: 15px; }
.usuario-sup { color: var(--suave); font-size: 13px; }
.menu-movil { display: none; }

/* Componentes */
.panel { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); margin-bottom: 16px; }
.rejilla { display: grid; gap: 14px; } .r2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .r3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .r4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px 16px; box-shadow: var(--sombra); }
.kpi small { color: var(--suave); display: block; } .kpi b { font-size: 22px; display: block; margin-top: 2px; }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--marca); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn:hover { background: var(--marca2); } .btn:disabled { opacity: .55; cursor: default; }
.btn.sec { background: #fff; color: var(--marca); border: 1px solid var(--borde); } .btn.sec:hover { background: #f1f4f9; }
.btn.peligro { background: var(--error); } .btn.ok { background: var(--ok); } .btn.chico { padding: 5px 10px; font-size: 12.5px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input, select, textarea { font: inherit; border: 1px solid #cfd6e2; border-radius: 8px; padding: 7px 10px; background: #fff; color: inherit; max-width: 100%; }
textarea { width: 100%; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9bb7e8; border-color: #9bb7e8; }
label { display: block; font-size: 12.5px; color: var(--suave); margin-bottom: 10px; }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: 3px; color: var(--texto); }
label.check { display: inline-flex; align-items: center; gap: 6px; color: var(--texto); font-size: 13.5px; margin: 0; }
label.check input { width: auto; margin: 0; }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; } .form3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.ancho { grid-column: 1 / -1; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabla th { text-align: left; font-size: 12px; color: var(--suave); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.tabla td { padding: 8px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
.tabla tr.clic { cursor: pointer; } .tabla tr.clic:hover td { background: #f7f9fc; }
.n { text-align: right; white-space: nowrap; }
.desplaza { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: #eef2f8; color: #33415c; white-space: nowrap; }
.b-ok { background: #e3f4ea; color: var(--ok); } .b-alerta { background: #fdf1dc; color: var(--alerta); } .b-error { background: #fbe5e2; color: var(--error); } .b-info { background: #e5edfd; color: var(--info); }
.vacio { color: var(--suave); padding: 18px; text-align: center; }
.suave { color: var(--suave); } .chico { font-size: 12.5px; }
.lista-simple { list-style: none; padding: 0; margin: 0; } .lista-simple li { padding: 8px 0; border-bottom: 1px solid #eef1f6; } .lista-simple li:last-child { border: 0; }
.pestanas { display: flex; gap: 4px; border-bottom: 1px solid var(--borde); margin-bottom: 16px; flex-wrap: wrap; }
.pestanas a { padding: 8px 14px; color: var(--suave); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pestanas a.activo { color: var(--marca); border-bottom-color: var(--oro); font-weight: 600; text-decoration: none; }
.barra-prog { height: 8px; background: #eef1f6; border-radius: 99px; overflow: hidden; margin-top: 6px; } .barra-prog i { display: block; height: 100%; background: var(--ok); }
pre.json { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; font-size: 12px; overflow: auto; max-height: 360px; }

/* Embudo */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kb-col { background: #eaeef5; border-radius: var(--radio); padding: 10px; min-height: 240px; }
.kb-col h4 { display: flex; justify-content: space-between; font-size: 12.5px; color: #33415c; margin-bottom: 8px; }
.kb-col.sobre { outline: 2px dashed var(--info); }
.kb-card { background: #fff; border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; box-shadow: var(--sombra); cursor: pointer; border-left: 3px solid var(--marca); }
.kb-card:hover { border-left-color: var(--oro); }
.kb-card b { display: block; font-size: 13.5px; } .kb-card small { display: block; color: var(--suave); font-size: 12px; }
.kb-card .v { font-weight: 700; margin-top: 3px; font-size: 13px; }

/* Avisos y modal */
#avisos { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.aviso { background: #1b2230; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 360px; }
.aviso.err { background: var(--error); } .aviso.ok { background: var(--ok); }
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 40; overflow-y: auto; }
.modal.oculto { display: none; }
.modal-caja { background: #fff; border-radius: 12px; padding: 22px; width: 100%; max-width: 720px; position: relative; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-caja.ancha { max-width: 1000px; }
.modal-cerrar { position: absolute; right: 12px; top: 8px; border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--suave); }

/* Ingreso */
.ingreso { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0a1a3f, #0b3fb3); padding: 16px; }
.tarjeta-ingreso { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.tarjeta-ingreso h1 { font-size: 15px; } .tarjeta-ingreso .btn { width: 100%; justify-content: center; margin-top: 6px; }
body.instalar { background: var(--fondo); padding: 30px 16px; } body.instalar .tarjeta-ingreso { margin: 0 auto; } body.instalar .btn { width: auto; }
.error { color: var(--error); } .ok { color: var(--ok); }

/* Cotización */
.items td input, .items td select { width: 100%; min-width: 70px; padding: 5px 6px; font-size: 13px; }
.items td.desc input { min-width: 180px; }
.totales { margin-left: auto; max-width: 380px; } .totales div { display: flex; justify-content: space-between; padding: 4px 0; } .totales .gran { font-weight: 700; font-size: 16px; border-top: 2px solid var(--marca); margin-top: 4px; padding-top: 8px; }
.alerta-linea { color: var(--error); font-size: 12px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; height: 100vh; }
  .app.menu .lateral { transform: none; }
  .menu-movil { display: inline-flex; }
  .principal { padding: 14px; }
  .r2, .r3, .r4, .form2, .form3 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(6, 78vw); }
}

/* Ajustes */
.btn.ok, .btn.peligro { color: #fff; }
input[hidden] { display: none !important; }
.btn.menu-movil { display: none; }
@media (max-width: 900px) { .btn.menu-movil { display: inline-flex; } }
.kanban { grid-template-columns: repeat(6, minmax(160px, 1fr)); }
.items td select[data-k=tipo] { min-width: 165px; } .items td select[data-k=medio] { min-width: 175px; } .items td select[data-k=dias] { min-width: 215px; }
.items td select[data-k=esquema] { min-width: 90px; } .items td input[data-k=valor_unitario] { min-width: 120px; }
.items td input[data-k=horas], .items td input[data-k=hora_inicio], .items td input[data-k=cantidad] { min-width: 58px; }
.item { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: flex-end; padding: 12px; border: 1px solid var(--borde); border-radius: 8px; margin-bottom: 10px; background: #fafbfd; }
.item label { margin-bottom: 6px; flex: 1 1 170px; } .item label.i-desc { flex: 3 1 320px; } .item label.i-n { flex: 0 1 90px; }
.item .i-tot { flex: 1 1 200px; text-align: right; margin-bottom: 6px; font-weight: 700; } .item .i-tot .chico, .item .i-tot .alerta-linea { font-weight: 400; }
.item [data-quitar] { margin-bottom: 8px; }
.item label:has([data-k=dias]) { flex-basis: 240px; } .item label:has([data-k=medio]), .item label:has([data-k=tipo]) { flex-basis: 200px; }
.tabla.prosp td { font-size: 13px; } .tabla .nw { white-space: nowrap; }
.tabla a.wa, a.wa { color: #128c4b; font-size: 12px; font-weight: 600; }
details.panel summary { cursor: pointer; }
.tabla.prosp td:first-child { min-width: 230px; }

/* Marca Seguridad Diez */
.lateral .marca { text-align: center; } .lateral .marca img { width: 150px; max-width: 100%; display: block; margin: 0 auto 6px; }
.lateral .marca small { color: var(--oro); }
.logo-ingreso { display: block; width: 190px; margin: 0 auto 14px; }
.kpi { border-top: 3px solid var(--marca); }
.pestanas a.activo { border-bottom-color: var(--marca); }
