:root { --bg:#f6f7fb; --fg:#171923; --muted:#5b6070; --accent:#4f46e5; --accent2:#4338ca; --card:#ffffff; --line:#e3e5ee; --ok:#16a34a; }
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f1117; --fg:#eceef6; --muted:#9aa0b4; --accent:#818cf8; --accent2:#a5b4fc; --card:#181b25; --line:#272b3a; }
}
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html { scroll-behavior:smooth; }
body { margin:0; background:var(--bg); color:var(--fg); font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; line-height:1.6; }
a { color:var(--accent); }
header.top { background:var(--card); border-bottom:1px solid var(--line); }
header.top .in { max-width:960px; margin:0 auto; padding:14px 20px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
header.top .brand { font-weight:800; font-size:1.15rem; color:var(--fg); text-decoration:none; }
header.top nav a { margin-left:16px; font-size:.92rem; color:var(--muted); text-decoration:none; }
header.top nav a:hover { color:var(--accent); }
main { max-width:960px; margin:0 auto; padding:28px 20px 40px; }
h1 { font-size:clamp(1.6rem,4vw,2.3rem); line-height:1.2; margin:0 0 8px; }
.lead { color:var(--muted); margin:0 0 24px; font-size:1.05rem; }
h2 { font-size:1.35rem; margin:36px 0 10px; }
h3 { font-size:1.05rem; margin:20px 0 4px; }
.tool { background:var(--card); border:1px solid var(--line); border-radius:18px; padding:22px; box-shadow:0 2px 14px rgba(20,20,40,.05); }
.drop { border:2px dashed var(--line); border-radius:14px; padding:34px 16px; text-align:center; color:var(--muted); cursor:pointer; transition:.15s; }
.drop:hover, .drop.over { border-color:var(--accent); color:var(--accent); background:rgba(99,102,241,.06); }
.drop strong { display:block; font-size:1.1rem; color:var(--fg); margin-bottom:4px; }
.row { display:flex; flex-wrap:wrap; gap:14px; align-items:center; margin:16px 0; }
.row label { font-size:.92rem; color:var(--muted); display:flex; flex-direction:column; gap:4px; }
input[type=text], input[type=number], input[type=url], select, textarea {
  font:inherit; color:var(--fg); background:var(--bg); border:1px solid var(--line); border-radius:10px; padding:10px 12px; min-width:0; }
textarea { width:100%; min-height:160px; resize:vertical; }
input[type=range] { accent-color:var(--accent); }
input[type=color] { width:56px; height:42px; border:1px solid var(--line); border-radius:10px; background:var(--bg); padding:2px; }
.btn { display:inline-block; border:0; border-radius:12px; padding:12px 22px; font:inherit; font-weight:700; background:var(--accent); color:#fff; cursor:pointer; text-decoration:none; }
.btn:hover { background:var(--accent2); }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.btn.sec { background:transparent; color:var(--fg); border:1px solid var(--line); }
.btn.sec:hover { border-color:var(--accent); color:var(--accent); background:transparent; }
.list { list-style:none; margin:16px 0 0; padding:0; display:grid; gap:10px; }
.list li { display:flex; align-items:center; gap:12px; background:var(--bg); border:1px solid var(--line); border-radius:12px; padding:10px 12px; }
.list .name { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.list .meta { color:var(--muted); font-size:.85rem; white-space:nowrap; }
.list img { width:48px; height:48px; object-fit:cover; border-radius:8px; }
.list button { background:none; border:0; color:var(--muted); cursor:pointer; font-size:1.1rem; padding:4px 8px; }
.list button:hover { color:var(--accent); }
.good { color:var(--ok); font-weight:700; }
.out { text-align:center; margin-top:16px; }
.out canvas, .out img { max-width:100%; height:auto; border-radius:10px; }
.grid2 { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:14px; }
.stat { background:var(--bg); border:1px solid var(--line); border-radius:12px; padding:14px; }
.stat b { display:block; font-size:1.5rem; }
.stat span { color:var(--muted); font-size:.88rem; }
.ad { margin:22px auto; text-align:center; min-height:0; overflow:hidden; }
.ad:empty { display:none; }
.seo p, .seo li { color:var(--muted); }
.seo ol, .seo ul { padding-left:20px; }
details { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:12px 16px; margin:8px 0; }
summary { cursor:pointer; font-weight:600; }
.tools { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
.tools a { background:var(--card); border:1px solid var(--line); border-radius:999px; padding:6px 14px; font-size:.9rem; text-decoration:none; }
footer.foot { border-top:1px solid var(--line); text-align:center; padding:22px 20px; color:var(--muted); font-size:.88rem; }
footer.foot a { color:var(--muted); margin:0 8px; }
.note { font-size:.85rem; color:var(--muted); }
.hide { display:none !important; }

/* ===== Generador de facturas ===== */
.inv-ed h2 { margin:26px 0 6px; font-size:1.1rem; }
.inv-ed h2:first-child { margin-top:0; }
.inv-ed .row { margin:10px 0; align-items:flex-start; }
.inv-ed .row label.grow { flex:1 1 220px; }
.inv-ed .row label.sm { flex:0 0 150px; }
.inv-ed input[type=text], .inv-ed input[type=number], .inv-ed input[type=date], .inv-ed select, .inv-ed textarea { width:100%; }
.inv-ed input[type=date] { font:inherit; color:var(--fg); background:var(--bg); border:1px solid var(--line); border-radius:10px; padding:10px 12px; }
.inv-ed textarea { min-height:70px; }
.chk { flex-direction:row !important; align-items:center; gap:8px !important; color:var(--fg) !important; }
.warn { background:rgba(234,179,8,.12); border:1px solid rgba(234,179,8,.45); border-radius:10px; padding:8px 12px; font-size:.88rem; margin:6px 0; }
.okmsg { color:var(--ok); font-size:.85rem; }
.err { color:#dc2626; font-size:.85rem; }
.items { display:grid; gap:10px; margin:10px 0; }
.item { display:grid; grid-template-columns:2.2fr .7fr 1fr .7fr 1.1fr auto; gap:8px; align-items:end; background:var(--bg); border:1px solid var(--line); border-radius:12px; padding:10px; }
.item label { font-size:.78rem; color:var(--muted); display:flex; flex-direction:column; gap:3px; }
.item .rm { background:none; border:0; color:var(--muted); cursor:pointer; font-size:1.2rem; padding:8px; }
.item .rm:hover { color:#dc2626; }
.item .more { grid-column:1 / -1; justify-self:start; background:none; border:0; color:var(--accent); cursor:pointer; font:inherit; font-size:.85rem; padding:2px 0; }
.item .more:hover { text-decoration:underline; }
.item-ext { grid-column:1 / -1; display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end; border-top:1px dashed var(--line); padding-top:10px; }
.item-ext label { flex:1 1 150px; }
.item-ext label.isc { flex:1 1 100%; }
.item-ext .chk { flex:0 0 auto; padding-bottom:8px; }
@media (max-width:720px) { .item { grid-template-columns:1fr 1fr; } .item label.d { grid-column:1 / -1; } }
.actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:18px; }
.paper-wrap { overflow-x:auto; margin-top:22px; }
#invoice { background:#fff; color:#111; border:1px solid #d6d9e4; border-radius:6px; padding:28px 30px; max-width:820px; margin:0 auto; font-size:.92rem; line-height:1.45; box-shadow:0 2px 14px rgba(20,20,40,.08); }
#invoice .inv-head { display:flex; justify-content:space-between; gap:20px; flex-wrap:wrap; border-bottom:2px solid #0f766e; padding-bottom:14px; margin-bottom:14px; }
#invoice .inv-title { font-size:1.35rem; font-weight:800; color:#0f766e; margin:0; }
#invoice .inv-ncf { font-weight:700; font-size:1.05rem; }
#invoice .muted { color:#555; }
#invoice .cols { display:grid; grid-template-columns:1fr 1fr; gap:18px; margin-bottom:16px; }
#invoice .cols h4 { margin:0 0 3px; font-size:.78rem; text-transform:uppercase; letter-spacing:.04em; color:#0f766e; }
#invoice table { width:100%; border-collapse:collapse; margin:6px 0 10px; }
#invoice th { background:#ecfdf5; color:#065f46; font-size:.78rem; text-transform:uppercase; letter-spacing:.03em; text-align:right; padding:7px 8px; border-bottom:1px solid #a7f3d0; }
#invoice th:first-child, #invoice td:first-child { text-align:left; }
#invoice td { padding:7px 8px; border-bottom:1px solid #eceef4; text-align:right; vertical-align:top; }
#invoice td.desc { white-space:pre-wrap; word-break:break-word; }
#invoice .tot { margin-left:auto; width:min(100%,340px); }
#invoice .tot div { display:flex; justify-content:space-between; gap:16px; padding:3px 0; }
#invoice .tot .grand { border-top:2px solid #0f766e; margin-top:6px; padding-top:8px; font-size:1.15rem; font-weight:800; }
#invoice .notes { margin-top:16px; padding-top:10px; border-top:1px dashed #cfd3df; white-space:pre-wrap; }
#invoice .foot { margin-top:14px; font-size:.8rem; color:#555; }
@media (max-width:640px) { #invoice { padding:16px; } #invoice .cols { grid-template-columns:1fr; } }
@media print {
  @page { size:A4; margin:12mm; }
  html, body { background:#fff !important; color:#000 !important; }
  body > :not(main), main > :not(#facturador) { display:none !important; }
  main { max-width:none !important; padding:0 !important; margin:0 !important; }
  #facturador { border:0 !important; box-shadow:none !important; padding:0 !important; background:none !important; }
  #facturador > :not(.paper-wrap) { display:none !important; }
  .paper-wrap { margin:0 !important; overflow:visible !important; }
  #invoice { border:0 !important; box-shadow:none !important; max-width:none !important; padding:0 !important; border-radius:0 !important; }
  #invoice tr, #invoice .tot { break-inside:avoid; }
}
