:root {
  --navy: #00006a;
  --navy-2: #1b1f86;
  --azul: #00a5ff;
  --azul-suave: #e3f4ff;
  --tinta: #0d1033;
  --gris: #5b6080;
  --gris-2: #8a8fab;
  --linea: #dfe3ee;
  --fondo: #f3f5fa;
  --papel: #ffffff;
  --ok: #138a5a;
  --ok-suave: #e1f5ec;
  --alerta: #b7791f;
  --alerta-suave: #fdf2dd;
  --peligro: #c53030;
  --peligro-suave: #fde8e8;
  --radio: 10px;
  --radio-sm: 6px;
  font-family: "Archivo", system-ui, sans-serif;
  color: var(--tinta);
  font-size: 15px;
  line-height: 1.45;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fondo); }
body { min-height: 100vh; font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
.oculto { display: none !important; }
:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
  padding: .55rem 1rem; border-radius: var(--radio-sm); cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--navy-2); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.sec { background: #fff; color: var(--navy); border-color: var(--linea); }
.btn.sec:hover { border-color: var(--navy); }
.btn.peq { padding: .3rem .65rem; font-size: .87rem; }
.btn.texto { background: none; border: none; color: var(--navy-2); padding: .2rem .3rem; font-weight: 600; }
.btn.texto:hover { text-decoration: underline; }
.btn.peligro { background: #fff; color: var(--peligro); border-color: #f1c4c4; }

label.campo { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; color: var(--gris); font-weight: 500; }
.campo input, .campo select, .campo textarea, .buscador input, .buscador select {
  border: 1px solid var(--linea); border-radius: var(--radio-sm); background: #fff;
  padding: .55rem .7rem; color: var(--tinta); font-size: .95rem; min-width: 0;
}
.campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--azul); outline: none; box-shadow: 0 0 0 3px var(--azul-suave); }
.campo textarea { resize: vertical; min-height: 4.5rem; }
.fila { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.ayuda { font-size: .82rem; color: var(--gris-2); margin: 0; }
.error { color: var(--peligro); font-size: .88rem; min-height: 1.2em; margin: 0; }

/* ---------- Login ---------- */
.pantalla-login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background-color: var(--fondo);
  background-image: radial-gradient(var(--azul) 1.4px, transparent 1.6px);
  background-size: 22px 22px; background-position: 0 0;
}
.pantalla-login::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, var(--fondo) 35%, rgba(243,245,250,.75) 70%, rgba(243,245,250,.35));
}
.tarjeta-login {
  position: relative; width: min(400px, 100%); background: #fff; border-radius: 14px;
  padding: 36px 32px 28px; border: 1px solid var(--linea);
  box-shadow: 0 20px 50px -24px rgba(0, 0, 106, .35);
}
.tarjeta-login img { width: 100%; max-width: 280px; display: block; margin: 0 auto 26px; }
.tarjeta-login h1 { font-size: 1.15rem; margin: 0 0 4px; }
.tarjeta-login p.sub { margin: 0 0 20px; color: var(--gris); font-size: .92rem; }
.tarjeta-login form { display: grid; gap: 14px; }
.tarjeta-login .btn { width: 100%; padding: .7rem; }
.cambiar-modo { text-align: center; margin-top: 14px; font-size: .9rem; color: var(--gris); }
.aviso { background: var(--azul-suave); color: var(--navy); padding: .7rem .85rem; border-radius: var(--radio-sm); font-size: .9rem; }

/* ---------- App ---------- */
.barra {
  background: #fff; border-bottom: 1px solid var(--linea);
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 62px;
  position: sticky; top: 0; z-index: 20;
}
.barra img { height: 30px; }
.barra nav { display: flex; gap: 4px; height: 100%; }
.barra nav button {
  background: none; border: none; cursor: pointer; padding: 0 12px; font-weight: 600; color: var(--gris);
  border-bottom: 3px solid transparent; height: 100%;
}
.barra nav button[aria-current="page"] { color: var(--navy); border-bottom-color: var(--azul); }
.barra .usuario { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--gris); }

main { padding: 24px; max-width: 1700px; margin: 0 auto; }
.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.encabezado h2 { margin: 0; font-size: 1.5rem; letter-spacing: -.01em; }
.encabezado p { margin: 2px 0 0; color: var(--gris); }

.resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.cifra { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px 16px; }
.cifra b { display: block; font-size: 1.35rem; color: var(--navy); }
.cifra span { color: var(--gris); font-size: .86rem; }
.cifra.alerta b { color: var(--peligro); }

