﻿:root {
  --navy: #1f3a5f; --navy2: #2b4c78; --gold: #f0b429; --bg: #f3f5f8; --card: #fff;
  --ink: #1d2733; --muted: #6b7785; --line: #e1e6ec; --red: #c0392b; --green: #1e8e5a; --blue: #2a6bc4;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Roboto, "Segoe UI", system-ui, Arial, sans-serif; font-size: 16px; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
#view { max-width: 640px; margin: 0 auto; padding: 0 14px 24px; }

/* Barra superior */
.bar { position: sticky; top: 0; z-index: 5; background: var(--navy); color: #fff; margin: 0 -14px 14px; padding: 14px 16px; display: flex; align-items: center; gap: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.bar h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 600; }
.bar .sub { font-size: 12px; color: var(--gold); letter-spacing: .5px; text-transform: uppercase; font-weight: 600; }
.bar .back { background: none; border: 0; color: #fff; font-size: 30px; line-height: 1; padding: 0 8px 4px 0; }

/* Navegación inferior */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
.tabs a { flex: 1; text-align: center; padding: 8px 2px 9px; font-size: 11.5px; color: var(--muted); text-decoration: none; font-weight: 600; }
.tabs a span { display: block; font-size: 21px; margin-bottom: 2px; }
.tabs a.on { color: var(--navy); }
.tabs a.tab-new span { background: var(--gold); color: var(--navy); width: 40px; height: 32px; line-height: 32px; border-radius: 12px; margin: 0 auto 2px; font-weight: 800; }

/* Tarjetas y formularios */
.card { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(20,40,70,.08); }
h2.sec { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 4px 8px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label small { font-weight: 400; }
input, textarea, select { display: block; width: 100%; margin-top: 5px; font: inherit; font-size: 16px; color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; }
input:focus, textarea:focus { outline: none; border-color: var(--navy2); box-shadow: 0 0 0 3px rgba(43,76,120,.15); }
textarea { resize: vertical; min-height: 84px; line-height: 1.4; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 500; font-size: 14.5px; }
label.check input { width: 22px; height: 22px; margin: 0; flex: none; }
.money { font-variant-numeric: tabular-nums; }
input.big { font-size: 20px; font-weight: 700; color: var(--navy); }

.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; text-align: center; text-decoration: none; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:disabled { background: #8a9bb2; }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.sec { background: #e6edf5; color: var(--navy); }
.btn.big { font-size: 17px; padding: 17px; margin-bottom: 10px; }
.btn.small { padding: 10px; font-size: 14px; }
.btn.wa { background: #1fa855; color: #fff; }
.link { background: none; border: 0; color: var(--blue); font: inherit; font-weight: 600; font-size: 14px; padding: 6px 0; cursor: pointer; }
.link.danger { color: var(--red); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Lista */
.search { margin-bottom: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 20px; padding: 7px 13px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.pcard { display: block; text-decoration: none; color: inherit; }
.pcard .top-line { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pcard .cli { font-weight: 700; font-size: 16.5px; }
.pcard .trab { color: var(--muted); font-size: 14px; margin-top: 2px; }
.pcard .bottom-line { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.pcard .tot { font-weight: 800; font-size: 18px; color: var(--navy); }
.pcard .num { font-size: 12px; color: var(--muted); }
.saldo { font-size: 12.5px; font-weight: 700; color: var(--red); }

.badge { display: inline-block; border-radius: 20px; padding: 4px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.amarillo { background: #fff3cd; color: #8a6100; }
.azul { background: #dde9fb; color: #1d4f99; }
.verde { background: #d8f2e4; color: #146c43; }
.gris { background: #e8eaed; color: #5b6570; }

/* Detalle */
.head-card .cli { font-size: 21px; font-weight: 800; }
.bigtotal { font-size: 30px; font-weight: 800; color: var(--navy); margin-top: 10px; }
.estados { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.est { border: 2px solid transparent; border-radius: 10px; padding: 9px 2px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; opacity: .55; }
.est.on { opacity: 1; border-color: currentColor; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv { gap: 12px; align-items: baseline; }
.kv b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv.saldo-row b { color: var(--red); font-size: 18px; }
.kv.ok b { color: var(--green); }
.cobro { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.cobro .x { background: none; border: 0; color: var(--red); font-size: 20px; padding: 0 4px 0 10px; }
.addcobro { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.addcobro input { margin: 0; }
.addcobro .full { grid-column: 1 / -1; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }

.preview { background: #dfe4ea; border-radius: 12px; padding: 10px; overflow: hidden; }
.preview-inner { transform-origin: top left; box-shadow: 0 2px 10px rgba(0,0,0,.15); }

/* Editor */
.item-ed { border-left: 4px solid var(--navy); }
.item-ed.is-opt { border-left-color: var(--gold); background: #fffcf3; }
details.calc { background: #f5f7fa; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
details.calc summary { font-weight: 700; color: var(--navy); cursor: pointer; font-size: 14.5px; }
details.calc summary small { color: var(--muted); font-weight: 400; }
.mats { margin-top: 10px; }
.mat { display: grid; grid-template-columns: minmax(0, 1fr) 50px 96px 24px; gap: 6px; margin-bottom: 6px; align-items: center; }
.mat input { margin: 0; padding: 9px 8px; font-size: 15px; }
.mat .x { background: none; border: 0; color: var(--red); font-size: 22px; padding: 0; }
.calc-row { display: flex; justify-content: space-between; padding: 8px 2px; font-size: 14.5px; }
.calc-row.big { font-size: 16px; border-top: 1.5px solid var(--line); margin-bottom: 8px; }
.calc-row b { color: var(--navy); }
.plantillas { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.plantillas span { width: 100%; font-size: 13px; font-weight: 700; color: var(--muted); }
.totbar { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 10px 10px 10px 16px; box-shadow: 0 -2px 14px rgba(20,40,70,.15); margin-top: 8px; }
.totbar div { flex: 1; }
.totbar small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.totbar b { font-size: 21px; color: var(--navy); }
.totbar .btn { width: auto; padding: 13px 26px; }

.stat { text-align: center; }
.stat small { display: block; color: var(--muted); font-weight: 600; font-size: 13px; }
.stat b { display: block; font-size: 26px; color: var(--navy); margin-top: 4px; }
.stat.red b { color: var(--red); }
.stat.green b { color: var(--green); }

#toast { position: fixed; left: 50%; top: 74px; transform: translateX(-50%) translateY(20px); background: #1d2733; color: #fff; padding: 11px 18px; border-radius: 22px; font-size: 14.5px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Hoja del PDF (mismo diseño aprobado) ============ */
.pdf-host { position: fixed; left: -10000px; top: 0; width: 794px; }
.pdf { width: 794px; background: #fff; color: #1d2733; font-family: "Segoe UI", Roboto, Arial, sans-serif; font-size: 14.5px; line-height: 1.35; }
.pdf * { box-sizing: border-box; }
.pdf .top { background: #1f3a5f; color: #fff; padding: 40px 60px 26px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.pdf .brand .name { font-size: 27px; font-weight: 700; letter-spacing: 1.5px; }
.pdf .brand .trade { font-size: 14px; color: #f0b429; font-weight: 600; letter-spacing: 1px; margin-top: 4px; text-transform: uppercase; }
.pdf .brand .contact { font-size: 12.5px; color: #c9d5e3; margin-top: 6px; }
.pdf .brand .contact + .contact { margin-top: 2px; }
.pdf .doc { text-align: right; flex: none; }
.pdf .doc .t { font-size: 24px; font-weight: 300; letter-spacing: 5px; }
.pdf .doc .d { font-size: 12.5px; color: #c9d5e3; margin-top: 4px; }
.pdf .accent { height: 5px; background: #f0b429; }
.pdf .body { padding: 28px 60px 20px; }
.pdf .client { display: flex; gap: 38px; background: #f1f4f8; border-left: 5px solid #1f3a5f; padding: 11px 18px; margin-bottom: 24px; }
.pdf .client span { color: #6b7785; text-transform: uppercase; font-size: 11px; letter-spacing: .6px; display: block; }
.pdf .client b { font-size: 15px; }
.pdf h2 { font-size: 19px; color: #1f3a5f; margin: 0 0 15px; padding-bottom: 8px; border-bottom: 2px solid #e3e8ee; }
.pdf .item { border: 1px solid #dde3ea; border-radius: 7px; margin-bottom: 18px; overflow: hidden; page-break-inside: avoid; }
.pdf .item .ih { background: #f7f9fb; padding: 10px 18px; font-weight: 700; color: #1f3a5f; display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid #dde3ea; }
.pdf .item .ih small { font-weight: 600; color: #6b7785; font-size: 12.5px; white-space: nowrap; }
.pdf .item .ib { padding: 12px 18px 4px; line-height: 1.55; font-size: 14px; }
.pdf .item .ib ul { margin: 0 0 9px; padding-left: 20px; }
.pdf .item .ib li { margin-bottom: 4px; }
.pdf .item .price { display: flex; justify-content: space-between; padding: 11px 18px; background: #e6edf5; font-weight: 700; color: #1f3a5f; }
.pdf .item.opt { border: 1.5px dashed #b08a2e; }
.pdf .item.opt .ih { background: #fdf8ec; color: #7a5c12; }
.pdf .item.opt .price { background: #fbf0d4; color: #7a5c12; }
.pdf .warn { background: #fff4f2; border-left: 5px solid #c0392b; padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: #8e2a1f; margin: 6px 0 16px; page-break-inside: avoid; }
.pdf .totals { margin-top: 22px; width: 100%; border-collapse: collapse; page-break-inside: avoid; }
.pdf .totals td { padding: 10px 18px; border-bottom: 1px solid #e3e8ee; }
.pdf .totals td.p { text-align: right; white-space: nowrap; font-weight: 600; }
.pdf .totals tr.g td { background: #1f3a5f; color: #fff; font-size: 18px; font-weight: 700; border: 0; }
.pdf .totals tr.g2 td { background: #f0b429; color: #1d2733; font-weight: 700; border: 0; }
.pdf .cond { margin-top: 24px; display: flex; gap: 20px; page-break-inside: avoid; }
.pdf .cond div { flex: 1; background: #f7f9fb; border-radius: 7px; padding: 12px 18px; font-size: 13.5px; line-height: 1.5; }
.pdf .cond b { display: block; color: #1f3a5f; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; }
.pdf .sign { margin-top: 30px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; page-break-inside: avoid; }
.pdf .sign p { margin: 0; font-size: 14px; color: #4a5663; line-height: 1.5; }
.pdf .sign .s { text-align: center; width: 250px; flex: none; }
.pdf .sign .s .line { border-top: 1.5px solid #1d2733; padding-top: 6px; font-weight: 700; }
.pdf .sign .s small { color: #6b7785; font-size: 12px; }
.pdf .foot { margin: 26px 60px 0; border-top: 1px solid #e3e8ee; padding: 7px 0 18px; font-size: 11.5px; color: #8a96a3; display: flex; justify-content: space-between; }
