/* Gsystem Facturación — estilo minimalista, mobile-first */
:root {
  --bg: #f6f7f9; --surface: #fff; --surface-2: #f1f3f6; --ink: #101828; --ink-2: #475467; --ink-3: #8a94a6;
  --line: #e4e7ec; --accent: #1f4fd8; --accent-ink: #fff; --accent-soft: #e8eefc;
  --ok: #0a7f4f; --ok-soft: #e3f5ec; --warn: #a15c00; --warn-soft: #fdf1dc; --bad: #b42318; --bad-soft: #fde8e6; --info: #1f4fd8; --info-soft: #e8eefc;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --nav-w: 232px; --tab-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c111b; --surface: #131a27; --surface-2: #1a2333; --ink: #eef1f6; --ink-2: #aab3c3; --ink-3: #6f7a8f;
    --line: #243046; --accent: #6b8cff; --accent-ink: #0b1220; --accent-soft: #1b2748;
    --ok: #4cd698; --ok-soft: #12301f; --warn: #f2b45b; --warn-soft: #3a2a0f; --bad: #ff8a80; --bad-soft: #3b1714; --info: #8fa9ff; --info-soft: #1b2748; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; letter-spacing: -.02em; margin: 0; } h2 { font-size: 1.05rem; margin: 0 0 .75rem; letter-spacing: -.01em; } h3 { font-size: .95rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; } .muted { color: var(--ink-2); } .faint { color: var(--ink-3); } .small { font-size: .85rem; } .mono { font-family: var(--mono); font-size: .82rem; word-break: break-all; }
.right { text-align: right; } .nowrap { white-space: nowrap; } .grow { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); 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 { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: 8px; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.side { display: none; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.02em; color: var(--ink); } .brand:hover { text-decoration: none; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: .9rem; }
main { padding: 18px 16px calc(var(--tab-h) + 28px); max-width: 1120px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head .sub { color: var(--ink-2); font-size: .9rem; margin-top: 2px; }
.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: var(--tab-h); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); }
.tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; color: var(--ink-3); font: inherit; font-size: .68rem; font-weight: 550; cursor: pointer; min-height: 44px; }
.tabbar a:hover { text-decoration: none; } .tabbar [aria-current="page"] { color: var(--accent); }
.ico { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sheet { position: fixed; inset: 0; z-index: 40; display: none; } .sheet.open { display: block; }
.sheet .backdrop { position: absolute; inset: 0; background: rgba(8,12,20,.45); }
.sheet .panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 18px 18px 0 0; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet .panel a, .sheet .panel button.link { display: flex; gap: 12px; align-items: center; padding: 13px 4px; color: var(--ink); border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; font: inherit; text-align: left; cursor: pointer; }
.sheet .grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 10px; }
@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--nav-w); padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--line); }
  .shell { padding-left: var(--nav-w); } .topbar, .tabbar { display: none; }
  main { padding: 30px 32px 48px; } .side .brand { padding: 4px 10px 18px; font-size: 1.02rem; }
  .side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--ink-2); font-weight: 520; }
  .side nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); } .side nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .side .foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
}
.side .who { padding: 4px 10px 10px; font-size: .84rem; } .side .who b { display: block; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 16px; } .grid > * { margin-top: 0 !important; } .card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); } .card-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: 1fr; } .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 14px 16px; } .stat .k { color: var(--ink-2); font-size: .8rem; } .stat .v { font-size: 1.55rem; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; } .stat .n { color: var(--ink-3); font-size: .78rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 580; cursor: pointer; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); text-decoration: none; } .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } .btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn.danger { color: var(--bad); } .btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { min-height: 32px; padding: 0 11px; font-size: .86rem; border-radius: 8px; } .btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--surface-2); }
.btn.block { width: 100%; } .btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: inline; }
label { display: block; font-size: .84rem; font-weight: 580; color: var(--ink-2); margin-bottom: 5px; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 12px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
input[type=file] { padding: 8px; } textarea { min-height: 84px; }
.field { margin-bottom: 14px; } .field .hint { color: var(--ink-3); font-size: .78rem; margin-top: 4px; } .field .err, .err { color: var(--bad); font-size: .82rem; margin-top: 4px; }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: 1fr; } @media (min-width: 720px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 450; color: var(--ink); } .check input { margin-top: 2px; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: .76rem; font-weight: 620; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .92rem; background: var(--info-soft); color: var(--info); border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); } .alert.warn { background: var(--warn-soft); color: var(--warn); } .alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert a { color: inherit; text-decoration: underline; } .alert .ico { margin-top: 1px; }
.secret { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 12px; margin-top: 8px; display: flex; gap: 10px; align-items: center; justify-content: space-between; } .secret code { font-family: var(--mono); word-break: break-all; font-size: .86rem; color: var(--ink); }

