:root {
  --nav: #1c2f4f;
  --nav2: #243a5e;
  --teal: #4b7371;
  --teal-osc: #3b5d5b;
  --verde: #9dbd96;
  --texto: #1c2f4f;
  --muestra: #4b7a6e;
  --gris: #a9acb2;
  --borde: #4a6f6f;
  --suave: #667085;
  --rojo: #d92d20;
  --fondo: #ffffff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); font: 18px/1.3 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; text-align: left; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; color: var(--texto); width: 100%; min-width: 0; padding: 0 14px; height: 52px; border: 3px solid var(--borde); border-radius: 14px; background: #fff; }
textarea { height: auto; padding: 10px 14px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--nav); box-shadow: 0 0 0 2px #cfe0dd; }
input[readonly] { background: #f6f8f8; }
select { padding-right: 6px; text-overflow: ellipsis; }
.num { text-align: right; }
small { font-size: 14px; color: var(--suave); font-weight: 400; }
.rojo { color: var(--rojo); }
.ast { color: var(--rojo); font-weight: 800; }

/* Barra superior y pestañas */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; height: calc(58px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; background: var(--nav); color: #fff; }
.top h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; font-size: 26px; color: #fff; text-align: center; padding: 0; }
.top .ic:active { background: rgba(255,255,255,.18); }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #fdb022; color: #4a2b00; font-weight: 700; white-space: nowrap; }
.tabs { position: sticky; top: calc(58px + env(safe-area-inset-top)); z-index: 4; display: flex; overflow-x: auto; background: var(--nav); border-top: 1px solid var(--nav2); box-shadow: 0 2px 4px rgba(0,0,0,.15); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; padding: 18px 20px 14px; font-size: 17px; font-weight: 600; color: rgba(255,255,255,.62); border-bottom: 4px solid transparent; letter-spacing: .2px; }
.tab.act { color: #fff; border-bottom-color: #fff; }

/* Menú lateral */
.m-fondo { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
.menu { position: fixed; top: 0; bottom: 0; left: 0; width: min(74vw, 320px); z-index: 31; background: var(--nav); color: #fff; display: flex; flex-direction: column; padding: calc(24px + env(safe-area-inset-top)) 0 calc(16px + env(safe-area-inset-bottom)); }
.m-cab { display: flex; align-items: center; gap: 18px; padding: 0 22px 30px; font-size: 20px; line-height: 1.25; }
.m-item { display: flex; align-items: center; gap: 22px; padding: 16px 22px; font-size: 19px; color: #fff; width: 100%; }
.m-item:active { background: rgba(255,255,255,.12); }
.m-ico { font-size: 30px; display: grid; place-items: center; width: 34px; }
.m-ico.grande { font-size: 56px; width: 60px; }
.m-pie { margin-top: auto; }

/* Contenido */
main.pad { padding: 18px 16px 120px; max-width: 560px; margin: 0 auto; }
main.home { padding: 20px 16px 40px; max-width: 560px; margin: 0 auto; text-align: center; }
.ayuda { color: var(--suave); font-size: 14px; margin: 10px 2px; }
.vacio { color: var(--suave); text-align: center; padding: 16px 0; margin: 0; }
.pie { text-align: center; color: var(--suave); font-size: 12px; margin-top: 24px; }
.alerta { background: #fffaeb; border: 1px solid #fedf89; color: #b54708; border-radius: 12px; padding: 12px; margin: 10px 0; font-size: 15px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); margin: 22px 2px 8px; }
h3 { margin: 0 0 4px; font-size: 20px; }

/* Home */
.logo-box { display: grid; place-items: center; min-height: 190px; padding: 10px 0 18px; }
.logo { max-width: 78%; max-height: 220px; object-fit: contain; }
.logo-txt { text-align: center; color: var(--nav); }
.logo-txt b { display: block; font-size: 54px; letter-spacing: 3px; font-weight: 900; }
.logo-txt small { letter-spacing: 6px; font-size: 14px; color: var(--teal); font-weight: 700; }
.grilla-home { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px 20px; max-width: 420px; margin: 8px auto 0; padding: 0 6px; }
.cuad { position: relative; aspect-ratio: 1.25; display: grid; place-items: center; font-size: 44px; color: #fff; background: var(--teal); border-radius: 22px; padding: 0; }
.cuad:active { filter: brightness(.88); }
.cuad.verde { background: var(--verde); }
.cuad.gris { background: var(--gris); }
.cuad.aviso-b { background: #d98a1f; }
.cuad:disabled { opacity: .7; }
.cuad.gira svg { animation: gira 1s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.cont { position: absolute; top: -8px; right: -8px; min-width: 26px; height: 26px; padding: 0 6px; display: grid; place-items: center; border-radius: 13px; background: var(--rojo); color: #fff; font-size: 14px; font-style: normal; font-weight: 700; }
.estado-home { margin: 26px 0 10px; font-size: 15px; color: var(--suave); line-height: 1.6; }

/* Formularios (etiqueta a la izquierda, campo a la derecha) */
.fila-f { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.fila-f > .et { flex: 0 0 34%; font-size: 19px; font-weight: 500; color: var(--texto); }
.fila-f > .ct { flex: 1; min-width: 0; }
.fila-f.col { flex-direction: column; align-items: stretch; gap: 6px; }
.fila-f.col > .et { flex: none; font-size: 15px; color: var(--suave); }
.fila-f.col > .et.chico { font-size: 14px; margin-bottom: -4px; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.dos .fila-f > .et { flex: 0 0 auto; }
.dos .fila-f { gap: 8px; }
.dos .fila-f.col { align-items: stretch; }
.pedido-form .dos .fila-f > .et { font-size: 18px; }
.muestra { margin: -6px 0 14px; padding: 0 2px; font-size: 21px; color: var(--muestra); min-height: 28px; font-weight: 500; }
.muestra small { color: var(--suave); }
.lupa { flex: 0 0 52px; height: 52px; display: grid; place-items: center; font-size: 26px; color: #fff; background: var(--teal); border-radius: 14px; padding: 0; text-align: center; }
.lupa.texto { font-size: 20px; font-weight: 700; flex-basis: 50px; }
.lupa:active { background: var(--teal-osc); }
.precios-fila { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; }
.precios-fila select { font-size: 16px; }

.pastilla { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 20px auto 16px; padding: 0 28px; height: 56px; min-width: 62%; border-radius: 28px; background: var(--teal); color: #fff; font-size: 19px; font-weight: 500; text-align: center; }
.pastilla:active { background: var(--teal-osc); }
.pastilla:disabled { background: var(--gris); }
.pastilla.chica { height: 46px; min-width: 0; margin: 10px 6px; padding: 0 22px; font-size: 17px; text-decoration: none; display: inline-flex; }
.pastilla.gris-b { background: var(--gris); }
.pastilla.grande-b { width: 70%; }
.ic-in { font-size: 24px; display: inline-grid; }
.botones-modo { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; margin: 0 0 22px; }
.botones-modo .pastilla { margin: 4px 0; min-width: 120px; }
.link { color: var(--teal); text-align: center; width: 100%; padding: 14px; text-decoration: underline; }
.peligro { display: block; background: #fee4e2; color: var(--rojo); font-weight: 600; padding: 14px 16px; border-radius: 28px; text-align: center; width: 100%; margin: 12px 0; }

.total-box { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 0; padding: 0 18px; height: 56px; border: 3px solid var(--borde); border-radius: 14px; font-size: 20px; }
.total-box b { font-weight: 600; }
.pie-botones { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-between; gap: 12px; padding: 12px 34px calc(14px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #eef0f2; max-width: 600px; margin: 0 auto; }
.bot-cuad { position: relative; flex: 1; max-width: 130px; height: 58px; display: grid; place-items: center; font-size: 32px; color: #fff; background: var(--nav); border-radius: 18px; padding: 0; }
.bot-cuad.gris { background: var(--gris); }
.bot-cuad:active:not(:disabled) { filter: brightness(1.3); }

/* Buscadores y listas */
.busca { margin-bottom: 14px; font-size: 19px; }
.res { display: grid; gap: 3px; width: 100%; padding: 12px 6px; border-bottom: 1px solid #e3e8e8; border-radius: 0; }
.res:active { background: #eef4f3; }
.res b { font-weight: 600; overflow-wrap: anywhere; }
.res.est:active { background: none; }
.res-fila { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.res-fila .precio { color: var(--muestra); white-space: nowrap; }
.lineas { display: grid; gap: 0; margin-bottom: 12px; }
.linea { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 6px; border-bottom: 1px solid #e3e8e8; }
.linea:active:not(.estatica) { background: #eef4f3; }
.linea-l { display: grid; gap: 2px; min-width: 0; }
.linea-r { font-weight: 700; white-space: nowrap; }
.total-fila { display: flex; justify-content: space-between; font-size: 20px; padding: 12px 4px; font-weight: 600; }
.nota { background: #f6f8f8; border-radius: 12px; padding: 12px; }
.card-r { display: grid; gap: 4px; padding: 14px 16px; margin: 0 0 14px; border: 3px solid var(--borde); border-radius: 14px; }
.card-r b { font-size: 22px; font-weight: 600; }
.card-r b.corto { font-size: 14px; word-break: break-all; font-weight: 500; }
.card-r span { font-size: 20px; color: var(--muestra); font-weight: 600; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.pend { background: #fef0c7; color: #b54708; }
.badge.env { background: #dbe6ff; color: #1c2f4f; }
.badge.imp { background: #d1fadf; color: #12945a; }
.acciones { display: grid; gap: 8px; margin: 10px 0; }

/* Barra inferior del carrito */
.barra { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; align-items: center; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #e3e8e8; max-width: 600px; margin: 0 auto; }
.barra-total { flex: 1; display: grid; }
.barra-total b { font-size: 22px; }
.barra .pastilla { margin: 0; min-width: 0; flex: 1.3; padding: 0 16px; }

/* Hoja */
.fondo { position: fixed; inset: 0; background: rgba(16,24,40,.5); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: #fff; border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); max-width: 600px; margin: 0 auto; box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
.sheet.lista-op { max-height: 80vh; display: flex; flex-direction: column; }
.op-scroll { overflow-y: auto; margin: 8px 0; }
.cant { display: flex; align-items: center; gap: 12px; margin: 12px 0 16px; }
.cant input { text-align: center; font-size: 28px; font-weight: 700; }
.mm { flex: 0 0 64px; height: 52px; border-radius: 14px; background: var(--teal); color: #fff; font-size: 30px; text-align: center; padding: 0; }
.sheet-bot { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; align-items: center; }
.sheet-bot .pastilla, .sheet-bot .peligro { margin: 0; min-width: 0; }

.aviso { position: fixed; left: 12px; right: 12px; top: calc(70px + env(safe-area-inset-top)); z-index: 40; max-width: 560px; margin: 0 auto; background: #101828; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.aviso.mal { background: var(--rojo); }

.linea { flex-wrap: wrap; align-items: center; }
.linea-bot { flex: 0 0 100%; display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.mini { width: 46px; height: 40px; display: grid; place-items: center; font-size: 22px; color: #fff; background: var(--teal); border-radius: 12px; padding: 0; }
.mini.rojo-b { background: #d92d20; }

/* Carrito: tarjetas verdes como en la app anterior */
.tarj { display: grid; gap: 8px; width: 100%; margin: 0 0 14px; padding: 14px 18px; background: var(--verde); color: #fff; border-radius: 26px; font-size: 19px; text-align: left; }
.tarj:active { filter: brightness(.93); }
.tarj-fila { display: flex; gap: 38px; align-items: baseline; }
.tarj-fila b { font-weight: 500; }
.tarj-desc { font-size: 20px; line-height: 1.25; }
.tarj-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.tarj-cols.vals { text-align: center; }
.tarj-cols.vals b { font-weight: 500; }
.tarj-obs { font-size: 14px; opacity: .9; }
.tarj .ast { color: #b42318; }
.ayuda.tocar { text-align: center; margin: 0 0 14px; }
.barra.dos-bot { justify-content: space-between; gap: 12px; }
.barra.dos-bot .pastilla { margin: 0; flex: 1; min-width: 0; height: 52px; }
.pastilla.verde-b { background: var(--verde); }
.barra.dos-bot .pastilla { padding: 0 10px; font-size: 17px; white-space: nowrap; }

.volver-fila { display: flex; justify-content: center; }
.volver-fila .pastilla { margin: 18px auto 8px; min-width: 56%; height: 50px; }

/* ---- Presupuesto en el momento */
.pastilla.presu-b { background: var(--nav); }
.pastilla.presu-b:active { background: var(--nav2); }
.presu-hojas { display: grid; gap: 12px; margin: 6px 0 4px; }
.presu-hoja { display: block; border: 1px solid #d9dee6; border-radius: 6px; overflow: hidden; box-shadow: 0 2px 8px rgba(28, 47, 79, .15); background: #fff; }
.presu-hoja img { display: block; width: 100%; height: auto; }
.presu .pastilla.chica { display: flex; margin: 14px auto 0; }
