:root {
  color-scheme: light;
  --bg: #f2f6f9;
  --surface: #ffffff;
  --surface-2: #edf2f6;
  --ink: #0e1621;
  --ink-2: #4a5663;
  --ink-3: #84909c;
  --line: #e1e8ee;
  --brand: #0e7490;
  --brand-2: #06b6d4;
  --brand-ink: #ffffff;
  --brand-soft: #e0f4fa;
  --ok: #0a7d32;
  --ok-soft: #e4f5ea;
  --warn: #9a6400;
  --warn-soft: #fff4dc;
  --bad: #c0302f;
  --bad-soft: #fde8e8;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --shadow: 0 1px 2px rgba(15, 23, 22, .06), 0 6px 24px rgba(15, 23, 22, .06);
  --radius: 18px;
  --tab-h: 68px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1118;
    --surface: #131c25;
    --surface-2: #1a2530;
    --ink: #eef3f7;
    --ink-2: #b4c0cb;
    --ink-3: #7c8996;
    --line: #24313d;
    --brand: #22d3ee;
    --brand-2: #0e7490;
    --brand-ink: #062a35;
    --brand-soft: #0f3240;
    --ok: #4ade80;
    --ok-soft: #12301d;
    --warn: #fbbf24;
    --warn-soft: #33270b;
    --bad: #f87171;
    --bad-soft: #3a1515;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c2c2a;
    --axis: #383835;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1118; --surface: #131c25; --surface-2: #1a2530; --ink: #eef3f7; --ink-2: #b4c0cb; --ink-3: #7c8996;
  --line: #24313d; --brand: #22d3ee; --brand-2: #0e7490; --brand-ink: #062a35; --brand-soft: #0f3240;
  --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #33270b; --bad: #f87171; --bad-soft: #3a1515;
  --series-1: #3987e5; --series-2: #d95926; --grid: #2c2c2a; --axis: #383835; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(120% 50% at 50% -10%, color-mix(in srgb, var(--brand-2) 16%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.45 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button, input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { max-width: 720px; margin: 0 auto; min-height: 100%; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { width: 42px; height: 42px; border-radius: 12px; flex: none; box-shadow: 0 4px 14px rgba(14, 116, 144, .3); }
.brand h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.sub { margin: 0; color: var(--ink-3); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.chip.ok .dot { background: var(--ok); }
.chip.pend .dot { background: var(--warn); }
.chip.err .dot { background: var(--bad); }

main { padding: 4px 16px 16px; }
.vista { display: none; animation: aparecer .25s ease; }
.vista.activa { display: block; }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Hero */
.hero-card {
  position: relative; overflow: hidden;
  border-radius: 26px; padding: 20px; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #06b6d4 0%, #0e7490 50%, #0c3a5e 100%);
  box-shadow: 0 14px 34px rgba(14, 116, 144, .32);
}
.hero-card::after { /* brillo decorativo */
  content: ""; position: absolute; width: 220px; height: 220px; right: -70px; top: -90px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 70%); pointer-events: none;
}
.hero-pie { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; font-weight: 600; }
.hero-pie span:first-child { background: rgba(255, 255, 255, .16); padding: 5px 12px; border-radius: 99px; }
.hero-pie span:last-child { opacity: .85; align-self: center; }
.hero-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.hero-label { font-weight: 600; text-transform: capitalize; }
.hero-count { font-size: 13px; opacity: .85; }
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hero-grid > div { background: rgba(255, 255, 255, .12); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; min-width: 0; }
.hero-grid .k { font-size: 12px; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.hero-grid strong { font-size: 22px; letter-spacing: -.02em; margin: 2px 0; overflow-wrap: anywhere; }
.hero-grid .kk { font-size: 12px; opacity: .85; }

/* Acciones */
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 8px; }
.btn-accion {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.btn-accion:active { transform: scale(.98); }
.btn-accion svg { grid-row: span 2; width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.btn-accion span { font-weight: 600; }
.btn-accion small { color: var(--ink-3); font-size: 12px; }
.btn-accion.primario { grid-column: 1 / -1; background: var(--brand); color: var(--brand-ink); border-color: transparent; padding: 18px; }
.btn-accion.primario svg { background: rgba(255, 255, 255, .18); color: inherit; }
.btn-accion.primario small { color: inherit; opacity: .8; }

.seccion-titulo { display: flex; justify-content: space-between; align-items: center; margin: 20px 2px 8px; }
.seccion-titulo h2, .card h2 { font-size: 16px; margin: 0; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; padding: 6px; }

/* Lista */
.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 50px 1fr auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 11px 14px 11px 16px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .12s ease;
}
.item::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--series-1); }
.item:has(.ico.venta)::before { background: var(--series-2); }
.item:active { background: var(--surface-2); transform: scale(.99); }
.item .ico { width: 50px; height: 50px; border-radius: 12px; display: grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: .02em; overflow: hidden; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.item .ico img { width: 100%; height: 100%; object-fit: cover; }
.item .ico.compra { background: color-mix(in srgb, var(--series-1) 14%, var(--surface)); color: var(--series-1); }
.item .ico.venta { background: color-mix(in srgb, var(--series-2) 14%, var(--surface)); color: var(--series-2); }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.item .monto { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.item .monto small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-3); }
.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.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); }
.grupo-mes { margin: 18px 2px 8px; display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--ink-2); }
.grupo-mes strong { color: var(--ink); text-transform: capitalize; font-size: 15px; }
.vacio { text-align: center; color: var(--ink-3); padding: 32px 16px; border: 1.5px dashed var(--line); border-radius: var(--radius); }
.vacio svg { width: 40px; height: 40px; margin-bottom: 8px; color: var(--ink-3); }

