/* Gestión · Provocador — identidad «refinado y luminoso»
   Papel cálido y aireado, cifras protagonistas en Bricolage Grotesque, texto en Instrument Sans.
   El color de marca (Ajustes › Empresa) solo aparece en lo importante. */
@font-face { font-family: 'Instrument Sans'; font-weight: 400; font-display: swap; src: url(fonts/instrument-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-weight: 500; font-display: swap; src: url(fonts/instrument-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-weight: 600; font-display: swap; src: url(fonts/instrument-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-weight: 700; font-display: swap; src: url(fonts/instrument-sans-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Bricolage Grotesque'; font-weight: 600; font-display: swap; src: url(fonts/bricolage-grotesque-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Bricolage Grotesque'; font-weight: 700; font-display: swap; src: url(fonts/bricolage-grotesque-latin-700-normal.woff2) format('woff2'); }

:root {
  --bg: #F6F6F3; --bg-2: #EFEEEA; --panel: #FFFFFF; --hover: #FAFAF7;
  --line: #E4E3DE; --line-2: #EDECE8; --ink: #1B1B18; --ink-2: #45443E; --muted: #74726A; --faint: #A3A199;
  --brand: #2F5BEA; --brand-ink: #FFFFFF; --brand-soft: color-mix(in srgb, var(--brand) 9%, white); --brand-line: color-mix(in srgb, var(--brand) 35%, white);
  --green: #1D7447; --green-bg: #E6F2EA; --amber: #8E5A0B; --amber-bg: #FBF0DD; --red: #B0372A; --red-bg: #FBEAE6; --blue: #2C5895; --blue-bg: #E9EEF6;
  --violet: #5A43A8; --violet-bg: #EFEBF8; --gray: #5C5A54; --gray-bg: #EEEDE8;
  --r: 12px; --r-s: 8px; --shadow: 0 1px 0 rgba(27, 27, 24, .04); --shadow-l: 0 18px 44px rgba(27, 27, 24, .13), 0 2px 8px rgba(27, 27, 24, .06);
  --display: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  --text: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --side: 244px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 14px/1.5 var(--text); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, .money { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; }
h1 { font: 700 28px/1.15 var(--display); letter-spacing: -.025em; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
::placeholder { color: var(--faint); }
::selection { background: color-mix(in srgb, var(--brand) 22%, white); }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px 14px; background: var(--bg); border-right: 1px solid var(--line-2); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; min-height: 46px; }
.brand img { max-height: 30px; max-width: 160px; object-fit: contain; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: #fff; display: grid; place-items: center; font: 700 14px var(--display); }
.brand b { font: 700 17px var(--display); letter-spacing: -.02em; }
.new-btn { margin: 0 2px 8px; }
.find { display: flex; align-items: center; gap: 9px; height: 36px; margin: 0 2px 12px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--muted); cursor: pointer; font-size: 13.5px; text-align: left; }
.find:hover { border-color: #D6D4CD; color: var(--ink-2); }
.find svg { width: 16px; height: 16px; }
.find kbd, .kbd { margin-left: auto; font: 500 11px var(--text); color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; background: var(--bg); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: var(--r-s); color: var(--ink-2); font-weight: 500; border: 1px solid transparent; }
.nav a svg { color: var(--muted); }
.nav a:hover { background: rgba(27, 27, 24, .045); }
.nav a.on { background: var(--panel); border-color: var(--line); color: var(--ink); box-shadow: 0 1px 2px rgba(27, 27, 24, .05); }
.nav a.on svg { color: var(--brand); }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 10px; }
.nav .navh { font-size: 12px; color: var(--faint); font-weight: 500; padding: 14px 11px 4px; }
.side .nav { overflow-y: auto; min-height: 0; flex: 1; margin-bottom: 8px; scrollbar-width: thin; }
.side .nav a { padding-top: 6px; padding-bottom: 6px; }
.side .foot { padding: 12px 8px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.side .me { display: flex; align-items: center; gap: 9px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-2); color: var(--ink-2); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.side .me .who { min-width: 0; flex: 1; line-height: 1.25; }
.side .me .who b { font-weight: 600; font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .legal { font-size: 11.5px; color: var(--faint); }
.side .legal a:hover { color: var(--ink-2); text-decoration: underline; }
main { min-width: 0; }
.page { max-width: 1200px; margin: 0 auto; padding: 36px 40px 96px; }
.page.narrow { max-width: 900px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; flex-wrap: wrap; }
.head h1 { margin-right: auto; }
.head .sub { width: 100%; color: var(--muted); margin-top: -6px; max-width: 72ch; font-size: 14.5px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: 12px; }
.back:hover { color: var(--ink); }

/* ---------- Botones y campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); font-weight: 550; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow); transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--hover); border-color: #D6D4CD; }
.btn:active { transform: translateY(.5px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 1px 2px rgba(27, 27, 24, .12); }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, black); border-color: color-mix(in srgb, var(--brand) 88%, black); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: rgba(27, 27, 24, .05); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn .spin, .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label.f { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); min-width: 0; }
label.f > .in, label.f > .combo, label.f > div { display: block; margin-top: 6px; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.in, select.in, textarea.in { height: 38px; width: 100%; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--r-s); background: #fff; outline: none; transition: border-color .12s, box-shadow .12s; min-width: 0; }
.in:hover { border-color: #D6D4CD; }
textarea.in { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
select.in { padding-right: 30px; appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2374726A' stroke-width='2.2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; }
.in:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 13%, transparent); }
.in.err { border-color: var(--red); }
.in[readonly] { background: var(--bg); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 10px; color: var(--faint); width: 17px; height: 17px; }
.search .in { padding-left: 35px; }

/* ---------- Paneles ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.panel > .ph { display: flex; align-items: center; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--line-2); min-height: 56px; }
.panel > .ph h2 { margin-right: auto; }
.panel > .pb { padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 20px; align-items: flex-start; }
.note { padding: 12px 14px; border-radius: 10px; background: var(--gray-bg); color: var(--ink-2); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }
.note svg { margin-top: 1px; }
.note.warn { background: var(--amber-bg); color: var(--amber); }
.note.bad { background: var(--red-bg); color: var(--red); }
.note.good { background: var(--green-bg); color: var(--green); }
.note.info { background: var(--blue-bg); color: var(--blue); }
.note a { text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }

/* ---------- Cifras ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 30px; }
.metric { padding: 2px 24px 2px; border-left: 1px solid var(--line); min-width: 0; }
.metric:first-child { border-left: 0; padding-left: 0; }
.metric .k { color: var(--muted); font-size: 13px; font-weight: 500; }
.metric .v { font: 600 31px/1.1 var(--display); letter-spacing: -.03em; margin-top: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fig .dec { font-size: .6em; letter-spacing: -.01em; opacity: .62; margin-left: .04em; }
.metric .d { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.metric .d a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.metric .d.bad { color: var(--red); }

/* ---------- Tablas ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--hover); }
.tbl .r, .tbl th.r { text-align: right; }
.tbl td.num, .tbl .r { font-variant-numeric: tabular-nums; }
.tbl .strong { font-weight: 600; }
.tbl .cl { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; font-variant-numeric: tabular-nums; }
.tblwrap { overflow-x: auto; }
.panel > .tblwrap:last-child, .panel > div:last-child > .tblwrap:last-child { border-radius: 0 0 var(--r) var(--r); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }

/* ---------- Estados ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 8px; border-radius: 999px; font-size: 12.5px; font-weight: 550; white-space: nowrap; background: var(--gray-bg); color: var(--gray); }
.badge:not(:has(svg))::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.violet { background: var(--violet-bg); color: var(--violet); }
.badge.strike { text-decoration: line-through; }
.badge svg { width: 12px; height: 12px; }
.vfdot { display: inline-flex; vertical-align: middle; margin-left: 6px; color: var(--green); }
.vfdot svg { width: 15px; height: 15px; }
.vfdot.amber { color: var(--amber); } .vfdot.red { color: var(--red); }

/* ---------- Filtros ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line-2); }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer; transition: background .12s, border-color .12s; }
.chip:hover { border-color: #D2D0C9; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg { display: inline-flex; padding: 3px; background: var(--bg-2); border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; font-weight: 550; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(27, 27, 24, .08); }
.toolbar select.in { width: auto; height: 34px; }

/* ---------- Vacío ---------- */
.empty { text-align: center; padding: 60px 24px; }
.empty .ico { width: 52px; height: 52px; border-radius: 50%; background: var(--bg-2); color: var(--ink-2); display: inline-grid; place-items: center; margin-bottom: 16px; }
.empty .ico svg { width: 22px; height: 22px; }
.empty h3 { font: 600 19px/1.25 var(--display); letter-spacing: -.015em; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 400px; margin: 0 auto 18px; }

/* ---------- Gráfico ---------- */
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

/* ---------- Modal y avisos ---------- */
.overlay { position: fixed; inset: 0; background: rgba(27, 27, 24, .32); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .14s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 16px; box-shadow: var(--shadow-l); width: 100%; max-width: 540px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .16s cubic-bezier(.2, .8, .3, 1); }
.modal.wide { max-width: 780px; }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0; } }
.modal .mh { display: flex; align-items: center; padding: 20px 22px 6px; gap: 10px; }
.modal .mh h2 { margin-right: auto; font: 600 20px/1.2 var(--display); letter-spacing: -.02em; }
.modal .mb { padding: 12px 22px 20px; overflow-y: auto; }
.modal .mf { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.modal .mf .left { margin-right: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: flex-end; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; padding: 11px 16px 11px 13px; border-radius: 11px; box-shadow: var(--shadow-l); font-weight: 500; max-width: min(92vw, 440px); animation: toastin .2s cubic-bezier(.2, .8, .3, 1); pointer-events: auto; line-height: 1.4; }
.toast svg { width: 17px; height: 17px; color: #8FD4A8; flex: none; }
.toast.bad { background: #2A1B18; }
.toast.bad svg { color: #FF9C8A; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }
.menu { position: absolute; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-l); padding: 5px; min-width: 220px; animation: pop .12s ease-out; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; font-weight: 500; }
.menu button svg { color: var(--muted); }
.menu button:hover { background: var(--bg); }
.menu button.danger, .menu button.danger svg { color: var(--red); }
.menu .sep { height: 1px; background: var(--line-2); margin: 4px 0; }

/* ---------- Esqueleto de carga ---------- */
.skel { animation: skin .2s .18s both; }
@keyframes skin { from { opacity: 0; } }
.sk { border-radius: 8px; background: linear-gradient(90deg, var(--bg-2) 0%, #F7F6F3 50%, var(--bg-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-h { width: 220px; height: 30px; margin-bottom: 30px; }
.sk-m { height: 64px; }
.sk-p { height: 320px; border-radius: var(--r); margin-top: 26px; }

/* ---------- Buscador global ---------- */
.overlay.top { place-items: start center; padding-top: 11vh; }
.cmdk { width: 100%; max-width: 640px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-l); overflow: hidden; animation: pop .14s ease-out; display: flex; flex-direction: column; max-height: 74vh; }
.cmdk .q { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line-2); }
.cmdk .q svg { width: 20px; height: 20px; color: var(--muted); }
.cmdk .q input { flex: 1; height: 58px; border: 0; outline: none; font-size: 17px; background: none; min-width: 0; }
.cmdk .res { overflow-y: auto; padding: 6px; }
.cmdk .grp { font-size: 12px; color: var(--faint); font-weight: 500; padding: 10px 12px 4px; }
.cmdk .it { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.cmdk .it .ic { width: 32px; height: 32px; border-radius: 9px; background: var(--bg); display: grid; place-items: center; color: var(--ink-2); flex: none; }
.cmdk .it .ic svg { width: 16px; height: 16px; }
.cmdk .it .tx { flex: 1; min-width: 0; }
.cmdk .it .tx b { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk .it .tx span { font-size: 12.5px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk .it .mt { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cmdk .it.act { background: var(--bg); }
.cmdk .it.act .ic { background: var(--brand); color: var(--brand-ink); }
.cmdk .none { padding: 28px 16px; text-align: center; color: var(--muted); }
.cmdk .ft { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--faint); }

/* ---------- Primeros pasos ---------- */
.setup { margin-bottom: 26px; }
.setup .ph .progress { width: 140px; }
.setup .steps2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.setup .st2 { display: flex; gap: 12px; align-items: flex-start; padding: 14px 20px; border-top: 1px solid var(--line-2); }
.setup .st2:nth-child(odd) { border-right: 1px solid var(--line-2); }
.setup .st2:nth-child(-n+2) { border-top: 0; }
.setup .st2 .ck { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); flex: none; display: grid; place-items: center; margin-top: 1px; }
.setup .st2.done .ck { background: var(--green); border-color: var(--green); color: #fff; }
.setup .st2.done .ck svg { width: 13px; height: 13px; stroke-width: 2.4; }
.setup .st2 .tx { flex: 1; min-width: 0; }
.setup .st2 b { font-weight: 600; display: block; }
.setup .st2.done b { color: var(--muted); font-weight: 500; }
.setup .st2 span { font-size: 12.5px; color: var(--muted); }
.setup .st2 .go { align-self: center; }

/* ---------- Documento: vista ---------- */
.docview { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 24px; align-items: start; }
.paper-frame { background: var(--bg-2); border-radius: var(--r); padding: 20px; }
.paper-frame iframe { width: 100%; height: calc(100vh - 160px); min-height: 640px; border: 0; border-radius: 4px; background: #fff; box-shadow: 0 1px 3px rgba(27, 27, 24, .08), 0 14px 32px rgba(27, 27, 24, .08); display: block; }
.docside { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 14px; }
.docside .total { font: 600 36px/1.1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.list-plain { display: flex; flex-direction: column; }
.list-plain > div { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.list-plain > div:last-child { border-bottom: 0; }
.mobile-doc { display: none; }

/* ---------- Editor: la hoja ---------- */
.editor-bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.editor-bar .inner { max-width: 1000px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 10px; }
.editor-bar h1 { font: 700 18px/1.2 var(--display); letter-spacing: -.02em; margin-right: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.desk { padding: 32px 24px 120px; }
.sheet { max-width: 900px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(27, 27, 24, .04), 0 22px 48px rgba(27, 27, 24, .07); position: relative; }
.sheet .sx { padding: 40px 48px; }
.sheet .top { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: start; }
.sheet .issuer img { max-height: 46px; max-width: 210px; object-fit: contain; margin-bottom: 12px; display: block; }
.sheet .issuer .nm { font: 700 20px var(--display); letter-spacing: -.02em; margin-bottom: 6px; }
.sheet .issuer .dt { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.sheet .doctitle { font: 700 30px/1.05 var(--display); letter-spacing: -.03em; }
.sheet .docnum { color: var(--brand); font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.sheet .docnum.pending { color: var(--muted); font-weight: 500; }
.sheet .dates { display: grid; grid-template-columns: repeat(2, 152px); gap: 10px 12px; margin-top: 18px; }
.sheet .dates label.f { font-size: 12px; color: var(--muted); }
.sheet hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.who-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.client-box { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
.client-card { border: 1px dashed #D9D7D0; border-radius: 10px; padding: 13px 15px; }
.client-card .nm { font-weight: 650; font-size: 15px; }
.client-card .dt { color: var(--muted); font-size: 13px; line-height: 1.5; }
.client-card .warn { color: var(--amber); font-size: 12.5px; margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.combo { position: relative; }
.combo .drop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-l); max-height: 300px; overflow-y: auto; padding: 4px; }
.combo .opt { padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.combo .opt.act, .combo .opt:hover { background: var(--bg); }
.combo .opt small { color: var(--muted); }
.combo .opt.add { color: var(--brand); font-weight: 550; justify-content: flex-start; align-items: center; }
.lines { margin-top: 6px; }
.lines .lh, .lines .lr { display: grid; grid-template-columns: minmax(0, 1fr) 76px 108px 70px 104px 112px 34px; gap: 8px; align-items: start; }
.lines.ret .lh, .lines.ret .lr { grid-template-columns: minmax(0, 1fr) 70px 100px 62px 96px 74px 104px 34px; }
.lines .lh { font-size: 12px; color: var(--muted); font-weight: 500; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.lines .lh .r { text-align: right; }
.lines .lr { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.lines .lr .in { height: 36px; }
.lines .lr .in.r { text-align: right; font-variant-numeric: tabular-nums; }
.lines .lr textarea.in { min-height: 36px; height: 36px; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.lines .lr .amt { text-align: right; font-weight: 600; padding-top: 8px; font-variant-numeric: tabular-nums; }
.lines .lr .del { opacity: .35; }
.lines .lr:hover .del { opacity: 1; }
.lines .adddesc { font-size: 12.5px; color: var(--muted); background: none; border: 0; padding: 5px 0 0; cursor: pointer; }
.lines .adddesc:hover { color: var(--brand); }
.addline { margin-top: 14px; }
.sheet .bottom { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 36px; margin-top: 28px; align-items: start; }
.totals { display: flex; flex-direction: column; gap: 7px; font-variant-numeric: tabular-nums; }
.totals .t { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-2); }
.totals .t span:first-child { color: var(--muted); }
.totals .grand { margin-top: 10px; padding: 14px 16px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.totals .grand b { font: 700 23px var(--display); letter-spacing: -.02em; }
.legal-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.doc-opts { display: flex; flex-direction: column; gap: 10px; }
.doc-opts:empty { display: none; }
.doc-opts .f { max-width: 320px; }

/* ---------- Ajustes ---------- */
.settings { display: grid; grid-template-columns: 214px minmax(0, 1fr); gap: 32px; align-items: start; }
.subnav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 1px; }
.subnav a { padding: 7px 11px; border-radius: var(--r-s); color: var(--ink-2); font-weight: 500; border: 1px solid transparent; }
.subnav a:hover { background: rgba(27, 27, 24, .045); }
.subnav a.on { background: #fff; border-color: var(--line); color: var(--ink); box-shadow: 0 1px 2px rgba(27, 27, 24, .05); }
.steps { display: flex; flex-direction: column; gap: 0; }
.step { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding: 20px; border-bottom: 1px solid var(--line-2); }
.step:last-child { border-bottom: 0; }
.step .n { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--muted); }
.step.done .n { background: var(--green); border-color: var(--green); color: #fff; }
.step h3 { margin-bottom: 4px; }
.decl { border: 1px solid var(--line); border-radius: var(--r-s); max-height: 340px; overflow-y: auto; }
.decl div { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.decl div:last-child { border-bottom: 0; }
.decl b { font-weight: 600; display: block; }
.progress { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.drop-zone { border: 1.5px dashed #D9D7D0; border-radius: var(--r); padding: 20px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .12s, background .12s; }
.drop-zone:hover, .drop-zone.over { border-color: var(--brand-line); background: var(--brand-soft); color: var(--ink-2); }
.drop-zone b { color: var(--ink); }
.swatch { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); padding: 0; cursor: pointer; }
.provs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.prov { display: flex; flex-direction: column; gap: 4px; padding: 15px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; position: relative; transition: border-color .12s; }
.prov:hover { border-color: #D2D0C9; }
.prov input { position: absolute; opacity: 0; pointer-events: none; }
.prov.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.prov b { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.prov svg { width: 13px; height: 13px; vertical-align: -2px; }
.code { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; line-height: 1.7; }

/* ---------- Acceso ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .box { width: 100%; max-width: 410px; }
.auth .box .panel { padding: 30px; box-shadow: 0 22px 48px rgba(27, 27, 24, .07); }
.auth h1 { font-size: 28px; margin-bottom: 6px; }
.auth .lead { color: var(--muted); margin-bottom: 22px; }

/* ---------- Gastos escaneados ---------- */
.modal.xl { max-width: 1180px; }
.xsplit { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.xprev { position: sticky; top: 0; height: calc(100vh - 210px); min-height: 420px; border-radius: 10px; background: var(--bg-2); overflow: auto; }
.xprev iframe { width: 100%; height: 100%; border: 0; display: block; }
.xprev img { width: 100%; display: block; }
.xsplit .xfile { padding: 11px 13px; text-align: left; }
.review-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 16px 18px; border-radius: var(--r); background: var(--violet-bg); margin-bottom: 18px; }
.review-bar > svg { color: var(--violet); flex-shrink: 0; width: 22px; height: 22px; }
.review-bar b { font-weight: 600; }
.tbl tr.rv td { background: #FBFAFE; }
.tbl tr.rv:hover td { background: #F4F1FC; }
.tray { margin-bottom: 18px; }
.tray .list-plain > div { gap: 10px; }
.tray .list-plain .st { max-width: 55%; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray .spin { color: var(--brand); }
.i.green { color: var(--green); } .i.amber { color: var(--amber); } .i.red { color: var(--red); }
.inbox-line { display: flex; align-items: center; gap: 8px; margin: -6px 0 18px; flex-wrap: wrap; }
.inbox-line > span { flex: 1; min-width: 220px; }
.inbox-line > svg { flex-shrink: 0; }
.inbox-line b { color: var(--ink-2); font-weight: 550; }
.dropcover { position: fixed; inset: 0; z-index: 40; background: rgba(27, 27, 24, .28); backdrop-filter: blur(2px); display: none; place-items: center; pointer-events: none; }
.dropcover.on { display: grid; }
.dropcover > div { background: #fff; border: 2px dashed var(--brand); border-radius: 18px; padding: 36px 48px; display: flex; flex-direction: column; align-items: center; gap: 8px; box-shadow: var(--shadow-l); }
.dropcover svg { width: 30px; height: 30px; color: var(--brand); }
.dropcover b { font: 600 21px var(--display); letter-spacing: -.02em; }
.dropcover span { color: var(--muted); font-size: 13.5px; }

/* ---------- Proyectos, recurrentes y tesorería ---------- */
#ml > .pb { padding: 16px 20px; }
.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; margin-bottom: 20px; }
.pgrid.t2 { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.pgrid .panel > p.pb { margin: 0; }
.metric .bar { height: 5px; border-radius: 3px; background: var(--bg-2); margin-top: 10px; overflow: hidden; max-width: 220px; }
.metric .bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.rlines { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.rline { display: grid; grid-template-columns: minmax(0, 1fr) 70px 100px 92px 104px 32px; gap: 6px; align-items: center; }
.rtot { text-align: right; font-size: 13px; color: var(--muted); padding-top: 4px; font-variant-numeric: tabular-nums; }
.rtot b { color: var(--ink); font-weight: 600; }
.accs { display: flex; gap: 12px; overflow-x: auto; margin-bottom: 16px; padding: 2px; }
.acc { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 220px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); text-align: left; cursor: pointer; transition: border-color .12s; }
.acc:hover { border-color: #D2D0C9; }
.acc .nm { font-weight: 600; }
.acc b { font: 600 21px var(--display); letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.acc .badge { margin-top: 6px; }
.acc.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.moves { display: flex; flex-direction: column; }
.mv { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto 32px; gap: 12px; align-items: start; padding: 13px 20px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.mv:last-child { border-bottom: 0; }
.mv .when { color: var(--muted); padding-top: 1px; font-variant-numeric: tabular-nums; }
.mv .what b { font-weight: 550; }
.mv .amt { font-weight: 600; white-space: nowrap; padding-top: 1px; font-variant-numeric: tabular-nums; }
.mv .amt.pos { color: var(--green); }
.mv.ignorado { opacity: .55; }
.mv .what svg { width: 14px; height: 14px; vertical-align: -2px; }
.cands { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cand { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand:hover { border-color: var(--brand-line); background: var(--brand-soft); }
.cand.exact { border-color: color-mix(in srgb, var(--green) 45%, white); color: var(--green); background: var(--green-bg); }
.cand svg { width: 13px !important; height: 13px !important; flex-shrink: 0; }
.list-plain > .click { cursor: pointer; }
.list-plain > .click:hover { background: var(--hover); }
.list-plain.pick { max-height: 360px; overflow-y: auto; }
.list-plain.pick > div { padding: 10px 6px; gap: 10px; }
.mapbox summary { cursor: pointer; color: var(--brand); margin-top: 12px; }

/* ---------- Barra inferior (móvil) ---------- */
.tabbar { display: none; }
.label-s { display: none; }
.mobile-top { display: none; }

@media (max-width: 1100px) {
  .docview { grid-template-columns: 1fr; }
  .docside { position: static; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 22px; }
  .metric:nth-child(odd) { border-left: 0; padding-left: 0; }
  .pgrid, .pgrid.t2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .page { padding: 20px 16px 110px; }
  .head { margin-bottom: 20px; }
  h1 { font-size: 25px; }
  .mobile-top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-2); position: sticky; top: 0; z-index: 15; }
  .mobile-top .brand { padding: 0; min-height: 0; margin-right: auto; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255, 255, 255, .95); backdrop-filter: blur(12px); border-top: 1px solid var(--line); z-index: 30; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 550; color: var(--muted); padding: 4px 0; background: none; border: 0; }
  .tabbar .on { color: var(--brand); }
  .tabbar svg.i { width: 22px; height: 22px; }
  .toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); align-items: center; }
  .settings { grid-template-columns: 1fr; gap: 16px; }
  .subnav { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; scrollbar-width: none; }
  .subnav a { white-space: nowrap; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .paper-frame { display: none; }
  .mobile-doc { display: block; }
  .tbl .hide-m { display: none; }
  .tbl th:first-child, .tbl td:first-child { padding-left: 16px; }
  .tbl th:last-child, .tbl td:last-child { padding-right: 16px; }
  .toolbar { padding: 12px 16px; }
  .panel > .ph { padding: 14px 16px; }
  .panel > .pb { padding: 16px; }
  .editor-bar .inner { padding: 10px 14px; }
  .editor-bar h1 { font-size: 16px; }
  .editor-bar .label-m { display: none; }
  .editor-bar .label-s { display: inline; }
  .editor-bar .btn { height: 34px; padding: 0 11px; }
  .editor-bar [data-a=del] { display: none; }
  .editor-bar h1 .badge { display: none; }
  .desk { padding: 14px 10px 120px; }
  .sheet .sx { padding: 24px 18px; }
  .sheet .top { grid-template-columns: 1fr; }
  .sheet .dates { grid-template-columns: 1fr 1fr; }
  .client-box, .sheet .bottom { grid-template-columns: 1fr; }
  .lines .lh { display: none; }
  .lines .lr, .lines.ret .lr { grid-template-columns: 1fr 1fr 1fr; }
  .lines .lr > .c-concept { grid-column: 1 / -1; }
  .lines .lr > .amt { grid-column: span 2; text-align: left; }
  .lines .lr > [data-ph]::before { content: attr(data-ph); display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
  .xsplit { display: block; } .xprev { display: none; }
  .setup .steps2 { grid-template-columns: 1fr; }
  .setup .st2:nth-child(odd) { border-right: 0; }
  .setup .st2:nth-child(2) { border-top: 1px solid var(--line-2); }
  .setup .st2 { padding: 13px 16px; }
  .setup .st2.done { display: none; }
  .setup .ph .progress { width: 80px; }
  .overlay.top { padding-top: 10px; }
}
@media (max-width: 700px) {
  .tray .list-plain .st { display: none; }
  #gpage .head .btns .btn span { display: none; }
  .rline { grid-template-columns: minmax(0, 1fr) 64px 88px; }
  .rline [data-del] { justify-self: end; }
  .mv { grid-template-columns: minmax(0, 1fr) auto 28px; padding: 12px 16px; }
  .mv .when { grid-column: 1 / -1; font-size: 12px; margin-bottom: -6px; }
  .acc { min-width: 190px; }
  .provs { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .metric { padding: 0 0 0 14px; }
  .metric .v { font-size: 23px; }
  .modal { max-height: calc(100vh - 20px); border-radius: 16px 16px 12px 12px; }
  .overlay { padding: 10px; align-items: end; }
  .overlay.top { align-items: start; }
  .cmdk { max-height: 82vh; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .side, .tabbar, .mobile-top, .editor-bar { display: none !important; } }
