/* Fig Invoice. Mobile-first, sin recursos externos. Paleta: ciruela #4a2366 / #5b2a86, tinta #1c1f24, papel #faf8f5. */
:root {
  --ink: #1c1f24;
  --muted: #555b65;
  --line: #d6d1dc;
  --line-strong: #8f8799;
  --bg: #faf8f5;
  --paper: #fff;
  --plum: #4a2366;
  --plum-2: #5b2a86;
  --plum-soft: #f3ecf8;
  --green: #1f6f5c;
  --danger: #a4261d;
  --radius: 10px;
  --focus: #4a2366;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-bottom: 112px; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
img, svg { max-width: 100%; }
a { color: var(--plum-2); text-underline-offset: 2px; }
a:hover { color: var(--plum); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.75rem, 4.5vw, 2.6rem); letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
.muted { color: var(--muted); font-weight: normal; }
.sr, .sr-file {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 8px; top: -60px; background: var(--paper); padding: 10px 14px; z-index: 50; border: 2px solid var(--plum); border-radius: 8px; }
.skip:focus { top: 8px; }

/* ---------- cabecera y pie ---------- */
.site-head { background: var(--paper); border-bottom: 1px solid var(--line); }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; padding-top: 8px; padding-bottom: 4px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.2rem; color: var(--ink); text-decoration: none; min-height: 44px; }
.brand .mark { width: 30px; height: 30px; }
.brand.small { font-size: 1.05rem; margin-bottom: .5em; min-height: 0; }
.site-head nav { width: 100%; overflow-x: auto; }
.site-head ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.site-head nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--ink); text-decoration: none; white-space: nowrap; font-weight: 500; }
.site-head nav a:hover { background: var(--plum-soft); }
.site-head nav a[aria-current="page"] { color: var(--plum); box-shadow: inset 0 -3px 0 var(--plum); border-radius: 0; }
@media (max-width: 479px) {
  /* en el celular el logo ya lleva al generador de facturas: así entran las otras cuatro sin barra de scroll */
  .site-head nav li:first-child { display: none; }
  .site-head ul { justify-content: space-between; }
  .site-head nav a { padding: 0 10px; }
}
@media (min-width: 760px) {
  .head-row { flex-wrap: nowrap; padding-top: 6px; padding-bottom: 6px; }
  .site-head nav { width: auto; }
}
.site-foot { margin-top: 48px; background: #241631; color: #ece6f2; padding: 32px 0 24px; }
.site-foot a { color: #ece6f2; }
.site-foot a:hover { color: #fff; }
.site-foot h2 { font-size: 1rem; color: #fff; }
.site-foot .brand { color: #fff; }
.site-foot ul { list-style: none; margin: 0; padding: 0; }
.site-foot li a { display: inline-block; padding: 6px 0; }
.foot-grid { display: grid; gap: 24px; }
@media (min-width: 760px) { .foot-grid { grid-template-columns: 2fr 1fr 1fr; } }
.fine { font-size: .875rem; color: #cfc6d9; margin-top: 16px; }

/* ---------- textos ---------- */
.hero { padding-top: 24px; padding-bottom: 8px; }
.lead { font-size: 1.1rem; max-width: 760px; }
.prose { padding-top: 16px; }
.prose section, .prose > h2 { margin-top: 36px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .35em 0; }
.ticks { list-style: none; padding-left: 0 !important; }
.ticks li { position: relative; padding-left: 1.6em; }
.ticks li::before { content: ""; position: absolute; left: 2px; top: .45em; width: .55em; height: .9em; border: solid var(--green); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.steps ol li { margin: .6em 0; }
.chips { list-style: none; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { margin: 0 !important; }
.chips a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); text-decoration: none; }
.chips a:hover { border-color: var(--plum-2); }
.cards { list-style: none; padding: 0 !important; display: grid; gap: 12px; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .cards { grid-template-columns: 1fr 1fr 1fr; } }
.cards li { margin: 0 !important; }
.cards a { display: block; height: 100%; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.cards a:hover { border-color: var(--plum-2); }
.cards strong { display: block; color: var(--plum-2); margin-bottom: 4px; }
.cards span { color: var(--muted); font-size: .95rem; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; min-height: 44px; }
.faq details p { margin: 0 0 14px; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 0 0 8px; font-size: .9rem; }
.crumbs li + li::before { content: "/"; margin: 0 6px 0 2px; color: var(--muted); }
.crumbs a { display: inline-block; padding: 4px 0; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--paper); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th.n, td.n { text-align: right; white-space: nowrap; }
.pro-teaser, .join { margin-top: 36px; padding: 20px; background: var(--plum-soft); border-radius: var(--radius); }
.note { padding: 12px; background: #fff4d6; border-radius: 8px; }

/* ---------- botones ---------- */
.btn, .doc-tools button, .doc-tools select {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--paper); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover, .doc-tools button:hover { border-color: var(--plum); color: var(--plum); }
.btn.primary { background: var(--plum); border-color: var(--plum); color: #fff; }
.btn.primary:hover { background: #3a1a52; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--plum-2); }
.btn.ghost:hover { background: var(--plum-soft); }
.btn.small { padding: 6px 10px; font-size: .95rem; }
.btn.danger, .doc-tools .danger { color: var(--danger); border-color: #d9a39e; }
.btn:disabled { opacity: .55; cursor: default; }
label.btn { user-select: none; }
.logo-row:has(.sr-file:focus-visible) label.btn,
.row-btns:has(.sr-file:focus-visible) label.btn { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- formularios ---------- */
.f { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.f > label, .f > legend, fieldset.f > legend { font-weight: 600; font-size: .92rem; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 11px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 8px;
}
textarea { resize: vertical; min-height: 44px; field-sizing: content; max-height: 14em; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--plum); }
input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
input::placeholder, textarea::placeholder { color: #707680; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--plum); margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.box { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 14px; background: var(--paper); }
.box > legend { font-weight: 700; font-size: 1.05rem; padding: 0 6px; margin-left: -6px; }
.hint { margin: 2px 0 0; font-size: .88rem; color: #8a4b00; min-height: 0; }
.hint:empty { display: none; }
.radio { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.status { margin: 8px 0 0; font-weight: 600; color: var(--green); min-height: 1.5em; }
.status.error { color: var(--danger); }

/* ---------- la app ---------- */
.app { margin-top: 8px; }
.app-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; padding: 3px; background: var(--paper); }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg-opt span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 7px; font-weight: 600; color: var(--ink); }
.seg-opt input:checked + span { background: var(--plum); color: #fff; }
.seg-opt:has(input:focus-visible) span { outline: 3px solid var(--focus); outline-offset: 2px; }
.bar-tools { display: flex; flex-wrap: wrap; gap: 2px; margin-left: -10px; }
@media (min-width: 640px) { .bar-tools { margin-left: 0; } }
.paper { background: transparent; }
.grid2, .grid3 { display: grid; gap: 0 14px; }
@media (min-width: 760px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid2.bottom { grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (min-width: 480px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .grid3 { grid-template-columns: repeat(4, 1fr); } }
.grid2.tight { grid-template-columns: 1fr 1fr; gap: 0 10px; }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
#logo-img { max-height: 64px; max-width: 180px; object-fit: contain; border: 1px dashed var(--line); border-radius: 6px; padding: 4px; background: #fff; }

/* ítems: tarjetas en el celular, filas en escritorio */
.items { list-style: none; margin: 0; padding: 0; }
.items-head { display: none; }
.item {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; align-items: end;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.item:first-child { padding-top: 0; }
.item .f { margin-bottom: 6px; }
.item .desc { grid-column: 1 / -1; }
.item .f > label { font-size: .85rem; }
.item .amt { align-self: end; }
.item .amt .lbl { font-weight: 600; font-size: .85rem; }
.item output { display: flex; align-items: center; justify-content: flex-end; min-height: 44px; font-variant-numeric: tabular-nums; font-weight: 600; }
.item .num { text-align: right; font-variant-numeric: tabular-nums; }
.item .tx { grid-column: 1 / 2; flex-direction: row; align-items: center; gap: 8px; min-height: 44px; margin: 0; }
.item .tx label { font-weight: 500; font-size: .92rem; }
.item .row-tools { grid-column: 2 / -1; display: flex; justify-content: flex-end; gap: 4px; }
.items.no-tax .tx { visibility: hidden; }
.icon { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font-size: 1.15rem; line-height: 1; cursor: pointer; color: var(--ink); }
.icon:hover:not(:disabled) { border-color: var(--plum); color: var(--plum); }
.icon:disabled { opacity: .35; cursor: default; }
.icon.del { color: var(--danger); }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
@media (min-width: 860px) {
  .items-head, .item { grid-template-columns: minmax(0, 1fr) 5.5rem 7.5rem 7.5rem 6.5rem 9.5rem; gap: 0 8px; }
  .items-head { display: grid; font-weight: 600; font-size: .85rem; color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
  .items-head span:nth-child(n+2):nth-child(-n+4) { text-align: right; }
  .items-head span:last-child { grid-column: 5 / -1; }
  .item { align-items: start; padding: 6px 0; }
  .item:first-child { padding-top: 0; }
  .item .desc { grid-column: auto; }
  .item .f > label, .item .amt .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .item .tx { grid-column: auto; }
  .item .tx label { position: static; width: auto; height: auto; clip: auto; overflow: visible; }
  .item .row-tools { grid-column: auto; gap: 2px; }
  .item .f { margin-bottom: 0; }
}

/* totales */
.sums { margin: 6px 0 0; border-top: 1px solid var(--line); padding-top: 8px; }
.sums > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.sums dt { color: var(--muted); }
.sums dd { margin: 0; font-variant-numeric: tabular-nums; }
.sums .grand { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; font-weight: 700; font-size: 1.15rem; }
.sums .grand dt { color: var(--ink); }

/* diseño del PDF */
.design-row { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: flex-start; }
.designs { display: flex; gap: 10px; }
.design { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font-weight: 600; font-size: .92rem; }
.design input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.design .thumb { width: 72px; height: 94px; border: 2px solid var(--line); border-radius: 6px; background: #fff; }
.design input:checked ~ .thumb { border-color: var(--plum); box-shadow: 0 0 0 2px var(--plum); }
.design:has(input:focus-visible) .thumb { outline: 3px solid var(--focus); outline-offset: 3px; }
.thumb .acc { fill: #1f6f5c; }
#doc-form:has(input[name=accent][value="#2457a6"]:checked) .thumb .acc { fill: #2457a6; }
#doc-form:has(input[name=accent][value="#6b3fa0"]:checked) .thumb .acc { fill: #6b3fa0; }
#doc-form:has(input[name=accent][value="#b3361b"]:checked) .thumb .acc { fill: #b3361b; }
#doc-form:has(input[name=accent][value="#a15c00"]:checked) .thumb .acc { fill: #a15c00; }
#doc-form:has(input[name=accent][value="#2b2b2b"]:checked) .thumb .acc { fill: #2b2b2b; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatches > legend { font-weight: 600; font-size: .92rem; margin-bottom: 4px; padding: 0; float: left; width: 100%; }
.swatch { position: relative; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line-strong); }
.swatch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.swatch:has(input:checked) { box-shadow: 0 0 0 3px var(--ink); }
.swatch:has(input:checked)::after { content: ""; position: absolute; left: 13px; top: 7px; width: 9px; height: 17px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); pointer-events: none; }
.swatch:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.sw-1f6f5c { background: #1f6f5c; }
.sw-2457a6 { background: #2457a6; }
.sw-6b3fa0 { background: #6b3fa0; }
.sw-b3361b { background: #b3361b; }
.sw-a15c00 { background: #a15c00; }
.sw-2b2b2b { background: #2b2b2b; }
.design-row > .f { min-width: 10rem; }

/* barra de acciones fija abajo */
.actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(28, 31, 36, .08);
}
@media (min-width: 760px) { .actions { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); } }
.actions .sum { margin: 0; font-size: 1.05rem; }
.actions .sum strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; margin-left: 4px; }
.action-btns { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; justify-content: flex-end; }
.action-btns .btn { padding: 8px 14px; }
.actions .conv { padding: 8px 14px; }
@media (max-width: 479px) {
  /* dos filas: total y convertir arriba, los tres botones abajo */
  .actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
  .actions .sum { grid-column: 1; grid-row: 1; align-self: center; }
  .actions .conv { grid-column: 2; grid-row: 1; padding: 6px 12px; font-size: .95rem; }
  .action-btns { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: 2fr 1fr 1fr; width: 100%; }
  .action-btns .btn { padding: 8px 6px; }
}
.privacy-note { font-size: .9rem; color: var(--muted); margin-top: 10px; }

/* diálogos */
dialog { width: min(680px, calc(100% - 24px)); max-height: calc(100% - 24px); border: 0; border-radius: 14px; padding: 18px; color: var(--ink); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(28, 20, 36, .55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.dlg-head h2 { margin: 0; }
dialog hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-row { display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.doc-main { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; min-width: 0; }
.doc-main .amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.doc-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-tools button, .doc-tools select { padding: 6px 12px; font-size: .95rem; width: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: #e8f1ee; color: #155343; }
.badge.estimate { background: #e7eef9; color: #1d4785; }
.badge.receipt { background: #f6ede0; color: #7a4600; }

/* precios Pro */
.plans { list-style: none; padding: 0 !important; display: grid; gap: 16px; }
@media (min-width: 720px) { .plans { grid-template-columns: 1fr 1fr; } }
.plan { margin: 0 !important; padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.plan.featured { border: 2px solid var(--plum); }
.price { font-size: 2.2rem; font-weight: 800; margin: 0; }
.price span { font-size: 1rem; font-weight: 600; color: var(--muted); }
.alt { color: var(--muted); }
.join form { max-width: 480px; }

/* anuncios (solo con AdSense configurado) */
.ad-slot { max-width: 1120px; margin: 24px auto; padding: 0 16px; min-height: 120px; }
.ad-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 4px; }
.ad-slot ins { display: block; min-height: 100px; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
