/* Presupuestador (demo): azul de plano para la app, hoja blanca A4 para el presupuesto */
:root {
  --azul: #0c2340; --azul-2: #102c51; --azul-3: #163a68;
  --linea: rgba(140, 190, 255, .14); --linea-2: rgba(140, 190, 255, .3);
  --texto: #eef4ff; --mute: #a8bbd6; --amarillo: #ffd23f; --cian: #6cc9ff; --verde: #2fc86e; --rojo: #ff8a75;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --titulos: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --letra: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--letra); font-size: 16px; line-height: 1.5; color: var(--texto); background: var(--azul); -webkit-font-smoothing: antialiased; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--amarillo); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; top: -100px; left: 1rem; z-index: 999; padding: .6rem 1rem; background: var(--amarillo); color: var(--azul); border-radius: 8px; }
.skip-link:focus { top: 1rem; }

.top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .6rem; padding: .5rem 1rem; background: rgba(12, 35, 64, .97); border-bottom: 1px solid var(--linea-2); }
.volver { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; font-size: 1.3rem; border: 1px solid var(--linea-2); flex-shrink: 0; }
.top-tit { display: flex; align-items: baseline; gap: .45rem; white-space: nowrap; }
.top-tit b { font-family: var(--titulos); font-weight: 900; font-size: 1.45rem; text-transform: uppercase; }
.top-tit b span { color: var(--amarillo); }
.top-tit small { color: var(--mute); font-size: .82rem; }
.top-demo { margin-left: auto; font-size: .76rem; font-weight: 700; color: #111; background: var(--amarillo); padding: .2rem .55rem; border-radius: 999px; white-space: nowrap; }
.top-reset { min-height: 44px; padding: .4rem .7rem; font-size: .82rem; font-weight: 600; color: var(--mute); border: 1px solid var(--linea-2); border-radius: 10px; white-space: nowrap; }
@media (max-width: 460px) { .top-tit small, .chico-oculto { display: none; } .top { gap: .45rem; padding-inline: .75rem; } }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(16, 44, 81, .98); border-top: 1px solid var(--linea-2); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { min-height: 64px; display: grid; justify-items: center; align-content: center; gap: .2rem; font-size: .78rem; font-weight: 600; color: var(--mute); text-align: center; line-height: 1.15; padding: 0 .2rem; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--amarillo); }

.vista { width: min(1200px, 100% - 2rem); margin: 1.2rem auto 2rem; outline: none; }
.vista > section { animation: entra .35s var(--ease); }
@keyframes entra { from { opacity: 0; transform: translateY(8px); } }
.v-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.v-tit { font-family: var(--titulos); font-weight: 900; font-size: 2rem; text-transform: uppercase; line-height: 1; margin-bottom: 1rem; }
.v-head .v-tit { margin: 0; }
.v-tit span { color: var(--amarillo); }
.v-sub { color: var(--mute); margin: -.4rem 0 1rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 46px; padding: .55rem 1rem; border-radius: 8px; font-family: var(--titulos); font-weight: 800; font-size: 1.08rem; letter-spacing: .03em; text-transform: uppercase; transition: transform .2s, background .2s, border-color .2s; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn:active { transform: scale(.96); }
.btn-amarillo { background: var(--amarillo); color: var(--azul); }
.btn-line { border: 1.5px solid var(--linea-2); }
.btn-wa { background: #25d366; color: #06210f; }
.btn-sm { min-height: 44px; font-size: 1rem; }

.caja { border: 1px solid var(--linea-2); border-radius: 14px; background: var(--azul-2); padding: 1rem 1rem 1.1rem; margin: 0 0 1rem; min-width: 0; }
.caja-tit { font-family: var(--titulos); font-weight: 900; font-size: 1.35rem; text-transform: uppercase; padding: 0; margin-bottom: .7rem; float: left; width: 100%; }
.caja > :not(.caja-tit) { clear: both; }  /* todo va debajo del título flotante (si no, las filas se corren al costado) */
.campo { display: grid; gap: .25rem; margin-bottom: .7rem; min-width: 0; }
.campo > span { font-size: .8rem; font-weight: 600; color: var(--mute); }
input, select, textarea { font: inherit; font-size: 16px; color: var(--texto); background: var(--azul); border: 1.5px solid var(--linea-2); border-radius: 8px; padding: .5rem .65rem; min-height: 46px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 80px; }
input[type="number"] { font-family: var(--mono); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--amarillo); box-shadow: 0 0 0 3px rgba(255, 210, 63, .16); }
.dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; align-items: end; }
.tres-col { display: grid; grid-template-columns: 1.2fr .8fr 1fr; gap: .6rem; }
.check { display: flex; align-items: center; gap: .55rem; min-height: 46px; margin-bottom: .7rem; cursor: pointer; font-weight: 600; font-size: .92rem; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--amarillo); flex-shrink: 0; }

