/* =============================================================================
   Estudio Contable — Hoja de estilos
   Mobile first. Tokens en :root con modo oscuro automático.
   Índice: 1. Tokens  2. Base  3. Layout  4. Componentes  5. Tablas responsive
           6. Gráficos  7. Vistas  8. Escritorio (>= 900px)  9. Impresión
   ============================================================================= */

/* 1. TOKENS ----------------------------------------------------------------- */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e5ea;
  --text: #16181d;
  --text-2: #4d5260;
  --text-3: #7a7f8c;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --accent: #2a78d6;
  --accent-soft: #e6f0fc;
  --ok: #17803d;      --ok-soft: #e4f4ea;
  --warn: #a15c00;    --warn-soft: #fdf1dc;
  --danger: #c22f2f;  --danger-soft: #fbe7e7;
  --series-1: #2a78d6;  /* Ventas  (validado: paleta de referencia, slot 1) */
  --series-2: #eb6834;  /* Compras (slot 2) */
  --series-3: #12936c;  /* Tercera serie (verde Okabe-Ito, distinguible del azul y el naranja) */
  /* Polaridad: azul = entradas / resultado positivo; rojo = salidas / resultado negativo. Azul-rojo se distingue
     con daltonismo (ΔE OKLab ≥ 23 en deuter/protan/tritan); el tono suave es la 2.ª serie del mismo lado. */
  --pos: #2a78d6;  --pos-soft: #7fb2ee;
  --neg: #d6453d;  --neg-soft: #f0948a;
  --grid: #eceef2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --tabbar-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121417;
    --surface: #1a1a19;
    --surface-2: #202226;
    --border: #2e3138;
    --text: #f2f3f5;
    --text-2: #b9bdc7;
    --text-3: #8b909c;
    --brand: #8fb8ee;
    --brand-ink: #0d1a2b;
    --accent: #3987e5;
    --accent-soft: #1b2a3f;
    --ok: #4cc27a;      --ok-soft: #15291d;
    --warn: #e0a243;    --warn-soft: #2e2413;
    --danger: #ef6b6b;  --danger-soft: #331a1a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #2fb88e;
    --pos: #3987e5;  --pos-soft: #9cc4f5;
    --neg: #e5534b;  --neg-soft: #f5a59c;
    --grid: #2a2d33;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417; --surface: #1a1a19; --surface-2: #202226; --border: #2e3138;
  --text: #f2f3f5; --text-2: #b9bdc7; --text-3: #8b909c;
  --brand: #8fb8ee; --brand-ink: #0d1a2b; --accent: #3987e5; --accent-soft: #1b2a3f;
  --ok: #4cc27a; --ok-soft: #15291d; --warn: #e0a243; --warn-soft: #2e2413;
  --danger: #ef6b6b; --danger-soft: #331a1a;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #2fb88e; --grid: #2a2d33; --shadow: none;
  --pos: #3987e5; --pos-soft: #9cc4f5; --neg: #e5534b; --neg-soft: #f5a59c;
}

