/* ==========================================================================
   Aspecto de la app — diseño «Profesional oscuro» (propuesta B)
   Menú lateral oscuro, contenido claro, letra Lato, índigo como color principal.
   La factura en pantalla (.invoice) va aparte, al final, igual que el PDF.
   ========================================================================== */

@font-face { font-family: 'Lato'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/lato-regular.woff2') format('woff2'); }
@font-face { font-family: 'Lato'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/lato-bold.woff2') format('woff2'); }
@font-face { font-family: 'Lato'; font-weight: 900; font-style: normal; font-display: swap; src: url('fonts/lato-black.woff2') format('woff2'); }

:root {
    --bg: #f2f3f5;
    --surface: #ffffff;
    --surface-2: #f8f9fa;
    --text: #111827;
    --muted: #4b5563;
    --faint: #6b7280;
    --border: #e5e7eb;
    --chip: #f3f4f6;
    --accent: #4338ca;
    --accent-hover: #3730a3;
    --accent-soft: #eef0ff;
    --accent-ink: #3730a3;
    --accent-text: #ffffff;
    --good: #047857; --good-bg: #e6f5ef;
    --warn: #92400e; --warn-bg: #fef3c7; --warn-soft: #fffbeb; --warn-line: #fde68a;
    --bad: #b91c1c;  --bad-bg: #fee2e2;
    --danger-bg: var(--bad-bg); --danger-text: var(--bad); --success-text: var(--good);
    --side: #0f172a; --side-2: #1e293b; --side-text: #cbd5e1; --side-muted: #94a3b8; --side-accent: #a5b4fc;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(17, 24, 39, .05);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120; --surface: #151d2e; --surface-2: #1b2438; --text: #e5e7eb; --muted: #a3acbb; --faint: #8b95a7;
        --border: #263047; --chip: #1f2a40; --accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: #232a52; --accent-ink: #c7d2fe; --accent-text: #0b1120;
        --good: #6ee7b7; --good-bg: #0f2f26; --warn: #fcd34d; --warn-bg: #3a2c0c; --warn-soft: #221b0b; --warn-line: #4a3a12; --bad: #fca5a5; --bad-bg: #3b1616;
        --side: #070b16; --side-2: #151d2e; --shadow: none;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Lato', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.5; background: var(--bg); color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 900; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 900; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; font-weight: 700; }
a { color: var(--accent); }
code { font-size: .9em; background: var(--chip); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.strong { font-weight: 700; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.icon { flex: none; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- estructura: menú lateral + contenido ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; text-decoration: none; font-weight: 900; font-size: 1rem; line-height: 1.2; }
.side-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--side-accent); color: var(--side); display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: .85rem; flex: none; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 16px 12px 6px; }
.side-item { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 8px; color: var(--side-text); text-decoration: none; font-weight: 700; font-size: .92rem; }
.side-item:hover { background: var(--side-2); color: #fff; }
.side-item.is-active { background: var(--side-2); color: #fff; }
.side-item.is-active .icon { color: var(--side-accent); }
.side-foot { margin-top: auto; padding: 16px 10px 4px; border-top: 1px solid var(--side-2); display: flex; flex-direction: column; gap: 10px; font-size: .85rem; color: var(--side-muted); }
.side-foot select { width: 100%; min-height: 38px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--side-2); background: var(--side-2); color: #fff; font: inherit; }
.side-foot .link-button { color: var(--side-text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.side-user { color: #fff; font-weight: 700; }
.main { padding: 28px 32px 48px; min-width: 0; }
.container { max-width: 1140px; }

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .side { position: static; height: auto; padding: 12px; }
    .side-brand { padding: 4px 6px 10px; }
    .side-nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
    .side-label { display: none; }
    .side-item { white-space: nowrap; min-height: 44px; }
    .side-foot { margin-top: 8px; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 6px 0; }
    .side-foot form { flex: 1; min-width: 180px; }
    .main { padding: 20px 16px 40px; }
}

/* ---------- pantallas de acceso (sin menú) ---------- */
body.guest { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--side); }
.card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 12px; padding: 32px 28px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }

/* ---------- botones ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: var(--radius); background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button:hover { background: var(--accent-hover); }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.button-secondary:hover { background: var(--surface-2); border-color: var(--faint); }
.button-small { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.button-danger { background: var(--bad); color: #fff; }
.button-google { width: 100%; margin-top: 8px; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- avisos ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; background: var(--bad-bg); color: var(--bad); padding: 12px 14px; border-radius: var(--radius); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.flash { margin: 0 0 20px; padding: 12px 16px; border-radius: var(--radius); background: var(--good-bg); color: var(--good); font-weight: 700; }
.flash.alert { font-weight: 400; }
.notice { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.success { color: var(--good); font-weight: 700; }
.steps { padding-left: 20px; }

/* ---------- cabecera de página, paneles y tarjetas ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .muted { margin: 4px 0 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin: 0 0 20px; box-shadow: var(--shadow); }
.panel h2 { margin-top: 0; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-flush > .table { margin: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
.panel-head h2 .icon { color: var(--accent); }
.plain { list-style: none; padding: 0; margin: 0 0 1rem; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { font-size: .8rem; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 1.5rem; font-weight: 900; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr; } }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; color: var(--muted); background: var(--chip); padding: 3px 10px; border-radius: 999px; }

/* ---------- gráfico de barras (SVG) ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .bar-in { fill: var(--accent); }
.chart .bar-out { fill: #9ca3af; }
.chart text { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart .axis { stroke: var(--border); }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .in::before { background: var(--accent); }
.legend .out::before { background: #9ca3af; }

/* ---------- tablas ---------- */
.table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: .92rem; background: var(--surface); }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table a { font-weight: 700; text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table tfoot td { font-weight: 900; background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
@media (max-width: 640px) { .table { display: block; overflow-x: auto; } }

/* ---------- formularios ---------- */
.form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.form input { min-height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
.form .button { margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid fieldset { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px 20px; margin: 0; background: var(--surface); box-shadow: var(--shadow); }
.form-grid legend { font-weight: 900; padding: 0 6px; font-size: 1rem; }
.span-2, .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 640px) { .form-grid, .form-grid fieldset { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .label-row { font-size: .85rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.field input, .field select, .field textarea, .input-small {
    min-height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font: inherit; width: 100%;
}
.field textarea { padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
.field input[type="color"] { padding: 3px; height: 42px; width: 80px; }
.field input[type="file"] { padding: 8px; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: .85rem; margin: 0; font-weight: 700; }
.hint { color: var(--muted); font-size: .85rem; margin: 2px 0 0; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400 !important; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.input-small { min-height: 34px; padding: 0 8px; font-size: .85rem; width: auto; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.logo-preview { max-width: 200px; max-height: 80px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 6px; }

/* ---------- ayudas «?» (sin JavaScript) ---------- */
.help { display: inline-block; position: relative; font-weight: 400; }
.help > summary { list-style: none; cursor: pointer; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: .75rem; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; }
.help > summary::-webkit-details-marker { display: none; }
.help[open] > summary { background: var(--accent); color: var(--accent-text); }
.help-body { position: absolute; z-index: 20; top: 26px; left: -12px; width: min(360px, 80vw); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(15, 23, 42, .18); font-size: .88rem; line-height: 1.5; text-transform: none; letter-spacing: 0; white-space: normal; text-align: left; }
.help-body p { margin: 0 0 8px; }
.help-body p:last-child { margin-bottom: 0; }
.help-title { font-weight: 900; }
.help-example { background: var(--surface-2); padding: 8px 10px; border-radius: 6px; }
.help-list { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.hint-item { display: inline-flex; align-items: center; gap: 4px; }
#operacion-texto { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border-radius: var(--radius); }
.warnings li { display: flex; gap: 8px; align-items: center; margin: 4px 0; color: var(--warn); }

/* ---------- clientes ---------- */
.searchbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; }
.searchbar input[name="q"] { flex: 1; min-width: 200px; min-height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
.danger-zone { margin-top: 24px; }
.danger-zone .link-button { color: var(--bad); }

/* ---------- facturas ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--chip); color: var(--text); white-space: nowrap; }
.badge-ok { background: var(--good-bg); color: var(--good); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--accent-soft); color: var(--accent-ink); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 0 0 16px; }
.filters .field { min-width: 150px; }
.field-button { justify-content: flex-end; }
.summary { margin: 8px 0 0; }

.lines { display: flex; flex-direction: column; gap: 10px; }
.line { display: grid; grid-template-columns: minmax(180px, 3fr) 80px 110px 70px minmax(120px, 1.4fr) 100px auto; gap: 8px; align-items: start; }
.line-head { font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.line textarea, .line input, .line select { width: 100%; min-height: 40px; padding: 8px 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
.line output { padding-top: 9px; font-variant-numeric: tabular-nums; font-weight: 700; }
.line-error textarea, .line-error input { border-color: var(--bad); }
.line-msg { grid-column: 1 / -1; }
@media (max-width: 760px) {
    .line { grid-template-columns: 1fr 1fr; }
    .line textarea { grid-column: 1 / -1; }
    .line-head { display: none; }
}
.totals-box { justify-self: end; min-width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.totals-box dl, .invoice-totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin: 0; }
.totals-box dd, .invoice-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals-box .big { font-weight: 900; font-size: 1.15rem; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.review-list { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.review-list dt { font-weight: 700; color: var(--muted); }
.review-list dd { margin: 0; }
.big-number { font-size: 1.25rem; font-weight: 900; }
.check-warn { color: var(--warn); font-weight: 700; }
.warnings { background: var(--warn-bg); border-color: transparent; }
.emit-box { border: 2px solid var(--accent); }
.action-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; }
.action-grid h3 { font-size: 1rem; margin: 0 0 6px; }
@media (max-width: 640px) { .action-grid, .review-list { grid-template-columns: 1fr; } }
.records { margin: 16px 0; }
.hash { font-size: .75rem; word-break: break-all; }

/* ---------- gastos ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .85rem; font-weight: 700; text-decoration: none; }
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.cat { display: inline-block; font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--chip); color: var(--text); }
.note { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.note-bad { color: var(--bad); }
.att { display: inline-flex; width: 30px; height: 30px; border-radius: 8px; align-items: center; justify-content: center; }
.att-ok { background: var(--good-bg); color: var(--good); }
.att-bad { background: var(--bad-bg); color: var(--bad); }
.gasto-lines { display: flex; flex-direction: column; gap: 8px; }
.gasto-line { display: grid; grid-template-columns: minmax(120px, 1fr) 130px minmax(120px, 1fr) minmax(120px, 1fr); gap: 10px; align-items: end; }
.gasto-line .field label { font-size: .75rem; }
@media (max-width: 640px) { .gasto-line { grid-template-columns: 1fr 1fr; } }
.gasto-totales { display: flex; gap: 24px; flex-wrap: wrap; justify-content: flex-end; font-variant-numeric: tabular-nums; }
.gasto-totales strong { font-size: 1.15rem; font-weight: 900; }
.preview-file { width: 100%; min-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.preview-img { max-width: 100%; max-height: 640px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; display: block; }

/* Documento de factura: siempre en claro, como en papel. Mismo diseño minimalista que el PDF. */
.invoice {
    --doc-primary: #1f5fbf; --doc-secondary: #5d6673;
    position: relative; overflow: hidden; background: #fff; color: #27272a; border: 1px solid #dde1e6; border-radius: 6px;
    padding: 48px 52px 36px; margin: 16px 0; font-size: 14px; line-height: 1.55; box-shadow: 0 1px 3px rgba(0,0,0,.06);
    max-width: 860px;
}
.invoice > * { position: relative; }
.invoice p { margin: 0; }
.invoice .invoice-bg { position: absolute; top: 34%; left: 8%; width: 84%; max-height: 50%; object-fit: contain; opacity: .09; pointer-events: none; }
.invoice-watermark { position: absolute !important; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 2;
    font-size: 72px; font-weight: 900; color: rgba(220, 38, 38, .16); transform: rotate(-30deg); letter-spacing: .12em; text-align: center; }
.invoice-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.invoice-logo { max-width: 260px; max-height: 60px; object-fit: contain; display: block; }
.invoice-brand { font-size: 24px; font-weight: 900; color: #18181b; }
.invoice-meta { text-align: right; color: #71717a; font-size: 13px; }
.invoice-title { font-size: 14px; font-weight: 900; margin: 0 0 4px; color: var(--doc-primary); text-transform: uppercase; letter-spacing: .3em; }
.invoice-number { font-size: 22px; font-weight: 700; color: #18181b; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 48px; color: #52525b; }
.invoice-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .18em; color: var(--doc-primary); margin-bottom: 6px !important; }
.invoice-name { font-weight: 700; font-size: 15px; color: #18181b; }
.invoice-note { margin-top: 28px !important; color: #52525b; }
.invoice-period { margin-top: 28px !important; color: #52525b; }
.invoice-scroll { overflow-x: auto; }
.invoice-lines { width: 100%; border-collapse: collapse; margin-top: 20px; }
.invoice-lines th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #71717a; text-align: left; padding: 0 8px 10px; border-bottom: 2px solid #18181b; }
.invoice-lines td { padding: 12px 8px; border-bottom: 1px solid #e4e4e7; vertical-align: top; }
.invoice-lines td:first-child { overflow-wrap: anywhere; min-width: 10em; }
.invoice-parties { overflow-wrap: anywhere; }
.invoice .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.invoice .strong { font-weight: 700; }
.invoice-totals { width: 300px; max-width: 100%; margin: 24px 0 0 auto; }
.invoice-totals dt, .invoice-totals dd { padding: 5px 8px; }
.invoice-totals dt { color: #71717a; }
.invoice-total { font-size: 20px; font-weight: 900; color: var(--doc-primary) !important; border-top: 2px solid #18181b; padding-top: 10px !important; margin-top: 6px; }
.invoice-legal { margin-top: 20px !important; font-size: 12px; color: #52525b; }
.invoice-obs { margin-top: 16px !important; font-size: 13px; color: #52525b; }
.invoice-foot { margin-top: 48px; font-size: 12px; color: #71717a; display: flex; flex-direction: column; gap: 2px; }
.invoice-foot strong { color: #27272a; }
@media (max-width: 640px) {
    .invoice { padding: 24px 16px; }
    .invoice-head { flex-direction: column; }
    .invoice-meta { text-align: left; }
    .invoice-parties { grid-template-columns: 1fr; margin-top: 28px; }
    .invoice-lines { font-size: 12px; }
    .invoice-watermark { font-size: 44px; }
}

/* ---------- impuestos ---------- */
.para { margin: 0 0 12px; }
.grid-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .grid-even { grid-template-columns: 1fr; } }
.panel-pad { padding: 16px 20px; margin: 0; }
.panel-flush .panel-head.panel-pad { margin: 0; }
.row-strong td { font-weight: 900; background: var(--surface-2); }
.aviso-discreto { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); margin: -6px 0 20px; }
.aviso-ok .icon { color: var(--good); }
.aviso-warn { color: var(--warn); }
.steps-list { margin: 0 0 16px; padding-left: 20px; }
.steps-list li { margin: 4px 0; }
.choice { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.choice legend { font-weight: 700; display: flex; gap: 6px; align-items: center; }
.hucha-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--chip); margin: 10px 0 14px; }
.hucha-rows { display: flex; flex-direction: column; gap: 8px; }
.hrow { display: flex; gap: 10px; align-items: center; }
.hrow .hname { flex: 1; }
.hrow .hval { font-weight: 700; font-variant-numeric: tabular-nums; }
.hrow.sub { color: var(--muted); font-size: .9rem; padding-left: 20px; }
.hrow.total { border-top: 1px solid var(--border); padding-top: 10px; font-weight: 900; }
.hrow.total .hval { font-size: 1.2rem; font-weight: 900; }
.settings-years { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.alert-ok { background: var(--good-bg); color: var(--good); }
.resultado-70 { margin-top: 12px; }
.grid-1 { display: grid; gap: 20px; }
.hucha-70 { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; color: var(--muted); margin-top: 14px; }
.hucha-70 > .icon { flex: none; margin-top: 3px; }
.alert-soft { background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn-line); margin-bottom: 18px; }
.alert-soft > .icon { color: var(--warn); flex: none; margin-top: 2px; }
.alert-soft a { font-weight: 700; }
.calc-list { display: flex; flex-direction: column; gap: 6px; max-width: 520px; margin-left: auto; }
.calc-list li { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.calc-list li.total { border-top: 1px solid var(--border); padding-top: 8px; font-weight: 900; font-size: 1.05rem; }
.nowrap { white-space: nowrap; }
.nowrap .inline-form { display: inline; margin-left: 8px; }
.hrow .hnote { display: block; color: var(--muted); font-size: .85rem; font-weight: 400; }
.hucha-nota { color: var(--muted); font-size: .82rem; margin-top: 10px; }
/* Calendario de recurrentes */
.cal-head { flex-wrap: wrap; gap: 10px; }
.cal-nav { display: flex; gap: 6px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.cal-dow { font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-day { min-height: 92px; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-empty { background: transparent; border-style: dashed; opacity: .5; }
.cal-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-num { font-size: .8rem; font-weight: 700; color: var(--muted); }
.cal-today .cal-num { color: var(--accent); }
.cal-item { position: relative; display: flex; flex-direction: column; gap: 0; padding: 4px 6px; border-radius: 6px; font-size: .75rem; line-height: 1.25; text-decoration: none; color: var(--text); border-left: 3px solid var(--accent); background: var(--accent-soft); min-width: 0; }
.cal-item .cal-who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.cal-item .cal-amt { font-variant-numeric: tabular-nums; color: var(--muted); }
.cal-item.cal-emitida { border-left-color: var(--good); background: var(--good-bg); }
.cal-item.cal-borrador, .cal-item.cal-variable { border-left-color: var(--warn); background: var(--warn-bg); }
.cal-item.cal-error { border-left-color: var(--bad); background: var(--bad-bg); }
.cal-item:hover::after, .cal-item:focus-visible::after {
    content: attr(data-tip); position: absolute; z-index: 20; left: 0; bottom: calc(100% + 6px); width: max-content; max-width: 260px;
    background: #111827; color: #f9fafb; padding: 7px 10px; border-radius: 8px; font-size: .8rem; font-weight: 400; line-height: 1.35;
    white-space: normal; box-shadow: 0 6px 18px rgba(0,0,0,.25); pointer-events: none;
}
.cal-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.cal-legend span::before { background: var(--accent); }
.cal-legend .l-emitida::before { background: var(--good); }
.cal-legend .l-borrador::before, .cal-legend .l-variable::before { background: var(--warn); }
.cal-legend .l-error::before { background: var(--bad); }
.cal-legend span { margin-right: 12px; }
.choice-row { display: flex; flex-direction: column; gap: 6px; }
.fechas-list { display: flex; flex-wrap: wrap; gap: 6px; }
.fechas-list li { background: var(--chip); padding: 4px 10px; border-radius: 999px; font-size: .85rem; }
.tareas-estado { margin-top: 10px; display: flex; gap: 6px; align-items: center; }
@media (max-width: 760px) {
    .cal { gap: 3px; }
    .cal-day { min-height: 64px; padding: 3px; }
    .cal-item { padding: 2px 4px; font-size: .68rem; }
    .cal-item .cal-amt { display: none; }
    .cal-dow { font-size: .65rem; }
}
.form-grid + .grid-2 { margin-top: 24px; }
.alert + .alert, .alert + .kpis, .alert-soft + .alert { margin-top: 12px; }
.input-wide { min-width: 280px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.kpi-text { font-size: 1rem; padding-top: 6px; }
.sugerencias { display: flex; flex-direction: column; gap: 12px; }
.sugerencias li { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
@media (max-width: 760px) { .sugerencias li { grid-template-columns: 1fr; } }
.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.ir-banco h1 { display: flex; gap: 10px; align-items: center; }
/* Calendario pequeño del inicio */
.small-link { font-size: .85rem; font-weight: 700; }
.mini-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 6px; }
.mc-dow { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.mc-day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; min-height: 40px; padding: 5px 0 4px; border-radius: 8px; font-size: .85rem; font-variant-numeric: tabular-nums; color: var(--text); text-decoration: none; background: var(--surface-2); }
.mc-empty { background: transparent; }
a.mc-day:hover, a.mc-day:focus-visible { background: var(--accent-soft); }
.mc-today { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 900; color: var(--accent); }
.mc-plazo { box-shadow: inset 0 0 0 2px var(--warn); }
.mc-plazo.mc-today { box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 4px var(--warn); }
.mc-dots { display: flex; gap: 2px; height: 6px; }
.mc-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.mc-emitida { background: var(--good); }
.mc-borrador, .mc-variable { background: var(--warn); }
.mc-error { background: var(--bad); }
.mc-sq { display: inline-block; width: 10px; height: 10px; border-radius: 3px; box-shadow: inset 0 0 0 2px var(--warn); }
a.mc-day:hover::after, a.mc-day:focus-visible::after {
    content: attr(data-tip); position: absolute; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(100% + 6px); width: max-content; max-width: 240px;
    background: #111827; color: #f9fafb; padding: 7px 10px; border-radius: 8px; font-size: .78rem; font-weight: 400; line-height: 1.35; white-space: normal;
    box-shadow: 0 6px 18px rgba(0,0,0,.25); pointer-events: none;
}
.mini-cal-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; font-size: .85rem; }
.mc-leyenda { display: inline-flex; gap: 5px; align-items: center; color: var(--muted); font-size: .78rem; }
.mc-leyenda .mc-dot, .mc-leyenda .mc-sq { margin-left: 6px; }
.hucha-fila { margin-top: 20px; }
.hucha-fila .hucha-rows, .hucha-fila .hucha-nota, .hucha-fila .hucha-70 { max-width: 760px; }