/* Ítems */
.items-cab { display: none; }
.items { list-style: none; padding: 0; display: grid; gap: .5rem; }
.item { display: grid; grid-template-columns: 1fr 1fr 1fr 44px; grid-template-areas: "desc desc desc x" "uni can pre x" "sub sub sub sub"; gap: .4rem; padding: .55rem; border-radius: 10px; background: var(--azul); border: 1px solid var(--linea); animation: entra .3s var(--ease); }
.item [data-c="desc"] { grid-area: desc; }
.item [data-c="unidad"] { grid-area: uni; }
.item [data-c="cant"] { grid-area: can; }
.item [data-c="precio"] { grid-area: pre; }
.item-sub { grid-area: sub; font-family: var(--mono); font-size: .86rem; color: var(--cian); text-align: right; }
.item-x { grid-area: x; width: 44px; height: 46px; border-radius: 8px; font-size: 1.4rem; color: var(--mute); align-self: start; }
.item label { display: grid; gap: .15rem; font-size: .76rem; font-weight: 600; color: var(--mute); min-width: 0; }
.items-acc { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.items-acc select { flex: 1 1 220px; width: auto; }

/* Hoja A4 */
.lado-hoja { min-width: 0; }
.hoja-acc { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .5rem; }
.guardado { font-size: .8rem; color: var(--mute); text-align: right; margin-bottom: .6rem; min-height: 1.2em; }
.hoja { background: #fff; color: #182437; border-radius: 4px; padding: 1.6rem 1.4rem; box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .8); font-size: .86rem; line-height: 1.45; }
.h-cab { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; border-bottom: 3px solid #182437; padding-bottom: .8rem; margin-bottom: .9rem; }
.h-marca { display: flex; gap: .7rem; align-items: center; }
.h-logo { width: 46px; height: 46px; border-radius: 8px; background: #0c2340; color: #ffd23f; display: grid; place-items: center; font-family: var(--titulos); font-weight: 900; font-size: 1.4rem; flex-shrink: 0; }
.h-negocio b { display: block; font-family: var(--titulos); font-weight: 900; font-size: 1.5rem; text-transform: uppercase; line-height: 1; }
.h-negocio small { display: block; color: #55637a; font-size: .76rem; }
.h-num { text-align: right; }
.h-num b { display: block; font-family: var(--titulos); font-weight: 900; font-size: 1.25rem; text-transform: uppercase; letter-spacing: .03em; }
.h-num small { display: block; color: #55637a; font-size: .76rem; }
.h-cli { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem 1rem; padding: .7rem .8rem; border-radius: 6px; background: #f2f5fa; margin-bottom: .9rem; }
.h-cli small { display: block; color: #55637a; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
.h-tabla { width: 100%; border-collapse: collapse; margin-bottom: .8rem; }
.h-tabla th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: #55637a; border-bottom: 1.5px solid #182437; padding: .35rem .3rem; }
.h-tabla td { border-bottom: 1px solid #dde3ec; padding: .45rem .3rem; vertical-align: top; }
.h-tabla .n { text-align: right; font-family: var(--mono); font-size: .78rem; white-space: nowrap; }
.h-vacia { color: #8a96a8; text-align: center; padding: 1rem; }
.h-totales { margin-left: auto; width: min(260px, 100%); display: grid; gap: .2rem; margin-bottom: .9rem; }
.h-totales p { display: flex; justify-content: space-between; gap: 1rem; font-family: var(--mono); font-size: .8rem; }
.h-totales .h-total { border-top: 2px solid #182437; padding-top: .35rem; margin-top: .2rem; font-family: var(--titulos); font-weight: 900; font-size: 1.5rem; text-transform: uppercase; }
.h-cond { display: grid; gap: .25rem; font-size: .8rem; color: #33415a; border-top: 1px dashed #b8c2d1; padding-top: .7rem; }
.h-cond b { color: #182437; }
.h-firma { display: flex; justify-content: space-between; gap: 1.5rem; margin-top: 2rem; font-size: .76rem; color: #55637a; }
.h-firma span { flex: 1; border-top: 1px solid #182437; padding-top: .3rem; text-align: center; }
.h-estado { display: inline-block; margin-top: .4rem; font-family: var(--titulos); font-weight: 900; font-size: .95rem; text-transform: uppercase; padding: .05rem .45rem; border: 2px solid; border-radius: 5px; }
.h-estado.Aceptado { color: #1f8a4c; }
.h-estado.Rechazado { color: #b0392a; }
.h-estado.Enviado { color: #1f6fb0; }
.h-estado.Borrador { color: #8a96a8; }

/* Lista de presupuestos */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-bottom: .9rem; }
.kpi { padding: .9rem; border-radius: 12px; background: var(--azul-2); border: 1px solid var(--linea-2); display: grid; gap: .1rem; }
.kpi p { font-size: .8rem; color: var(--mute); }
.kpi b { font-family: var(--titulos); font-weight: 900; font-size: 1.8rem; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi small { font-size: .76rem; color: var(--mute); }
.kpi-ok b { color: var(--verde); }
.kpi-alerta b { color: var(--amarillo); }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .8rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex-shrink: 0; min-height: 40px; padding: .35rem .85rem; border-radius: 999px; border: 1.5px solid var(--linea-2); font-size: .86rem; font-weight: 600; color: var(--mute); }
.chips button[aria-pressed="true"] { background: var(--amarillo); color: var(--azul); border-color: var(--amarillo); }
.filas { list-style: none; padding: 0; display: grid; gap: .5rem; }
.fila { display: grid; grid-template-columns: 1fr auto; gap: .35rem .8rem; align-items: center; padding: .8rem .9rem; border-radius: 12px; background: var(--azul-2); border: 1px solid var(--linea); }
.fila-tit { font-weight: 600; }
.fila-tit small { font-family: var(--mono); color: var(--mute); font-weight: 400; margin-right: .4rem; }
.fila-sub { font-size: .82rem; color: var(--mute); }
.fila-total { grid-column: 2; grid-row: 1; font-family: var(--titulos); font-weight: 900; font-size: 1.35rem; text-align: right; }
.fila-acc { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.fila-acc select { width: auto; min-height: 40px; padding: .3rem .5rem; font-size: .88rem; }
.mini { min-height: 40px; padding: .3rem .7rem; border-radius: 8px; font-size: .84rem; font-weight: 700; border: 1.5px solid var(--linea-2); }
.mini.wa { background: #25d366; color: #06210f; border-color: #25d366; }
.estado { font-size: .76rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; margin-left: .3rem; }
.e-Aceptado { background: rgba(47, 200, 110, .16); color: #7ee3a6; }
.e-Enviado { background: rgba(108, 201, 255, .14); color: var(--cian); }
.e-Rechazado { background: rgba(255, 138, 117, .15); color: var(--rojo); }
.e-Borrador { background: rgba(168, 187, 214, .14); color: var(--mute); }
.vacio { color: var(--mute); text-align: center; padding: 1.4rem; }

/* Lista de precios */
.aumento { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.aumento .campo { margin: 0; width: 140px; }
.aumento-pct { font-family: var(--titulos); font-weight: 900; font-size: 1.6rem; padding-bottom: .3rem; }
.aumento-ej { width: 100%; font-size: .84rem; color: var(--mute); }
.cat { list-style: none; padding: 0; display: grid; gap: .45rem; margin-bottom: .8rem; }
.cat li { display: grid; grid-template-columns: 1fr 90px 120px 44px; gap: .4rem; align-items: center; padding: .45rem; border-radius: 10px; background: var(--azul-2); border: 1px solid var(--linea); }
.cat .x { width: 44px; height: 46px; border-radius: 8px; color: var(--mute); font-size: 1.4rem; }
.cat .sube { animation: sube .7s var(--ease); }
@keyframes sube { 0% { background: rgba(255, 210, 63, .35); } }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 90; transform: translateX(-50%); max-width: calc(100% - 2rem); padding: .75rem 1.1rem; border-radius: 10px; background: var(--amarillo); color: var(--azul); font-weight: 700; box-shadow: 0 16px 40px -10px rgba(0, 0, 0, .8); }

@media (hover: hover) {
  .tabs button:hover { color: var(--texto); }
  .item-x:hover, .cat .x:hover { color: var(--rojo); }
}
@media (max-width: 520px) {
  .cat li { grid-template-columns: 1fr 1fr 44px; grid-template-areas: "n n x" "u p x"; }
  .cat li > :nth-child(1) { grid-area: n; } .cat li > :nth-child(2) { grid-area: u; } .cat li > :nth-child(3) { grid-area: p; } .cat li > :nth-child(4) { grid-area: x; }
  .tres-col { grid-template-columns: 1fr 1fr; }
  .tres-col > :first-child { grid-column: 1 / -1; }
  .hoja { padding: 1.1rem .9rem; }
  .h-cli { grid-template-columns: 1fr; }
}
@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fila { grid-template-columns: 1fr auto auto; }
  .fila-acc { grid-column: 3; grid-row: 1 / span 2; justify-content: flex-end; }
  .fila-total { grid-row: 1 / span 2; }
}
@media (min-width: 760px) {
  .items-cab { display: grid; grid-template-columns: 1fr 78px 72px 104px 110px 40px; gap: .4rem; padding: 0 .55rem .3rem; font-size: .76rem; font-weight: 600; color: var(--mute); }
  .item { grid-template-columns: 1fr 78px 72px 104px 110px 40px; grid-template-areas: "desc uni can pre sub x"; align-items: center; padding: .4rem .55rem; }
  .item label > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .item-sub { text-align: right; }
  .item-x { align-self: center; width: 40px; }
}
@media (min-width: 1060px) {
  body { padding-bottom: 0; }
  .tabs { position: sticky; top: 61px; bottom: auto; display: flex; justify-content: center; gap: .3rem; border-top: 0; border-bottom: 1px solid var(--linea-2); background: rgba(12, 35, 64, .97); padding: .3rem 0; }
  .tabs button { min-height: 48px; grid-auto-flow: column; gap: .5rem; padding: 0 1.1rem; border-radius: 10px; font-size: .92rem; }
  .tabs button[aria-current="page"] { background: rgba(255, 210, 63, .1); }
  .editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.4rem; align-items: start; }
  .lado-hoja { position: sticky; top: 132px; }
  /* con dos columnas, cada trabajo en dos renglones: la descripción entera arriba y los números abajo */
  .items-cab { display: none; }
  .item { grid-template-columns: 84px 76px 1fr 1fr 40px; grid-template-areas: "desc desc desc desc x" "uni can pre sub x"; align-items: end; padding: .5rem .55rem; }
  .item label > span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .item-sub { align-self: center; padding-top: 1rem; }
  .toast { bottom: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .vista > section, .item, .cat .sube { animation: none; }
}

/* Imprimir: solo la hoja del presupuesto, en A4 */
@page { size: A4; margin: 14mm; }
@media print {
  body { background: #fff; padding: 0; }
  .top, .tabs, .formu, .hoja-acc, .guardado, .v-head, .toast, .skip-link { display: none !important; }
  .vista { width: auto; margin: 0; }
  .editor { display: block; }
  .hoja { box-shadow: none; padding: 0; font-size: 10.5pt; }
}