/* tablas → tarjetas en móvil */
.tbl { width: 100%; border-collapse: collapse; } .tbl th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 620; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; } .tbl tr:last-child td { border-bottom: 0; } .tbl .num { text-align: right; font-variant-numeric: tabular-nums; } .tbl tr.click:hover td { background: var(--surface-2); }
@media (max-width: 719px) {
  .tbl thead { display: none; } .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: 12px 16px; border-bottom: 1px solid var(--line); } .tbl tr:last-child { border-bottom: 0; } .tbl td { padding: 2px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tbl td::before { content: attr(data-l); color: var(--ink-3); font-size: .78rem; text-align: left; flex: none; } .tbl td[data-l=""]::before, .tbl td:not([data-l])::before { content: none; } .tbl td.lead { font-weight: 620; justify-content: flex-start; text-align: left; font-size: 1rem; }
}
.kv { display: grid; grid-template-columns: 1fr; gap: 10px 20px; margin: 0; } @media (min-width: 560px) { .kv { grid-template-columns: repeat(2, 1fr); } }
.kv dt { color: var(--ink-3); font-size: .78rem; } .kv dd { margin: 1px 0 0; word-break: break-word; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); } @media (min-width: 900px) { .filters { grid-template-columns: repeat(6, 1fr) auto; align-items: end; } } .filters .field { margin: 0; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); font-size: .86rem; color: var(--ink-2); } .pager nav svg { width: 16px; } .pager a, .pager span[aria-current] { padding: 4px 8px; }
.empty { text-align: center; padding: 38px 16px; color: var(--ink-2); } .empty .ico { width: 34px; height: 34px; color: var(--ink-3); margin-bottom: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; } .timeline li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .88rem; } .timeline li:last-child { border: 0; }
.items-edit .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: var(--surface-2); } .items-edit .row .full { grid-column: 1 / -1; } .items-edit .row .field { margin: 0; }
@media (min-width: 720px) { .items-edit .row { grid-template-columns: 3fr 1fr 1fr 1fr auto; align-items: end; } .items-edit .row .full { grid-column: auto; } }
.totals { margin-left: auto; width: min(100%, 320px); } .totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; } .totals .grand { border-top: 1px solid var(--ink); margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 1.1rem; }
.toast { position: fixed; z-index: 60; left: 16px; right: 16px; bottom: calc(var(--tab-h) + 14px); max-width: 420px; margin: 0 auto; background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 12px; display: none; gap: 12px; align-items: center; justify-content: space-between; box-shadow: 0 8px 28px rgba(0,0,0,.28); } .toast.show { display: flex; } .toast button { background: none; border: 0; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }
@media (min-width: 900px) { .toast { bottom: 20px; left: auto; right: 20px; } }
.install { display: none; } .install.show { display: flex; }
.offline-bar { display: none; position: sticky; top: 0; z-index: 50; background: var(--warn-soft); color: var(--warn); padding: 8px 16px; text-align: center; font-size: .85rem; font-weight: 600; } body.is-offline .offline-bar { display: block; }
body.is-offline .needs-net { opacity: .5; pointer-events: none; }
.demo-ribbon { background: var(--warn-soft); color: var(--warn); font-size: .76rem; font-weight: 650; text-align: center; padding: 4px; letter-spacing: .03em; }

/* ---------- invitado ---------- */
.guest { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.guest .box { width: 100%; max-width: 420px; } .guest .box.wide { max-width: 520px; }
.guest .brand { justify-content: center; margin-bottom: 22px; font-size: 1.15rem; } .guest h1 { font-size: 1.3rem; margin-bottom: 4px; }
.guest .foot { text-align: center; margin-top: 16px; font-size: .86rem; color: var(--ink-2); }
.qr svg { width: 180px; height: 180px; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }
.prose h2 { margin-top: 1.4rem; } .prose { max-width: 720px; line-height: 1.65; }