/* 2. BASE ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.35rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 620; }
h3 { font-size: .95rem; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--text-3); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .85em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* 3. LAYOUT ----------------------------------------------------------------- */
.shell { min-height: 100dvh; }
.main { min-width: 0; }
.sidebar { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { flex: 1; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center; background: var(--brand); color: var(--brand-ink);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand small { display: block; font-weight: 500; color: var(--text-3); font-size: .75rem; }

.content {
  padding: 16px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  max-width: 1280px;
  margin: 0 auto;
}

/* Barra de navegación inferior (móvil) */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabbar a, .tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font: inherit; font-size: .7rem; background: none; border: 0; cursor: pointer;
  text-decoration: none; min-width: 0;
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar .active { color: var(--accent); font-weight: 600; }

/* 4. COMPONENTES ------------------------------------------------------------ */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-header p { margin: 4px 0 0; color: var(--text-2); font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; min-width: 0;
}
.card + .card, .section + .section { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head p { margin: 2px 0 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 560; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: .85rem; }
.btn-icon { width: 40px; padding: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* KPIs */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi-label { color: var(--text-2); font-size: .8rem; }
/* En móvil (2 columnas) el importe usa una fuente menor y no se corta a mitad de número. */
.kpi-value { font-size: 1.05rem; font-weight: 680; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-hint { font-size: .78rem; color: var(--text-3); margin-top: 2px; }
.kpi-hint .delta-up, .kpi-hint .delta-down { white-space: nowrap; }
.kpi.tone-danger { border-left: 3px solid var(--danger); }
.kpi.tone-warn { border-left: 3px solid var(--warn); }
.kpi.tone-ok { border-left: 3px solid var(--ok); }
.kpi.tone-pos { border-left: 3px solid var(--pos); }
.kpi.tone-neg { border-left: 3px solid var(--neg); }
.delta-up { color: var(--ok); font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }

/* Badges de estado: siempre texto + color (nunca solo color) */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--accent-soft); color: var(--accent); }

/* Formularios */
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: .82rem; font-weight: 560; color: var(--text-2); }
.field .req { color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.check { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.check input { width: 18px; height: 18px; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 8px 12px; font-size: .88rem; }
.field-hint { font-size: .75rem; color: var(--text-3); }

.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; align-items: end; }
.filters .field:first-child { grid-column: 1 / -1; }

/* Pestañas */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 16px; scrollbar-width: none; }
.tabs button {
  background: none; border: 0; padding: 10px 12px; font: inherit; color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Modal (<dialog>) — en móvil sube como hoja inferior */
dialog.modal {
  border: 0; padding: 0; width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92dvh;
  border-radius: 16px 16px 0 0; background: var(--surface); color: var(--text);
}
dialog.modal::backdrop { background: rgba(10, 14, 22, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-body { padding: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list a, .menu-list button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 4px; color: var(--text);
  font: inherit; background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; text-align: left;
}
.menu-list svg { width: 20px; height: 20px; color: var(--text-3); }

/* Toasts */
.toasts { position: fixed; z-index: 100; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 16px); display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: var(--radius-sm); box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: toast-in .2s ease-out; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* Estados */
.state { text-align: center; padding: 40px 16px; color: var(--text-3); }
.state .btn { margin-top: 12px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; color: var(--text-2); font-size: .85rem; }

/* Listas simples (vencimientos, deudores) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .title { font-weight: 560; overflow-wrap: anywhere; }
.list .sub { color: var(--text-3); font-size: .8rem; }

.dl { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 0; }
.dl dt { font-size: .78rem; color: var(--text-3); }
.dl dd { margin: 2px 0 0; overflow-wrap: anywhere; }

/* 5. TABLAS RESPONSIVE --------------------------------------------------------
   En móvil cada fila se muestra como tarjeta con etiqueta (data-label). */
.table-wrap { width: 100%; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.table thead { display: none; }
table.table tr { display: block; padding: 12px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.table td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; text-align: right; }
table.table td::before { content: attr(data-label); color: var(--text-3); font-size: .8rem; text-align: left; }
table.table td.cell-main { font-weight: 600; text-align: left; justify-content: flex-start; padding-bottom: 6px; }
table.table td.cell-main::before { display: none; }
table.table td[data-label=""]::before { display: none; }
table.table tr.clickable { cursor: pointer; }
table.table tfoot td { font-weight: 650; }

/* 6. GRÁFICOS ---------------------------------------------------------------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:hover, .chart .hit:focus-visible { fill: var(--text); fill-opacity: .05; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--text-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: 8px 10px; font-size: .8rem;
}
.tooltip .tt-title { color: var(--text-3); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }
.tooltip .tt-key { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .tt-key i { width: 12px; height: 2px; border-radius: 2px; display: inline-block; }

/* 7. VISTAS ------------------------------------------------------------------ */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { margin-bottom: 20px; }
.login-card form { display: grid; gap: 14px; }
.demo-box { margin-top: 18px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .82rem; color: var(--text-2); }
.demo-box button { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

.recibo { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface); }
.recibo + .recibo { margin-top: 12px; }
.recibo-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.recibo table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.recibo th, .recibo td { padding: 5px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.recibo th { color: var(--text-3); font-weight: 560; font-size: .75rem; }
.recibo th.num, .recibo td.num { text-align: right; }
.recibo tfoot th { color: var(--text); font-size: .85rem; }
.recibo .neto { display: flex; justify-content: space-between; font-weight: 700; padding-top: 8px; font-size: 1rem; }

/* 8. ESCRITORIO --------------------------------------------------------------- */
@media (min-width: 600px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-value { font-size: 1.3rem; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .full { grid-column: 1 / -1; }
  .filters { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .filters .field:first-child { grid-column: auto; }
  .dl { grid-template-columns: repeat(2, 1fr); }
  dialog.modal { max-width: 640px; margin: auto; border-radius: 16px; }
  .toasts { left: auto; width: 360px; }
}

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .topbar, .tabbar { display: none; }
  .toasts { bottom: 24px; right: 24px; }
  .content { padding: 28px 32px 48px; width: 100%; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
    padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border);
  }
  .sidebar .brand { padding: 0 8px 20px; flex: none; }
  /* El menú se desplaza solo (la marca y el usuario quedan fijos arriba y abajo). */
  .sidebar nav { display: grid; gap: 2px; align-content: start; flex: 1 1 auto; min-height: 0; overflow-y: auto;
    overscroll-behavior: contain; margin: 0 -6px; padding: 0 6px 8px; scrollbar-width: thin;
    scrollbar-color: var(--border) transparent; }
  .sidebar nav::-webkit-scrollbar { width: 8px; }
  .sidebar nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
  .sidebar nav::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
  .sidebar nav a {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 520; text-decoration: none;
  }
  .sidebar nav a svg { width: 18px; height: 18px; }
  .sidebar nav a:hover { background: var(--surface-2); }
  .sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 620; }
  .sidebar .user-box { flex: none; margin-top: 8px; padding: 12px 8px 0; border-top: 1px solid var(--border); font-size: .85rem; }
  .sidebar .user-box .btn { margin-top: 8px; width: 100%; }

  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .dl { grid-template-columns: repeat(3, 1fr); }

  /* Tabla clásica en escritorio */
  table.table thead { display: table-header-group; }
  table.table tr { display: table-row; padding: 0; margin: 0; border: 0; background: none; }
  table.table th, table.table td { display: table-cell; padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
  table.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); font-weight: 600; background: var(--surface-2); }
  table.table td::before { display: none; }
  table.table td.cell-main { font-weight: 560; padding-bottom: 10px; }
  table.table .num, table.table th.num { text-align: right; }
  table.table tbody tr.clickable:hover { background: var(--surface-2); }
  .table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
}

@media (min-width: 1400px) {
  .kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}

/* 9. IMPRESIÓN (recibos) ------------------------------------------------------ */
@media print {
  .sidebar, .topbar, .tabbar, .no-print, .toasts { display: none !important; }
  body { background: #fff; color: #000; }
  .content { padding: 0; }
  .recibo { break-inside: avoid; border-color: #999; }
}

/* 10. SUELDOS ------------------------------------------------------------------ */
.form-section { margin: 8px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: .85rem;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.form-grid > .form-section:first-child, .form-error + .form-section { border-top: 0; padding-top: 0; }
.recibo .cols td.num, .recibo .cols th.num { width: 15%; }
.recibo .letras { font-size: .78rem; color: var(--text-2); font-style: italic; margin-top: 2px; }
.recibo .contrib { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.recibo .contrib h4 { margin: 0 0 6px; font-size: .78rem; text-transform: uppercase; color: var(--text-3); letter-spacing: .03em; }
.recibo .costo { display: flex; justify-content: space-between; font-weight: 650; padding-top: 6px; }
.lista-dinamica { display: grid; gap: 8px; }
.lista-dinamica .fila { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.alerta { border-radius: var(--radius-sm); padding: 10px 12px; font-size: .88rem; margin-bottom: 12px; }
.alerta-warn { background: var(--warn-soft); color: var(--warn); }
.alerta-ok { background: var(--ok-soft); color: var(--ok); }
.alerta-danger { background: var(--danger-soft); color: var(--danger); }
.alerta-danger ul { margin: 6px 0; padding-left: 18px; }
.alerta-danger a { color: inherit; font-weight: 600; }
.alerta ul { margin: 6px 0 0; padding-left: 18px; }
@media print {
  .recibo { page-break-after: always; }
}

/* 11. VISOR DE DOCUMENTOS (vista previa antes de imprimir) ---------------------- */
@media (min-width: 600px) { dialog.modal.modal-wide { max-width: 960px; } }
/* Visor de documentos a pantalla completa: encabezado y pie fijos, el documento ocupa todo el resto. */
dialog.modal.modal-full, dialog.modal.modal-full[open] {
  width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0;
  display: flex; flex-direction: column;
}
dialog.modal.modal-full:not([open]) { display: none; }
.modal-full .modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px; }
.modal-full .visor { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.visor-frame { flex: 1; width: 100%; min-height: 60dvh; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #525659; }
.visor-imagen { display: block; max-width: 100%; max-height: calc(100dvh - 150px); margin: auto; object-fit: contain; border-radius: var(--radius-sm); }
.visor .state { min-height: 200px; }

/* 12. POSICIONES DE IMPUESTOS ---------------------------------------------------- */
.tabla-posicion { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla-posicion td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.tabla-posicion .fila-total td { font-weight: 650; }


/* ---------- Bancos ---------- */
.cuentas-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 8px; }
.cuenta h3 { margin: 0; font-size: 1rem; }
.cuenta p { margin: 4px 0; }
.cuenta.inactiva { opacity: .6; }
.section-title { font-size: 1.05rem; margin: 20px 0 10px; }
.btn-link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.btn-link:hover .badge, .btn-link:focus-visible .badge { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (min-width: 720px) {
  .cuentas-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
.nowrap { white-space: nowrap; }

/* ---------- Menú agrupado ---------- */
.nav-grupo { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
  margin: 14px 12px 4px; font-weight: 600; }
.menu-list .nav-grupo { margin: 12px 4px 4px; list-style: none; }
.nav-pronto { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-3); cursor: not-allowed; }
.nav-pronto small { margin-left: auto; font-size: .68rem; border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; }

/* ---------- Cheques ---------- */
.barra-agenda { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 8px 0 12px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { background: var(--surface); border: 0; padding: 7px 12px; font: inherit; cursor: pointer; color: var(--text); }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.activo { background: var(--accent); color: #fff; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-titulo { min-width: 12ch; text-align: center; }
.resumen-rango { margin: 4px 0 10px; color: var(--text-2, var(--text)); }
.kpi-btn { all: unset; display: block; cursor: pointer; border-radius: var(--radius); }
.kpi-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi-btn:hover .kpi { box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-cab { font-size: .72rem; color: var(--text-3); text-align: center; padding: 2px 0; }
.cal-dia { min-height: 64px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  padding: 4px 6px; text-align: left; font: inherit; display: flex; flex-direction: column; gap: 2px; cursor: pointer; color: var(--text); }
.cal-dia.vacio { border: 0; background: none; cursor: default; }
.cal-dia.hoy { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-dia.con-datos { background: var(--accent-soft); }
.cal-num { font-size: .78rem; color: var(--text-3); }
.cal-total { font-weight: 600; font-size: .85rem; }
.cal-apagar { font-size: .7rem; color: var(--warn); }
.cal-cant { font-size: .7rem; color: var(--ok); }
.dia-cheques { margin-bottom: 14px; }
.dia-cab { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 6px 2px; border-bottom: 2px solid var(--border); margin-bottom: 4px; }
.dia-cab strong { text-transform: capitalize; }
.texto-ok { color: var(--ok); }
.texto-warn { color: var(--warn); }
.texto-neg { color: var(--neg); }
.texto-pos { color: var(--pos); }
.seguimiento { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 10px; }
.seguimiento h3 { margin: 0 0 6px; font-size: 1rem; }
.seguimiento h4 { margin: 10px 0 6px; font-size: .85rem; color: var(--text-3); }
.fila-accion { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.fila-accion .field { min-width: 150px; flex: 1; }
@media (max-width: 719px) {
  .cal-dia { min-height: 48px; padding: 2px 3px; }
  .cal-apagar, .cal-cant { display: none; }
  .cal-total { font-size: .7rem; }
}

.sidebar nav .nav-pronto svg { width: 18px; height: 18px; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---------- Planes de pago ---------- */
.progreso { height: 6px; background: var(--grid); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progreso span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.lista-docs { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }

/* ---------- Marca de agua: logo de C&A Inteligencia Contable (el mismo de los recibos) ----------
   Fija y centrada en el área de trabajo; queda detrás del contenido (las tarjetas la tapan). */
:root { --marca-opacidad: .07; --marca-filtro: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --marca-opacidad: .12; --marca-filtro: brightness(2.2) saturate(.7); }
}
:root[data-theme="dark"] { --marca-opacidad: .12; --marca-filtro: brightness(2.2) saturate(.7); }
.content, .login-wrap { position: relative; isolation: isolate; }
.content::before, .login-wrap::before {
  content: ""; position: fixed; z-index: -1; pointer-events: none;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(520px, 72vw); aspect-ratio: 466 / 454;
  background: url("../img/marca-agua.png") center / contain no-repeat;
  opacity: var(--marca-opacidad); filter: var(--marca-filtro);
}
@media (min-width: 900px) {
  .content::before { left: calc(50% + var(--sidebar-w) / 2); }
}
@media print { .content::before, .login-wrap::before { display: none; } }

/* ---------- Resumen del cliente: compromisos ---------- */
.lista-compromisos { list-style: none; margin: 0; padding: 0; }
.lista-compromisos li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border); }
.lista-compromisos li:last-child { border-bottom: 0; }
.lista-compromisos .fecha { font-variant-numeric: tabular-nums; color: var(--text-3); font-size: .85rem; min-width: 5.5ch; }
.lista-compromisos .importe { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.alerta-compromisos { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }

.login-logo { display: block; margin: 4px auto 8px; width: 160px; height: auto; filter: var(--logo-filtro, none); }
.login-subtitulo { text-align: center; color: var(--text-3); margin: 0 0 18px; font-size: .9rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --logo-filtro: brightness(1.9) saturate(.8); } }
:root[data-theme="dark"] { --logo-filtro: brightness(1.9) saturate(.8); }

/* ---------- Impuestos: comparación con la DJ ---------- */
.comparacion { margin-top: 12px; }
.comparacion h3 { font-size: .95rem; margin: 10px 0 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.form-section { font-size: .95rem; margin: 16px 0 4px; }

/* Resumen del cliente · resultado del período y cruce con bancos */
details.card > summary { cursor: pointer; font-weight: 600; padding: 2px 0; }
details.card[open] > summary { margin-bottom: 12px; }
.card h3 { margin: 0 0 4px; font-size: 1rem; }

/* Resumen del cliente: mes que se está viendo */
.col-destacada { fill: var(--accent-soft); }
.axis-label-destacada { font-weight: 700; fill: var(--text); }
.periodo-vista { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: -4px 0 16px; padding: 12px 16px;
  border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface); }
.periodo-vista .mes { font-size: 1.15rem; font-weight: 700; }
.periodo-vista .actualizacion { color: var(--text-2); font-size: .88rem; }
.filters-resumen { align-items: end; }
.lista-simple { margin: 0; padding-left: 16px; }
.lista-simple li + li { margin-top: 2px; }
.checks { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* Alta asistida */
.pasos { display: flex; flex-wrap: wrap; gap: 8px 24px; list-style: none; padding: 0; margin: 0 0 16px; }
.pasos li { display: flex; align-items: center; gap: 8px; color: var(--text-3); }
.pasos li .num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--border); font-weight: 600; font-size: .85rem; }
.pasos li.actual { color: var(--text); font-weight: 600; }
.pasos li.actual .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.pasos li.hecho .num { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.zona-carga { display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; padding: 28px 16px;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; margin-bottom: 12px; }
.zona-carga:hover, .zona-carga.arrastrando { border-color: var(--accent); background: var(--accent-soft); }
.zona-carga:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.lista-pendientes { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 12px 20px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.lista-pendientes li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.lista-pendientes li .input { width: 100%; }
.lista-pendientes li .muted { flex-basis: 100%; }
.card h4 { margin: 12px 0 6px; font-size: .95rem; }
.primeros-pasos { border-left: 4px solid var(--accent); margin-bottom: 16px; }
.primeros-pasos p { margin: 6px 0 12px; }

/* Pantallas de poca altura (notebooks): menú lateral más compacto. */
@media (min-width: 900px) and (max-height: 820px) {
  .sidebar { padding-top: 14px; padding-bottom: 12px; }
  .sidebar .brand { padding-bottom: 12px; }
  .sidebar nav a { padding: 6px 10px; }
  .sidebar .nav-grupo { margin-top: 10px; }
}

/* Mi seguridad y usuario del menú */
.user-acciones { display: flex; gap: 6px; margin-top: 8px; }
.sidebar .user-box .user-acciones .btn { margin-top: 0; width: auto; flex: 1; justify-content: center; }
.pasos-2fa { padding-left: 20px; display: grid; gap: 14px; }
.qr { background: #fff; padding: 8px; border-radius: var(--radius-sm); margin: 8px 0; }
