:root {
  --navy: #0E1B2B; --navy-2: #132438; --navy-3: #1A2F47;
  --azul: #1F66B5; --azul-osc: #174f8c; --azul-claro: #E7F0FA;
  --verde: #1F7A4D; --verde-claro: #E3F4EA;
  --amarillo: #F5B800; --amarillo-claro: #FFF6D6;
  --rojo: #B3261E; --rojo-claro: #FCE8E6;
  --fondo: #F2F5F8; --hoja: #FFFFFF; --texto: #16283A; --gris: #5D6E7E; --linea: #DDE5EC;
  --radio: 12px; --sombra: 0 1px 2px rgba(14, 27, 43, .06), 0 4px 16px rgba(14, 27, 43, .06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); font-size: 16px; line-height: 1.5; }
a { color: var(--azul); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Barra superior */
.barra { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; }
.barra-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 10px 20px; }
.marca { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: .2px; }
.marca img { width: 36px; height: 36px; border-radius: 9px; }
.marca small { color: #6BD39A; font-weight: 800; }
.menu { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.menu a { color: #B3C3D2; text-decoration: none; padding: 9px 14px; border-radius: 10px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.menu a:hover { background: var(--navy-3); color: #fff; }
.menu a.activo { background: var(--azul); color: #fff; }
.menu svg { width: 18px; height: 18px; }
.estado { margin-left: auto; border: 0; border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }
.estado.activa { background: #1F7A4D; color: #fff; }
.estado.lectura, .estado.verificar { background: var(--amarillo); color: var(--navy); }
.estado.sin, .estado.suspendida { background: #fff; color: var(--navy); }

/* Avisos de toda la app */
.aviso { max-width: 1180px; margin: 14px auto 0; padding: 12px 18px; border-radius: var(--radio); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.aviso p { margin: 0; flex: 1; min-width: 240px; }
.aviso.amarillo { background: var(--amarillo-claro); border: 1px solid #F0D27A; }
.aviso.rojo { background: var(--rojo-claro); border: 1px solid #F3B8B3; }
.aviso.azul { background: var(--azul-claro); border: 1px solid #B9D3EF; }

main:focus { outline: none; }
main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
h1 { font-size: 26px; margin: 4px 0 6px; }
h2 { font-size: 20px; margin: 0 0 10px; }
h3 { font-size: 17px; margin: 0 0 8px; }
.sub { color: var(--gris); margin: 0 0 18px; }
.ayuda { color: var(--gris); font-size: 14px; margin: 6px 0 0; }

.tarjeta { background: var(--hoja); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); padding: 20px; margin-bottom: 16px; }
.fila { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.entre { justify-content: space-between; }
.rejilla { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Botones grandes y obvios */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 20px; border-radius: 10px; border: 1.5px solid var(--linea);
  background: #fff; font-weight: 700; cursor: pointer; text-decoration: none; color: var(--texto); }
.btn:hover { border-color: var(--azul); }
.btn.prim { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn.prim:hover { background: var(--azul-osc); }
.btn.verde { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn.peligro { color: var(--rojo); border-color: #F3B8B3; }
.btn.grande { min-height: 56px; font-size: 18px; padding: 12px 26px; }
.btn.chico { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn[disabled], .btn.bloqueado { opacity: .5; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; }

/* Proyectos */
.proyecto { cursor: pointer; transition: transform .08s; display: flex; flex-direction: column; gap: 6px; }
.proyecto:hover { transform: translateY(-2px); border-color: var(--azul); }
.proyecto .nom { font-weight: 800; font-size: 17px; }
.proyecto .dato { color: var(--gris); font-size: 14px; }
.nuevo { border: 2px dashed #B9D3EF; background: var(--azul-claro); color: var(--azul); display: flex; align-items: center; justify-content: center; min-height: 140px; font-weight: 800; font-size: 18px; cursor: pointer; border-radius: var(--radio); }
.nuevo:hover { border-color: var(--azul); }
.nuevo svg { width: 26px; height: 26px; }
.vacio { text-align: center; padding: 50px 20px; }
.vacio svg { width: 64px; height: 64px; color: var(--azul); }

/* Formularios */
label { display: block; font-weight: 700; margin: 12px 0 6px; }
input[type=text], input[type=email], input[type=search], select, textarea { width: 100%; min-height: 46px; padding: 10px 14px; border: 1.5px solid var(--linea); border-radius: 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px var(--azul-claro); }

/* Base de APUs */
.buscador { display: flex; gap: 10px; margin-bottom: 14px; }
.buscador input { font-size: 17px; }
.caps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.cap { border: 1px solid var(--linea); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.cap.activo { background: var(--azul); color: #fff; border-color: var(--azul); }
.cap b { font-weight: 700; color: var(--gris); margin-left: 4px; }
.cap.activo b { color: #dbe8f6; }
table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
.t th { text-align: left; background: #F6F9FB; color: var(--gris); font-weight: 700; font-size: 13px; padding: 9px 10px; border-bottom: 1px solid var(--linea); position: sticky; top: 0; }
.t td { padding: 9px 10px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: var(--azul-claro); }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t .cod { color: var(--gris); width: 70px; }
.t tfoot td { font-weight: 800; background: #F6F9FB; }
.seccion { margin-top: 18px; }
.seccion h3 { color: var(--azul); }
.basico { color: var(--verde); font-size: 12px; font-weight: 700; border: 1px solid #9fd3b6; border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.totales { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 18px; }
.totales div { background: #F6F9FB; border-radius: 10px; padding: 12px; }
.totales small { color: var(--gris); display: block; }
.totales b { font-size: 18px; }
.totales .vu { background: var(--navy); color: #fff; }
.totales .vu small { color: #B3C3D2; }

/* Cuenta */
.datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.datos div { background: #F6F9FB; border-radius: 10px; padding: 12px 14px; }
.datos small { color: var(--gris); display: block; font-size: 13px; }
.datos b { font-size: 16px; }
.equipo { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--linea); }
.equipo:last-child { border-bottom: 0; }
.equipo svg { width: 30px; height: 30px; color: var(--azul); flex: none; }
.equipo .info { flex: 1; }
.equipo small { color: var(--gris); display: block; }
.etiqueta { background: var(--verde-claro); color: var(--verde); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 800; margin-left: 6px; }
.opcion { border: 2px solid var(--linea); border-radius: var(--radio); padding: 18px; cursor: pointer; background: #fff; text-align: left; width: 100%; }
.opcion:hover, .opcion.elegida { border-color: var(--azul); background: var(--azul-claro); }
.opcion .precio { font-size: 26px; font-weight: 800; color: var(--navy); }
.opcion .nombre { font-weight: 800; font-size: 18px; }

/* Bienvenida */
.bienvenida { display: grid; grid-template-columns: 1.1fr .9fr; gap: 28px; align-items: center; }
.bienvenida h1 { font-size: 34px; line-height: 1.2; }
.ventajas { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; }
.ventajas li { display: flex; gap: 10px; align-items: flex-start; }
.ventajas svg { width: 22px; height: 22px; color: var(--verde); flex: none; margin-top: 2px; }
.caja-entrar { text-align: center; }
.caja-entrar img { width: 200px; height: 200px; border-radius: 18px; margin-bottom: 4px; }
#btnGoogle { display: flex; justify-content: center; min-height: 48px; margin: 14px 0 6px; }

/* Ventana modal */
dialog.hoja { border: 0; border-radius: 16px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog.hoja::backdrop { background: rgba(14, 27, 43, .55); }
.modal-cuerpo { padding: 24px; }
.modal-pie { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(520px, 92vw); }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--sombra); font-weight: 600; }
.toast.error { background: var(--rojo); }

.cargando { display: flex; justify-content: center; padding: 60px; }
.giro { width: 34px; height: 34px; border: 4px solid var(--linea); border-top-color: var(--azul); border-radius: 50%; animation: g 0.8s linear infinite; display: inline-block; }
@keyframes g { to { transform: rotate(360deg); } }
.pie-app { text-align: center; color: var(--gris); font-size: 13px; margin-top: 30px; }

@media (max-width: 820px) {
  .barra-in { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .menu { order: 3; flex: 1 1 100%; margin: 0; overflow-x: auto; justify-content: space-around; }
  .menu a span { display: inline; font-size: 14px; }
  .menu a { padding: 8px 10px; }
  .bienvenida { grid-template-columns: 1fr; }
  main { padding: 16px 12px 50px; }
}

/* Editor del presupuesto (tabla tipo Excel) */
.ed-cab h1 { margin-bottom: 2px; }
.ed-estado { font-size: 13px; color: var(--gris); margin-left: 10px; }
.ed-estado.ok { color: var(--verde); }
.ed-estado.ok::before { content: "✓ "; }
.ed-barra { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 12px; position: sticky; top: 56px; z-index: 5; background: var(--fondo); padding: 8px 0; }
.ed-hoja { padding: 0; overflow: auto; max-height: calc(100vh - 230px); }
table.ed { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 15px; }
.ed th { position: sticky; top: 0; z-index: 2; background: #EEF3F8; color: var(--gris); font-size: 13px; font-weight: 700; text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--linea); }
.ed th.num { text-align: right; }
.ed td { border-bottom: 1px solid #E8EEF3; border-right: 1px solid #F0F4F7; padding: 0; height: 38px; vertical-align: middle; }
.ed td.it { padding: 0 8px; color: var(--gris); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ed td.num, .ed .tot { text-align: right; padding: 0 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ed input { width: 100%; height: 38px; border: 0; background: transparent; padding: 0 8px; font: inherit; color: inherit; outline: none; border-radius: 0; }
.ed input.num { text-align: right; font-variant-numeric: tabular-nums; }
.ed input:focus { background: #fff; box-shadow: inset 0 0 0 2px var(--azul); }
.ed input[readonly]:focus { box-shadow: inset 0 0 0 2px var(--linea); }
.ed tr.cap td { background: #E3EDF8; font-weight: 800; }
.ed tr.cap input { font-weight: 800; color: var(--navy); }
.ed tr.sub td { background: #F3F7FB; font-weight: 700; }
.ed tr.sel td.it { box-shadow: inset 4px 0 0 var(--azul); }
.ed tr.item:hover td { background: #FAFCFE; }
.ed td.vu { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding-right: 10px; border-right: 0; }
.ed td.vu span.num { padding: 0; }
.pliega { border: 0; background: transparent; cursor: pointer; font-size: 13px; color: var(--azul); padding: 0 4px 0 0; }
.mas { border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--gris); width: 100%; height: 38px; }
.mas:hover { background: var(--azul-claro); color: var(--azul); }
.apu-chip { border: 1px solid #9fd3b6; background: var(--verde-claro); color: var(--verde); border-radius: 6px; font-size: 11px; font-weight: 800; padding: 1px 6px; cursor: pointer; }
.menu-ctx { position: fixed; z-index: 60; background: #fff; border: 1px solid var(--linea); border-radius: 10px; box-shadow: 0 12px 32px rgba(14,27,43,.18); padding: 6px; width: 240px; }
.menu-ctx button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.menu-ctx button:hover { background: var(--azul-claro); }
.menu-ctx button.peligro { color: var(--rojo); }
.menu-ctx hr { border: 0; border-top: 1px solid var(--linea); margin: 4px 0; }
.ed-pie { display: grid; grid-template-columns: 1fr 470px; gap: 20px; align-items: start; margin-top: 16px; }
.resumen h3 { margin-bottom: 10px; }
.r-fila { display: grid; grid-template-columns: minmax(0, 1fr) 96px 150px; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #EEF2F6; }
.r-fila b { text-align: right; font-variant-numeric: tabular-nums; }
.r-pct { white-space: nowrap; color: var(--gris); }
.r-pct input { width: 54px; min-height: 34px; padding: 4px 8px; text-align: right; border: 1.5px solid var(--linea); border-radius: 8px; }
.r-pct small { display: block; font-size: 11px; }
.r-fila.cd { font-weight: 700; }
.r-fila.total { border-bottom: 0; background: var(--navy); color: #fff; border-radius: 10px; padding: 12px 14px; margin-top: 8px; font-size: 18px; grid-template-columns: minmax(0, 1fr) 0 auto; }
.r-fila span:first-child { white-space: nowrap; }
.letras { color: var(--gris); font-size: 14px; font-style: italic; margin: 10px 0 0; }
dialog.hoja.ancha { width: min(900px, 96vw); }
.lista-apu { max-height: 52vh; overflow: auto; border: 1px solid var(--linea); border-radius: 10px; }
.apu-op { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--linea); }
.apu-op .num { font-variant-numeric: tabular-nums; font-weight: 700; }
.logo-vista { width: 160px; height: 70px; border: 1.5px dashed var(--linea); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--gris); font-size: 13px; background: #fff; }
.logo-vista img { max-width: 150px; max-height: 62px; object-fit: contain; }
.pila-op { display: grid; gap: 10px; }
textarea { width: 100%; padding: 10px 14px; border: 1.5px solid var(--linea); border-radius: 10px; font: inherit; resize: vertical; }
@media (max-width: 980px) { .ed-pie { grid-template-columns: 1fr; } .ed-hoja { max-height: none; } }