.buscador { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.buscador input { flex: 1 1 260px; }

.tabla-wrap { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); overflow: auto; max-height: calc(100vh - 300px); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .88rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--linea); white-space: nowrap; vertical-align: top; }
th { position: sticky; top: 0; background: #f8f9fc; color: var(--gris); font-weight: 600; font-size: .82rem; z-index: 1; }
td.num, th.num { text-align: right; }
td.texto-largo { white-space: normal; min-width: 220px; max-width: 320px; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: #f6f9ff; }
.vacio { padding: 48px 16px; text-align: center; color: var(--gris); }

.estado { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: #eceef5; color: var(--gris); }
.estado.e-iniciado { background: #eceef5; color: #3d4266; }
.estado.e-cotizacion { background: var(--azul-suave); color: #005f94; }
.estado.e-materiales { background: #ece9ff; color: #4a3aa8; }
.estado.e-ejecutado { background: #e6f0ff; color: var(--navy-2); }
.estado.e-pago { background: var(--alerta-suave); color: var(--alerta); }
.estado.e-vencido { background: var(--peligro-suave); color: var(--peligro); }
.estado.e-liquidar { background: var(--ok-suave); color: var(--ok); }
.estado.e-cerrado { background: #e9ebef; color: #6b7088; }

/* ---------- Ficha de ticket (panel) ---------- */
.velo { position: fixed; inset: 0; background: rgba(13, 16, 51, .35); z-index: 40; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--fondo); z-index: 41;
  display: flex; flex-direction: column; box-shadow: -20px 0 50px -30px rgba(0,0,0,.4);
}
.panel-cab { background: #fff; padding: 18px 24px; border-bottom: 1px solid var(--linea); display: flex; gap: 12px; align-items: flex-start; }
.panel-cab h3 { margin: 0; font-size: 1.2rem; }
.panel-cab p { margin: 2px 0 0; color: var(--gris); font-size: .92rem; }
.panel-cab .cerrar { margin-left: auto; }
.panel-cuerpo { overflow: auto; padding: 20px 24px 40px; }

/* Línea de vida: puntos y trazo, como la línea punteada del logo */
.linea-vida { list-style: none; margin: 0 0 22px; padding: 18px 8px 4px; display: grid; grid-template-columns: repeat(9, 1fr); background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); }
.linea-vida li { position: relative; text-align: center; font-size: .74rem; color: var(--gris-2); padding-top: 26px; line-height: 1.2; }
.linea-vida li::before {
  content: ""; position: absolute; top: 4px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: #fff; border: 2px solid var(--linea); z-index: 1;
}
.linea-vida li::after {
  content: ""; position: absolute; top: 10px; left: -50%; width: 100%; height: 0;
  border-top: 2px dotted var(--linea);
}
.linea-vida li:first-child::after { display: none; }
.linea-vida li.ok { color: var(--tinta); }
.linea-vida li.ok::before { background: var(--azul); border-color: var(--azul); }
.linea-vida li.ok::after { border-top: 2px solid var(--azul); }
.linea-vida li.actual { color: var(--navy); font-weight: 700; }
.linea-vida li.actual::before { border-color: var(--navy); box-shadow: 0 0 0 4px var(--azul-suave); }
.linea-vida li.actual::after { border-top-color: var(--azul); }

.paso { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); margin-bottom: 12px; }
.paso > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.paso > header h4 { margin: 0; font-size: 1rem; }
.paso > header .marca { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; border: 2px solid var(--linea); color: var(--gris-2); flex: none; }
.paso.hecho > header .marca { background: var(--azul); border-color: var(--azul); color: #fff; }
.paso.bloqueado { opacity: .6; }
.paso > header .acciones { margin-left: auto; display: flex; gap: 6px; }
.paso .contenido { padding: 0 16px 16px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; margin: 0; }
.datos div dt { font-size: .8rem; color: var(--gris); }
.datos div dd { margin: 0; font-weight: 600; }
.docs { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.docs li { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.docs li .tipo { font-size: .75rem; padding: .1rem .45rem; border-radius: 4px; background: var(--azul-suave); color: #005f94; }
.form-paso { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; background: #f8f9fc; padding: 14px; border-radius: var(--radio-sm); border: 1px dashed var(--linea); }
.form-paso .botones { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.gastos-tabla { border: 1px solid var(--linea); border-radius: var(--radio-sm); overflow: auto; }
.gastos-tabla table { font-size: .86rem; }
.gastos-tabla tbody tr { cursor: default; }
.gastos-tabla tfoot td { font-weight: 700; border-bottom: none; }
.gastos-tabla tr.editando td { background: var(--azul-suave); }
.gastos-tabla .acciones-fila { display: flex; gap: 4px; }

/* Monto con selector de moneda */
.monto { display: flex; align-items: stretch; }
.monto select, .monto .sufijo {
  flex: none; border: 1px solid var(--linea); border-right: none; border-radius: var(--radio-sm) 0 0 var(--radio-sm);
  background: #f3f5fa; color: var(--navy); font-weight: 600; font-size: .9rem; padding: 0 .5rem; min-width: 4.4rem;
}
.monto .sufijo { display: flex; align-items: center; justify-content: center; }
.monto input { flex: 1; border-radius: 0 var(--radio-sm) var(--radio-sm) 0 !important; }
.monto select:focus { outline: none; border-color: var(--azul); }

.liquidacion { background: var(--ok-suave); border: 1px solid #bfe6d3; border-radius: var(--radio); padding: 16px; display: grid; gap: 6px; }
.liquidacion .total { font-size: 1.7rem; font-weight: 700; color: var(--ok); }
.liquidacion .linea { display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; }

.dias { font-size: 2rem; font-weight: 700; color: var(--alerta); line-height: 1; }
.dias.vencido { color: var(--peligro); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--tinta); color: #fff; padding: .65rem 1rem; border-radius: var(--radio-sm); z-index: 60; font-size: .92rem; }
.toast.err { background: var(--peligro); }

.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal .caja { position: relative; background: #fff; border-radius: 12px; width: min(520px, 100%); padding: 22px; z-index: 51; display: grid; gap: 14px; }
.modal h3 { margin: 0; }

@media (max-width: 760px) {
  .barra { padding: 0 12px; gap: 10px; height: auto; flex-wrap: wrap; padding-top: 8px; }
  .barra nav { order: 3; width: 100%; height: 44px; }
  .barra .usuario span { display: none; }
  main { padding: 16px; }
  .panel-cab, .panel-cuerpo { padding-left: 16px; padding-right: 16px; }
  .paso .contenido { padding-left: 16px; }
  .linea-vida { grid-template-columns: repeat(5, 1fr); row-gap: 12px; }
  .linea-vida li:nth-child(6)::after { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