/* Filtros */
.filtros { display: grid; gap: 8px; position: sticky; top: calc(env(safe-area-inset-top) + 64px); z-index: 4; background: var(--bg); padding: 4px 0 8px; }
.buscar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; }
.buscar svg { color: var(--ink-3); width: 18px; height: 18px; }
.buscar input { border: 0; outline: 0; background: transparent; padding: 12px 0; width: 100%; min-width: 0; }
.fila-filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.fila-filtros select { flex: 1; min-width: 0; }
.form textarea { font: inherit; color: inherit; resize: vertical; min-height: 46px; line-height: 1.4; }
.campo-auto textarea { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); background: color-mix(in srgb, var(--brand) 5%, var(--surface)); }
.item .d { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
select, .form input, .form textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; width: 100%; outline: none; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.form input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }

/* Cards / botones */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 12px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; background: var(--brand); color: var(--brand-ink); cursor: pointer; text-decoration: none; }
.btn svg { width: 18px; height: 18px; }
.btn.sec { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .55; cursor: default; }
.resumen-top { align-items: center; }
.resumen-top .btn { flex: none; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.tile strong { display: block; font-size: 19px; letter-spacing: -.02em; margin-top: 2px; overflow-wrap: anywhere; }
.tile small { color: var(--ink-2); font-size: 12px; }

/* Gráfico */
.leyenda { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.s1 { background: var(--series-1); }
.sw.s2 { background: var(--series-2); }
.grafico { width: 100%; }
.grafico svg { width: 100%; height: auto; display: block; stroke: none; }
.grafico .gl { stroke: var(--grid); stroke-width: 1; }
.grafico .base { stroke: var(--axis); stroke-width: 1; }
.grafico text { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.grafico .b1 { fill: var(--series-1); }
.grafico .b2 { fill: var(--series-2); }
.grafico .hit { fill: transparent; cursor: pointer; }
.grafico .hit:hover, .grafico .hit.on { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow); min-width: 150px; }
.tooltip b { display: block; margin-bottom: 4px; text-transform: capitalize; }
.tooltip div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.tooltip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

/* Tabla */
.tabla-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 520px; }
.tabla th, .tabla td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabla th:first-child, .tabla td:first-child { text-align: left; text-transform: capitalize; }
.tabla thead th { color: var(--ink-3); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.tabla thead tr:first-child th { border-bottom: 0; padding-bottom: 0; }
.tabla .grp-c, .tabla .grp-v { color: var(--ink-2); }
.tabla tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--line); }
.tabla td.cero { color: var(--ink-3); }
.nota { color: var(--ink-3); font-size: 12px; margin: 10px 0 0; }

/* Formularios */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.form small { color: var(--ink-3); font-weight: 400; }
.form h2 { margin: 6px 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.fila-botones { display: flex; gap: 8px; flex-wrap: wrap; }
.switch { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px !important; cursor: pointer; color: var(--ink) !important; }
.switch input { display: none; }
.switch span { width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.estado-conexion { margin: 0; font-size: 13px; }
.estado-conexion.ok { color: var(--ok); }
.estado-conexion.err { color: var(--bad); }
.version { text-align: center; color: var(--ink-3); font-size: 12px; margin-top: 20px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { display: block; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 9px 6px; border-radius: 9px; font-weight: 600; color: var(--ink-2); cursor: pointer; font-size: 13.5px; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-3); cursor: pointer; padding: 6px 0; }
.tab svg { padding: 3px 14px; width: 50px; height: 28px; border-radius: 99px; transition: background .2s; }
.tab.activa { color: var(--brand); }
.tab.activa svg { stroke-width: 2.2; background: var(--brand-soft); }
.tab.fab { justify-self: center; width: 60px; height: 60px; border-radius: 20px; background: linear-gradient(135deg, #06b6d4, #0e7490); color: #fff; justify-content: center; margin-top: -26px; box-shadow: 0 10px 24px rgba(14, 116, 144, .45); border: 4px solid var(--bg); }
.tab.fab svg { width: 28px; height: 28px; padding: 0; stroke-width: 2.4; background: none !important; }

/* Sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(5, 10, 9, .45); display: flex; align-items: flex-end; justify-content: center; animation: fondo .2s ease; }
@keyframes fondo { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 720px; max-height: 96dvh; background: var(--bg); border-radius: 24px 24px 0 0; display: flex; flex-direction: column;
  animation: subir .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes subir { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 17px; text-align: center; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface-2); display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.icon-btn.peligro { color: var(--bad); }
.sheet-body { overflow-y: auto; padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0; }
.sheet-body > * { flex-shrink: 0; }
.sheet-foot { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.preview { border-radius: 16px; overflow: hidden; background: var(--surface-2); display: block; max-height: 260px; flex: none; }
.preview:empty { display: none; }
.preview { position: relative; }
.preview img { width: 100%; max-height: 260px; object-fit: contain; display: block; }
.preview-links { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.preview-links a { text-decoration: none; }
.fila-archivo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preview .pdf { padding: 24px; display: flex; gap: 10px; align-items: center; color: var(--ink-2); font-weight: 600; }
.preview .pdf svg { width: 36px; height: 36px; color: var(--bad); }
.preview a { color: var(--brand); }
.progreso { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.progreso > div:last-child { flex: 1; }
.barra { height: 6px; border-radius: 99px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.barra i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .3s; }
.spinner { width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: girar .8s linear infinite; flex: none; }
@keyframes girar { to { transform: rotate(360deg); } }
.fuente, .sunat { border-radius: 14px; padding: 10px 14px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; }
.fuente { background: var(--brand-soft); color: var(--ink); }
.fuente svg, .sunat svg { width: 20px; height: 20px; margin-top: 1px; }
.sunat.ok { background: var(--ok-soft); }
.sunat.ok svg { color: var(--ok); }
.sunat.warn { background: var(--warn-soft); }
.sunat.warn svg { color: var(--warn); }
.sunat.bad { background: var(--bad-soft); }
.sunat.bad svg { color: var(--bad); }
.sunat small { display: block; color: var(--ink-2); }
.campo-falta { color: var(--bad) !important; font-weight: 700 !important; }
.campo-falta input, .campo-falta select { border: 2px solid var(--bad) !important; background: var(--bad-soft) !important; animation: sacudir .4s; }
@keyframes sacudir { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.campo-auto input, .campo-auto select { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); background: color-mix(in srgb, var(--brand) 5%, var(--surface)); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; width: max-content; max-width: calc(100% - 32px); text-align: center; }
.toast.ver { opacity: 1; transform: translate(-50%, 0); }
.toast.con-accion.ver { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; }
.toast button { border: 0; border-radius: 9px; padding: 9px 12px; font-weight: 700; background: #06b6d4; color: #062a35; cursor: pointer; white-space: nowrap; }

/* Bienvenida (nombre) */
.bienvenida { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(120% 70% at 50% 0%, #0e7490 0%, #0c4a6e 45%, #0a1f3d 100%); }
.bv-caja { width: min(420px, 100%); background: var(--surface); border-radius: 26px; padding: 28px 22px; display: grid; gap: 12px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .4); }
.bv-caja img { justify-self: center; border-radius: 22px; box-shadow: 0 8px 22px rgba(12, 74, 110, .35); }
.bv-caja h1 { margin: 4px 0 0; font-size: 24px; font-weight: 800; }
.bv-caja p { margin: 0 0 6px; color: var(--ink-2); }
.bv-caja label { text-align: left; font-weight: 700; font-size: 14px; }
.bv-caja input { font: inherit; font-size: 17px; padding: 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); outline: none; }
.bv-caja input:focus { border-color: var(--brand); }
.bv-caja .btn { padding: 15px; font-size: 17px; }
.bv-caja small { color: var(--ink-3); }
.bv-error { margin: 0; color: var(--bad); font-weight: 700; font-size: 14px; }
.bv-campo { display: grid; gap: 10px; }
.bv-rapido { padding: 20px !important; font-size: 20px !important; font-weight: 800; margin-top: 4px; box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 40%, transparent); }
.bv-link { justify-self: center; font-size: 14px; }
.contactos-info { font-weight: 700; color: var(--brand); margin: 0; }
.pasos-contactos { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 13.5px; display: grid; gap: 4px; }
label.btn { text-align: center; }

.sheet-foot:has(#btnValidar[hidden]) { grid-template-columns: 1fr; }
.btn-google { min-height: 44px; display: flex; justify-content: center; }
.tab .punto-rojo { position: absolute; top: 4px; right: calc(50% - 22px); width: 10px; height: 10px; border-radius: 50%; background: #ef4444; border: 2px solid var(--surface); }
.tab { position: relative; }

/* Administrador: empresas */
.barra-empresa { position: sticky; top: calc(env(safe-area-inset-top) + 66px); z-index: 4; margin: 0 16px 6px; display: flex; align-items: center; gap: 8px;
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); border-radius: 14px; padding: 4px 4px 4px 12px; }
.barra-empresa select { flex: 1; border: 0; background-color: transparent; font-weight: 800; color: var(--ink); padding: 9px 30px 9px 4px; }
.lista-empresas { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lista-empresas li { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.lista-empresas li small { display: block; color: var(--ink-3); }
.lista-empresas button { border: 0; background: transparent; color: var(--bad); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.lista-empresas button.btn { color: var(--ink); font-size: 13px; padding: 8px 12px; border: 1px solid var(--line); background: var(--surface); flex: none; }
.filtros { top: calc(env(safe-area-inset-top) + 64px); }
body:has(#barraEmpresa:not([hidden])) .filtros { top: calc(env(safe-area-inset-top) + 118px); }

/* Administrador */
.chip.admin { background: var(--brand); color: var(--brand-ink); border-color: transparent; font-weight: 700; }
.chip.admin .dot { display: none; }
.badge.usuario { background: color-mix(in srgb, var(--brand) 16%, var(--surface)); color: var(--brand); }
#filtroUsuario { width: 100%; }
.admin-card h2 { margin-top: 0; }

/* Deslizar hacia abajo para actualizar */
.ptr { position: fixed; z-index: 64; left: 50%; top: calc(env(safe-area-inset-top) + 8px); transform: translate(-50%, -70px); pointer-events: none; transition: transform .2s ease; }
.ptr-circulo { width: 42px; height: 42px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0, 0, 0, .25); display: grid; place-items: center; color: var(--brand); }
.ptr-circulo svg { width: 22px; height: 22px; stroke-width: 2.4; }
.ptr.listo .ptr-circulo { background: var(--brand); color: var(--brand-ink); }
.ptr.cargando .ptr-circulo svg { animation: girar .8s linear infinite; }

/* Aviso pequeño de actualización (arriba, sin interrumpir) */
.aviso-mini {
  position: fixed; z-index: 65; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 66px);
  display: flex; align-items: center; gap: 8px; padding: 5px 5px 5px 12px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  font-size: 13px; font-weight: 700; white-space: nowrap; animation: bajarMini .3s ease;
}
@keyframes bajarMini { from { transform: translate(-50%, -12px); opacity: 0; } }
.am-btn { border: 0; border-radius: 99px; padding: 6px 12px; font-weight: 800; font-size: 13px; background: var(--brand); color: var(--brand-ink); cursor: pointer; }
.am-x { border: 0; background: transparent; color: var(--ink-3); font-size: 14px; padding: 4px 6px; cursor: pointer; }
.estado-version { margin: 0; font-weight: 700; }
.estado-version.nueva { color: var(--brand); }

/* Aviso de actualización */
.aviso-update {
  position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); width: min(520px, calc(100% - 24px));
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "ico txt" "bot bot"; gap: 12px 12px;
  padding: 16px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
  animation: subirAviso .35s cubic-bezier(.2, .8, .2, 1);
}
@keyframes subirAviso { from { transform: translate(-50%, 30px); opacity: 0; } }
.au-ico { grid-area: ico; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.au-txt { grid-area: txt; display: flex; flex-direction: column; justify-content: center; }
.au-txt strong { font-size: 16px; font-weight: 800; }
.au-txt span { font-size: 13px; color: var(--ink-3); }
.aviso-update .btn { padding: 13px; font-size: 15px; }
.au-luego { grid-area: bot; justify-self: start; border: 0 !important; background: transparent !important; color: var(--ink-3) !important; }
#btnActualizar, .au-principal { grid-area: bot; justify-self: end; min-width: 60%; }

/* Botón del hero */
.hero-btn { position: relative; z-index: 1; margin-top: 14px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 12px; font-weight: 700; font-size: 15px; background: #fff; color: #0e7490; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
.hero-btn svg { width: 20px; height: 20px; }
.hero-btn:active { transform: scale(.98); }

/* Resumen: chips de meses + cuadro del mes */
.meses-chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.meses-chips::-webkit-scrollbar { display: none; }
.chip-mes { flex: none; position: relative; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 99px; padding: 9px 16px; font-weight: 700; font-size: 14px; cursor: pointer; }
.chip-mes.hay::after { content: ""; position: absolute; top: 5px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.chip-mes.on { background: var(--brand); color: var(--brand-ink); border-color: transparent; box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 35%, transparent); }
.chip-mes.on::after { background: var(--brand-ink); }
.cuadro-mes { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); }
.cm-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.cm-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.cm-head span { font-size: 12px; color: var(--ink-3); }
.cm-fila { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.1fr; gap: 6px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cm-nombre { font-weight: 800; font-size: 16px; display: flex; flex-direction: column; }
.cm-nombre .sw { display: inline-block; margin-right: 6px; }
.cm-nombre small { font-weight: 500; font-size: 12px; color: var(--ink-3); }
.cm-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14.5px; display: flex; flex-direction: column; }
.cm-num span { font-size: 11px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.cm-num.total { font-weight: 800; font-size: 16px; }
.cm-igv { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-radius: 16px; padding: 14px 16px; }
.cm-igv span { font-weight: 800; display: flex; flex-direction: column; }
.cm-igv small { font-weight: 500; font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.cm-igv strong { font-size: 22px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.cm-igv.pagar { background: var(--warn-soft); }
.cm-igv.pagar strong { color: var(--warn); }
.cm-igv.favor { background: var(--ok-soft); }
.cm-igv.favor strong { color: var(--ok); }
.titulo-anio { font-size: 16px; margin: 22px 2px 0; }
@media (max-width: 370px) { .cm-fila { grid-template-columns: 1fr 1fr 1fr; } .cm-nombre { grid-column: 1 / -1; } }

/* Agrupar / por empresa */
.seg-mini { flex: 1; min-width: 200px; }
.seg-mini span { padding: 7px 6px; font-size: 13px; }
.btn-tel { width: 100%; }
.tabla-emp { min-width: 0; }
.tabla-emp td:first-child { white-space: normal; text-transform: none; max-width: 180px; }
.tabla-emp td:first-child small { display: block; color: var(--ink-3); font-size: 11.5px; }
.tabla-emp .pct { display: block; height: 4px; border-radius: 4px; background: var(--series-1); margin-top: 4px; min-width: 2px; }
.tabla-emp.ventas .pct { background: var(--series-2); }
.grupo-emp small { color: var(--ink-3); }

/* Cámara y editor (pantalla completa, siempre oscuras) */
.pantalla { position: fixed; inset: 0; z-index: 40; background: #000; color: #fff; display: flex; flex-direction: column; }
.camara video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-guia { position: absolute; inset: 14% 7% 22%; pointer-events: none; }
.cam-guia i { position: absolute; width: 36px; height: 36px; border: 3px solid #67e8f9; }
.cam-guia i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.cam-guia i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.cam-guia i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.cam-guia i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.cam-guia span { position: absolute; left: 50%; bottom: -44px; transform: translateX(-50%); white-space: nowrap; font-size: 13px; background: rgba(0, 0, 0, .55); padding: 6px 12px; border-radius: 99px; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.ver { animation: flash .35s ease; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }
.cam-top, .ed-top { position: relative; display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; gap: 12px; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: center; padding: 20px 16px calc(env(safe-area-inset-bottom) + 24px); background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }
.cam-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.cam-btn.on { background: #fde047; color: #000; }
.cam-btn.pulso { animation: pulsoLuz 1.2s ease-in-out infinite; }
@keyframes pulsoLuz { 50% { box-shadow: 0 0 0 10px rgba(253, 224, 71, .35); background: rgba(253, 224, 71, .5); } }
.cam-aviso { position: absolute; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 76px); z-index: 2; max-width: calc(100% - 32px); text-align: center;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 13.5px; font-weight: 600; padding: 8px 14px; border-radius: 99px; }
.cam-btn.vacio-btn { background: none; backdrop-filter: none; }
.cam-listo { min-width: 48px; height: 48px; padding: 0 16px; border-radius: 99px; border: 0; background: #22d3ee; color: #062a35; font-weight: 800; font-size: 15px; cursor: pointer; }
.cam-bottom:has(.cam-listo[hidden])::after { content: ""; width: 48px; }
.cam-disparo { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; cursor: pointer; }
.cam-disparo span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.cam-disparo:active span { transform: scale(.88); }
.ed-top strong { font-size: 17px; }
.ed-ayuda { margin: 0; text-align: center; font-size: 13px; color: rgba(255, 255, 255, .7); }
.ed-lienzo { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 18px 26px; }
.ed-marco { position: relative; max-width: 100%; max-height: 100%; display: flex; touch-action: none; }
.ed-marco canvas { display: block; max-width: 100%; max-height: calc(100dvh - 330px); width: auto; height: auto; border-radius: 4px; }
.ed-marco svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ed-punto { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; cursor: grab; touch-action: none; display: grid; place-items: center; }
.ed-punto::after { content: ""; width: 22px; height: 22px; border-radius: 50%; background: rgba(45, 212, 191, .25); border: 3px solid #22d3ee; box-shadow: 0 0 0 2px rgba(0, 0, 0, .4); transition: transform .1s; }
.ed-punto.activo::after { transform: scale(1.35); background: rgba(45, 212, 191, .5); }
.ed-herr { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; padding: 8px 16px; }
.ed-modos { display: flex; background: rgba(255, 255, 255, .12); border-radius: 12px; padding: 4px; gap: 4px; }
.ed-modos button, .ed-chip { border: 0; background: none; color: #fff; padding: 8px 12px; border-radius: 9px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.ed-modos button.on { background: #fff; color: #000; }
.ed-chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .12); border-radius: 12px; padding: 12px; }
.ed-chip svg { width: 18px; height: 18px; }
.ed-chip.on { background: #06b6d4; color: #062a35; }
.ed-chip:disabled { opacity: .5; }
.ed-acciones { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; padding: 8px 16px calc(env(safe-area-inset-bottom) + 16px); }
.ed-acciones:has(#edRepetir[hidden]) { grid-template-columns: 1fr; }
.ed-acciones .btn { padding: 15px; font-size: 16px; }
.ed-acciones .btn.sec { background: rgba(255, 255, 255, .12); color: #fff; border: 0; }
.ed-acciones .btn { background: #06b6d4; color: #062a35; }

/* Inicio simple: dos botones grandes */
.acciones { grid-template-columns: 1fr; }
.btn-accion { padding: 18px; }
.btn-accion svg { width: 48px; height: 48px; padding: 11px; border-radius: 14px; }
.btn-accion span { font-size: 17px; }
.btn-accion small { font-size: 13px; }
.btn-accion.primario { padding: 22px 18px; }
.btn-accion.primario span { font-size: 19px; }
.btn-accion.mini { grid-template-rows: auto; justify-content: center; background: transparent; box-shadow: none; border-style: dashed; padding: 10px; }
.btn-accion.mini svg { grid-row: auto; width: 30px; height: 30px; padding: 6px; background: none; }
.btn-accion.mini span { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.pasos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; text-align: left; }
.pasos li { display: flex; gap: 12px; align-items: center; color: var(--ink-2); }
.pasos b { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }

@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 380px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 label:last-child { grid-column: 1 / -1; }
}
