/* ==========================================================================
   Sistema visual
   Neutros fríos, un acento verde azulado y colores semánticos con su versión
   suave para fondos (etiquetas, variaciones, avisos). Los colores de los
   gráficos son categóricos validados (daltonismo y contraste) en claro y oscuro.
   ========================================================================== */
:root {
  --fondo: #f3f5f7;
  --superficie: #ffffff;
  --superficie-2: #f8fafb;
  --pista: #eceff2;
  --borde: #e3e7eb;
  --borde-fuerte: #cdd4db;
  --texto: #101828;
  --suave: #5f6b7a;
  --tenue: #8a95a3;
  --acento: #0f766e;
  --acento-hover: #0b5f58;
  --acento-suave: #e3f4f1;
  --acento-texto: #ffffff;
  --anillo: rgb(15 118 110 / 0.22);
  --ingreso: #067647;
  --ingreso-suave: #e3f6ec;
  --gasto: #c4320a;
  --gasto-suave: #fdece5;
  --ambar: #a15c07;
  --ambar-suave: #fdf3dc;
  --morado: #6941c6;
  --morado-suave: #f0ebfd;
  --etiqueta: #eef1f4;
  --aviso-fondo: #101828;

  --lateral: #0d1b1a;
  --lateral-texto: #a9bab7;
  --lateral-activo: rgb(255 255 255 / 0.09);
  --lateral-borde: rgb(255 255 255 / 0.08);
  --lateral-acento: #5ed3c4;

  --serie-ingresos: #2a78d6;
  --serie-gastos: #eb6834;
  --serie-resultado: #52514e;
  --rejilla: #e6e9ed;
  --eje: #c9cfd6;
  --eje-texto: #8a95a3;

  --radio: 12px;
  --radio-s: 8px;
  --sombra-1: 0 1px 2px rgb(16 24 40 / 0.05), 0 1px 3px rgb(16 24 40 / 0.04);
  --sombra-2: 0 12px 32px -6px rgb(16 24 40 / 0.18), 0 4px 8px -4px rgb(16 24 40 / 0.06);
  --alto-control: 2.25rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0e1214;
    --superficie: #161b1e;
    --superficie-2: #1b2125;
    --pista: #222a2e;
    --borde: #283035;
    --borde-fuerte: #36414a;
    --texto: #e9eef1;
    --suave: #9aa7b2;
    --tenue: #75828d;
    --acento: #3cc0b0;
    --acento-hover: #5ed3c4;
    --acento-suave: rgb(60 192 176 / 0.14);
    --acento-texto: #06201d;
    --anillo: rgb(60 192 176 / 0.3);
    --ingreso: #4fd18b;
    --ingreso-suave: rgb(79 209 139 / 0.13);
    --gasto: #f7845e;
    --gasto-suave: rgb(247 132 94 / 0.14);
    --ambar: #f2b84b;
    --ambar-suave: rgb(242 184 75 / 0.14);
    --morado: #b69cf7;
    --morado-suave: rgb(182 156 247 / 0.14);
    --etiqueta: #232b30;
    --aviso-fondo: #e9eef1;
    --lateral: #0a0f11;
    --serie-ingresos: #3987e5;
    --serie-gastos: #d95926;
    --serie-resultado: #c3c2b7;
    --rejilla: #262d32;
    --eje: #36414a;
    --eje-texto: #75828d;
    --sombra-1: 0 1px 2px rgb(0 0 0 / 0.3);
    --sombra-2: 0 16px 40px -8px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
/* El atributo hidden manda aunque una clase ponga display */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 14.5px/1.5 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { margin: 0; color: var(--texto); }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1rem; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 0.85rem; }
h3 { font-size: 0.9rem; font-weight: 650; }
a { color: var(--acento); text-underline-offset: 2px; }
::selection { background: var(--acento-suave); }

/* ---------- controles ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--superficie);
  border: 1px solid var(--borde-fuerte);
  border-radius: var(--radio-s);
  padding: 0.45rem 0.7rem;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:not([type='checkbox']):not([type='radio']):not([type='color']), select { min-height: var(--alto-control); }
input:hover, select:hover, textarea:hover { border-color: var(--tenue); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px var(--anillo); }
button:focus-visible, a:focus-visible, summary:focus-visible, tr:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: var(--tenue); }
input[type='checkbox'], input[type='radio'] { accent-color: var(--acento); width: 1rem; height: 1rem; }
select {
  appearance: none;
  padding-right: 2rem;
  background-image: 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='%238a95a3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  cursor: pointer;
}
textarea { width: 100%; resize: vertical; }
select { max-width: 100%; }
.modelo > *, .formulario > *, .fila > * { min-width: 0; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radio-s);
  padding: 0.45rem 0.95rem;
  min-height: var(--alto-control);
  cursor: pointer;
  background: none;
  font-weight: 500;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
button:disabled { opacity: 0.55; cursor: default; }
.primario { background: var(--acento); color: var(--acento-texto); font-weight: 600; box-shadow: var(--sombra-1); }
.primario:hover:not(:disabled) { background: var(--acento-hover); }
.primario.ingreso { background: var(--ingreso); color: #fff; }
.primario.gasto { background: var(--gasto); color: #fff; }
.primario.ingreso:hover:not(:disabled), .primario.gasto:hover:not(:disabled) { filter: brightness(0.92); }
.secundario { border-color: var(--borde-fuerte); background: var(--superficie); color: var(--texto); box-shadow: var(--sombra-1); }
.secundario:hover:not(:disabled) { background: var(--superficie-2); border-color: var(--tenue); }
.peligro { color: var(--gasto); }
button.peligro:not(.enlace) { border-color: var(--gasto); }
button.peligro:not(.enlace):hover { background: var(--gasto-suave); }
.enlace { padding: 0.2rem 0.45rem; min-height: 0; color: var(--acento); font-weight: 500; }
.enlace:hover:not(:disabled) { background: var(--acento-suave); }
.enlace.peligro { color: var(--gasto); }
.enlace.peligro:hover { background: var(--gasto-suave); }
.ancho { width: 100%; }
.izquierda { margin-right: auto; }
a.boton, summary.boton {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--alto-control);
  text-decoration: none;
  border-radius: var(--radio-s);
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--borde-fuerte);
  background: var(--superficie);
  color: var(--texto);
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--sombra-1);
  transition: background-color 0.15s, border-color 0.15s;
}
a.boton:hover, summary.boton:hover { background: var(--superficie-2); border-color: var(--tenue); }
summary.boton::after { content: ''; width: 0.5rem; height: 0.5rem; border-right: 1.6px solid var(--tenue); border-bottom: 1.6px solid var(--tenue); transform: rotate(45deg) translate(-2px, -2px); margin-left: 0.2rem; }
details[open] > summary.boton { border-color: var(--acento); box-shadow: 0 0 0 3px var(--anillo); }

/* ---------- estructura: menú lateral + contenido ---------- */
.app { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 100vh; }
.lateral {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.1rem 0.85rem;
  background: var(--lateral);
  color: var(--lateral-texto);
  overflow-y: auto;
  z-index: 20;
}
.lateral .marca { display: flex; align-items: center; gap: 0.6rem; padding: 0.15rem 0.45rem; color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.lateral .marca img { border-radius: 7px; }
.selector-negocio { display: grid; gap: 0.3rem; padding: 0 0.35rem; }
.selector-negocio > span { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tenue); }
.selector-negocio select {
  width: 100%;
  background-color: rgb(255 255 255 / 0.06);
  border-color: var(--lateral-borde);
  color: #fff;
  font-weight: 600;
}
.selector-negocio select:hover { border-color: rgb(255 255 255 / 0.2); }
.selector-negocio select option { color: #101828; }
.menu-principal { display: grid; gap: 0.15rem; }
.menu-principal a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radio-s);
  color: var(--lateral-texto);
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}
.menu-principal a:hover { background: rgb(255 255 255 / 0.05); color: #fff; }
.menu-principal a.activo { background: var(--lateral-activo); color: #fff; box-shadow: inset 3px 0 0 var(--lateral-acento); }
.menu-principal a.activo .icono { color: var(--lateral-acento); }
.menu-principal .icono { flex: none; opacity: 0.95; }
.pie-lateral { margin-top: auto; display: grid; gap: 0.75rem; }
.usuario { display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 0.45rem 0; border-top: 1px solid var(--lateral-borde); }
.avatar { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--acento); color: #fff; font-weight: 700; font-size: 0.85rem; }
.usuario-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; }
.lateral .salir { color: var(--lateral-texto); padding: 0.35rem; min-height: 0; }
.lateral .salir:hover { color: #fff; background: rgb(255 255 255 / 0.08); }
.aviso-menu { margin-left: auto; min-width: 1.3rem; padding: 0 0.4rem; border-radius: 999px; background: var(--serie-gastos); color: #fff; font-size: 0.7rem; font-weight: 700; text-align: center; line-height: 1.3rem; }

.principal { min-width: 0; }
.barra-movil { display: none; }
.velo { display: none; }
.pagina-cabecera { max-width: 82rem; margin: 0 auto; padding: 1.9rem 2.25rem 0.25rem; }
.pagina-cabecera p { margin: 0.35rem 0 0; color: var(--suave); }
.contenido { max-width: 82rem; margin: 0 auto; padding: 1.25rem 2.25rem 4rem; }

/* ---------- barras de herramientas ---------- */
.barra { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.botones { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.filtros { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.1rem; }
.barra .filtros { margin-bottom: 0; }
.filtros input[type='search'] {
  flex: 1;
  min-width: 12rem;
  padding-left: 2.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%238a95a3' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.7rem center;
}
.filtros select { max-width: 16rem; }
select.filtro-activo, details.columnas-menu summary.filtro-activo { border-color: var(--acento); background-color: var(--acento-suave); color: var(--acento); box-shadow: none; }

.periodo { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.segmentos { display: inline-flex; gap: 2px; padding: 3px; background: var(--pista); border-radius: 10px; }
.segmentos button, .segmentos a {
  min-height: 1.9rem;
  padding: 0.25rem 0.8rem;
  border: 0;
  border-radius: 7px;
  color: var(--suave);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.segmentos button:hover, .segmentos a:hover { color: var(--texto); }
.segmentos button.activo, .segmentos a.activo { background: var(--superficie); color: var(--texto); font-weight: 600; box-shadow: var(--sombra-1); }
.pestanas { margin-bottom: 1.25rem; }
.navegar { display: inline-flex; align-items: center; gap: 0.35rem; }
.navegar .flecha { width: var(--alto-control); padding: 0; font-size: 1.15rem; line-height: 1; border: 1px solid var(--borde-fuerte); background: var(--superficie); box-shadow: var(--sombra-1); }
.navegar .flecha:hover { border-color: var(--acento); color: var(--acento); }

/* ---------- tarjetas de totales ---------- */
.totales { display: grid; grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.tarjeta {
  position: relative;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1rem 1.15rem 1.05rem;
  box-shadow: var(--sombra-1);
  display: grid;
  gap: 0.2rem;
  align-content: start;
}
.tarjeta::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--borde-fuerte); }
.tarjeta.ingreso::before, .tarjeta.positivo::before { background: var(--ingreso); }
.tarjeta.gasto::before, .tarjeta.negativo::before { background: var(--gasto); }
.tarjeta.neutro::before { background: var(--acento); }
.tarjeta > span { display: block; color: var(--suave); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.tarjeta strong { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; font-variant-numeric: tabular-nums; margin: 0.15rem 0; }
.tarjeta.ingreso strong, .tarjeta.positivo strong { color: var(--ingreso); }
.tarjeta.gasto strong, .tarjeta.negativo strong { color: var(--gasto); }
.tarjeta small { display: block; font-size: 0.78rem; }
.tarjeta small.variacion { justify-self: start; display: inline-flex; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.75rem; }

/* ---------- tablas ---------- */
.tabla-envoltorio { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); overflow-x: auto; box-shadow: var(--sombra-1); }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.tabla th { background: var(--superficie-2); font-size: 0.7rem; color: var(--suave); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tbody tr { transition: background-color 0.12s; }
.tabla.clicable tbody tr { cursor: pointer; }
.tabla.clicable tbody tr:hover, .tabla tbody tr:hover { background: var(--superficie-2); }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla .fecha { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--suave); }
.tabla td.num.sub { color: var(--tenue); font-size: 0.8rem; }
.tabla tfoot td { font-weight: 700; background: var(--superficie-2); border-top: 1px solid var(--borde-fuerte); }
/* Fila para meter un ingreso directamente en la tabla */
.tabla .fila-nueva td { background: var(--acento-suave); padding: 0.5rem 0.55rem; vertical-align: middle; }
.tabla .fila-nueva:hover { background: none; }
.tabla .fila-nueva input, .tabla .fila-nueva select { width: 100%; min-width: 0; min-height: 2rem; padding: 0.3rem 0.5rem; font-size: 0.88rem; }
.tabla .fila-nueva select { padding-right: 1.7rem; background-position: right 0.5rem center; }
.tabla .fila-nueva input[type='date'] { min-width: 8.5rem; }
.tabla .fila-nueva .campos-fila { display: flex; gap: 0.4rem; }
.tabla .fila-nueva .campos-fila input { flex: 1 1 7rem; }
.tabla .fila-nueva .campos-fila.apilados { flex-direction: column; gap: 0.3rem; min-width: 11rem; }
.tabla .fila-nueva .campos-fila.apilados input { flex: none; }
.tabla .fila-nueva td.num input { width: 6rem; flex: 0 0 6rem; text-align: right; }
.tabla .fila-nueva button { min-height: 2rem; padding: 0.3rem 0.75rem; }
.importe.ingreso { color: var(--ingreso); font-weight: 650; }
.importe.gasto { color: var(--gasto); font-weight: 650; }
.concepto { font-weight: 550; }
.sub { color: var(--suave); font-size: 0.82rem; display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
tr.inactivo td { opacity: 0.55; }
select.rapido { min-height: 1.9rem; max-width: 9.5rem; padding: 0.2rem 1.7rem 0.2rem 0.5rem; font-size: 0.85rem; background-position: right 0.5rem center; border-color: transparent; background-color: transparent; }
.tabla tr:hover select.rapido, select.rapido:focus { border-color: var(--borde-fuerte); background-color: var(--superficie); }
.tabla input.check-b { width: 1rem; height: 1rem; cursor: pointer; }

/* etiquetas */
.etiqueta { display: inline-flex; align-items: center; background: var(--etiqueta); border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.72rem; font-weight: 600; color: var(--suave); margin-left: 0.25rem; white-space: nowrap; }
.etiqueta.personal, .etiqueta.proforma { color: var(--morado); background: var(--morado-suave); }
.etiqueta.terceros, .etiqueta.borrador { color: var(--ambar); background: var(--ambar-suave); }
.etiqueta.borrador { margin-left: 0; }
.etiqueta.nodeducible, .etiqueta.gasto { color: var(--gasto); background: var(--gasto-suave); }
.etiqueta.ingreso { color: var(--ingreso); background: var(--ingreso-suave); }
.etiqueta.adjunto { color: var(--acento); background: var(--acento-suave); }
.vacio { padding: 2.5rem 1rem; text-align: center; color: var(--suave); margin: 0; }

/* ---------- paneles ---------- */
.panel { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1.25rem 1.35rem; margin-bottom: 1.25rem; box-shadow: var(--sombra-1); }
.panel > h2:first-child { margin-top: 0; }
.panel.estrecho { max-width: 26rem; }
.acciones { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }
.columnas { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.25rem; }
.columnas .panel { margin-bottom: 0; }
.columnas > * { min-width: 0; }
.barra button, .botones button, .segmentos button, .tabla button, .navegar button { white-space: nowrap; }
.lista-editable { list-style: none; padding: 0; margin: 0 0 0.85rem; display: grid; gap: 0.4rem; }
.lista-editable li { display: flex; gap: 0.35rem; align-items: center; }
.lista-editable li input { flex: 1 1 0; width: 0; }
.lista-editable li button { font-size: 0.85rem; }
.lista-editable li.inactiva input { opacity: 0.55; }
.anadir { display: flex; gap: 0.5rem; }
.anadir input { flex: 1; }

.tarjetas-negocio { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.85rem; }
.tarjetas-negocio button { width: 100%; justify-content: flex-start; text-align: left; padding: 1.1rem; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); font-weight: 600; box-shadow: var(--sombra-1); }
.tarjetas-negocio button:hover { border-color: var(--tenue); }
.tarjetas-negocio button.activo { border-color: var(--acento); box-shadow: 0 0 0 3px var(--anillo); }

/* ---------- facturas ---------- */
.dialogo.ancho { width: min(62rem, calc(100vw - 2rem)); }
.lineas-factura { overflow-x: auto; }
.lineas-factura table { min-width: 40rem; }
.lineas-factura td { padding: 0.3rem 0.25rem; vertical-align: top; }
.lineas-factura input, .lineas-factura select { width: 100%; }
.lineas-factura td:nth-child(2) { width: 5.5rem; }
.lineas-factura td:nth-child(3) { width: 7rem; }
.lineas-factura td:nth-child(4) { width: 4.5rem; }
.lineas-factura td:nth-child(5) { width: 5.5rem; }
.lineas-factura td:nth-child(6) { width: 8rem; }
.lineas-factura td:nth-child(7) { width: 6.5rem; padding-top: 0.75rem; }
.lineas-factura td:nth-child(8) { width: 2rem; }
.concepto-linea textarea { min-height: 2.3rem; field-sizing: content; }
.totales-factura { display: grid; gap: 0.35rem; margin-left: auto; min-width: min(22rem, 100%); font-variant-numeric: tabular-nums; padding: 0.9rem 1rem; background: var(--superficie-2); border: 1px solid var(--borde); border-radius: var(--radio-s); }
.totales-factura div { display: flex; justify-content: space-between; gap: 1rem; color: var(--suave); }
.totales-factura b { color: var(--texto); }
.totales-factura .total { border-top: 1px solid var(--borde-fuerte); padding-top: 0.45rem; font-size: 1.15rem; color: var(--texto); }
.tabla .codigo b { white-space: nowrap; }
.tabla .acciones-fila { width: 1%; white-space: nowrap; text-align: right; }
.lista-aviso { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.3rem; }
.peligro-fondo { background: var(--gasto); color: #fff; }
fieldset.vertical { flex-direction: column; gap: 0.5rem; }
.logo-zona { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.logo-zona img { max-height: 70px; max-width: 220px; border: 1px solid var(--borde); border-radius: var(--radio-s); padding: 4px; background: #fff; }
.formulario h3 { margin: 0.75rem 0 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--suave); }

/* ---------- visión general ---------- */
.vision { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
.vision > * { min-width: 0; }
.vision .totales { margin-bottom: 0; }
.vision .panel { margin-bottom: 0; }
.vision-barra { display: grid; gap: 0.75rem; margin-bottom: 0.75rem; }
.vision-barra .barra { margin-bottom: 0; }
.barra-filtros { margin-bottom: 1.25rem; padding: 0.75rem; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra-1); }
.barra-filtros .filtros { margin-bottom: 0; }
.vistas { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.titulo-periodo { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; }
.titulo-periodo small { font-weight: 500; font-size: 0.85rem; color: var(--suave); }
.variacion { font-variant-numeric: tabular-nums; font-weight: 600; }
.variacion.mejor { color: var(--ingreso); }
.variacion.peor { color: var(--gasto); }
.variacion.igual { color: var(--suave); }
small.variacion.mejor { background: var(--ingreso-suave); }
small.variacion.peor { background: var(--gasto-suave); }
small.variacion.igual { background: var(--etiqueta); }
.vision h3 { margin: 1.25rem 0 0.5rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--suave); }
.titulo-grafico { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.titulo-grafico h2 { margin: 0; }
.leyenda { display: flex; gap: 1rem; font-size: 0.82rem; color: var(--suave); flex-wrap: wrap; }
.leyenda > span { display: inline-flex; align-items: center; gap: 0.35rem; }
.muestra { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 0.35rem; vertical-align: -1px; }
.muestra.ingresos { background: var(--serie-ingresos); }
.muestra.gastos { background: var(--serie-gastos); }
.muestra.resultado { background: none; border-top: 2px solid var(--serie-resultado); border-radius: 0; height: 0; width: 14px; vertical-align: 3px; }
.marco-grafico { position: relative; }
.grafico { width: 100%; height: auto; display: block; }
.grafico .rejilla { stroke: var(--rejilla); stroke-width: 1; }
.grafico .eje-base { stroke: var(--eje); stroke-width: 1; }
.grafico .eje-texto { fill: var(--eje-texto); font-size: 11px; font-variant-numeric: tabular-nums; }
.grafico .marca-ingresos { fill: var(--serie-ingresos); }
.grafico .marca-gastos { fill: var(--serie-gastos); }
.grafico .linea-resultado { fill: none; stroke: var(--serie-resultado); stroke-width: 2; stroke-linejoin: round; }
.grafico .punto-resultado { fill: var(--serie-resultado); stroke: var(--superficie); stroke-width: 2; }
.grafico .zona-hover { fill: transparent; outline: none; }
.grafico .zona-hover.activa { fill: var(--texto); fill-opacity: 0.05; }
.tooltip-grafico { position: absolute; top: 0.25rem; transform: translateX(-50%); background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio-s); padding: 0.5rem 0.7rem; font-size: 0.85rem; box-shadow: var(--sombra-2); pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabla-datos { margin-top: 0.75rem; }
.tabla-datos summary { cursor: pointer; color: var(--acento); font-size: 0.85rem; font-weight: 500; }
.tabla-datos .tabla-envoltorio { margin-top: 0.6rem; box-shadow: none; }
.barras-h { display: grid; gap: 0.55rem; }
.fila-barra { display: grid; grid-template-columns: minmax(6rem, 36%) 1fr auto; gap: 0.7rem; align-items: center; font-size: 0.86rem; }
.nombre-barra { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pista-barra { height: 10px; background: var(--pista); border-radius: 999px; overflow: hidden; }
.barra-h { display: block; height: 100%; border-radius: 999px; }
.barra-h.ingresos { background: var(--serie-ingresos); }
.barra-h.gastos { background: var(--serie-gastos); }
.valor-barra { font-variant-numeric: tabular-nums; font-weight: 600; }

/* menús desplegables con casillas (columnas y filtros) */
details.columnas-menu { position: relative; display: inline-block; }
details.columnas-menu summary { list-style: none; cursor: pointer; }
details.columnas-menu summary::-webkit-details-marker { display: none; }
.columnas-lista {
  position: absolute;
  right: 0;
  z-index: 30;
  margin-top: 0.4rem;
  padding: 0.4rem;
  display: grid;
  gap: 1px;
  min-width: 13rem;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 10px;
  box-shadow: var(--sombra-2);
  white-space: nowrap;
  max-height: 60vh;
  overflow-y: auto;
}
.columnas-lista label { display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.55rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; }
.columnas-lista label:hover { background: var(--superficie-2); }
.columnas-lista input[type='search'] { margin-bottom: 0.3rem; }
.filtro-menu .columnas-lista { right: auto; left: 0; min-width: 15rem; }
.filtro-menu .columnas-lista input[type='search'] { width: 100%; }
.filtro-menu summary { max-width: 18rem; }

/* ---------- recurrentes ---------- */
.recurrentes { display: grid; gap: 1.25rem; }
.sugerencias { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.sugerencias li { display: grid; grid-template-columns: 1fr auto auto; gap: 0.75rem; align-items: center; padding: 0.6rem 0; border-top: 1px solid var(--borde); }
.sugerencias li:first-child { border-top: 0; }
.sugerencias .num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- smartscan ---------- */
.duplicados ul { list-style: none; padding: 0; margin: 0.25rem 0; display: grid; gap: 0.4rem; }
.duplicados li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.soltar {
  border: 2px dashed var(--borde-fuerte);
  border-radius: var(--radio);
  padding: 2.5rem 1rem;
  display: grid;
  gap: 0.35rem;
  place-items: center;
  text-align: center;
  cursor: pointer;
  background: var(--superficie);
  margin-bottom: 1.25rem;
  transition: border-color 0.15s, background-color 0.15s;
}
.soltar::before {
  content: '';
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 0.35rem;
  border-radius: 50%;
  background: var(--acento-suave) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%230f766e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4M7 9l5-5 5 5M4 16v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3'/%3E%3C/svg%3E") no-repeat center;
}
.soltar:hover, .soltar.encima { border-color: var(--acento); background: var(--acento-suave); }
.escaneos { display: grid; gap: 1.25rem; }
.acciones-bloque { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.escaneo { display: grid; gap: 0.85rem; margin: 0; }
.escaneo-cabecera { display: flex; gap: 0.85rem; align-items: center; }
.miniatura { flex: none; width: 64px; height: 64px; border: 1px solid var(--borde); border-radius: var(--radio-s); overflow: hidden; display: grid; place-items: center; background: #fff; text-decoration: none; }
.miniatura img { width: 100%; height: 100%; object-fit: cover; }
.icono-pdf { font-weight: 700; color: var(--gasto); }
.estado-leido { color: var(--ambar); }
.estado-creado { color: var(--ingreso); }
.estado-error { color: var(--gasto); }
.lineas-escaneo { display: grid; gap: 0.4rem; justify-items: start; }
.lineas-escaneo .fila { width: 100%; align-items: end; }
.quitar-linea { justify-self: start; align-self: center; }

/* ---------- informes ---------- */
.informe { display: grid; gap: 1rem; }
.informe h2 { margin: 1rem 0 0; }
.informe .columnas { grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); }
.informe .columnas section { display: grid; gap: 0.6rem; align-content: start; }

/* ---------- impuestos ---------- */
.presentado { border: 1px solid var(--ingreso); background: var(--ingreso-suave); border-radius: var(--radio-s); padding: 0.6rem 0.8rem; display: grid; gap: 0.2rem; }
.presentado > b { color: var(--ingreso); }
.botones-presentado { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.intro { color: var(--suave); margin: 0 0 1.25rem; max-width: 62rem; }
.modelos { align-items: start; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
.modelo { display: grid; gap: 0.85rem; }
.titulo-modelo { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--borde); }
.titulo-modelo h2 { margin: 0; }
.titulo-modelo strong { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.a-pagar { color: var(--gasto); }
.a-favor { color: var(--ingreso); }
.casillas td { padding: 0.4rem 0.5rem; }
.casillas .casilla-n { color: var(--tenue); font-variant-numeric: tabular-nums; width: 3.5rem; font-size: 0.82rem; }
.casillas tr.total td { font-weight: 600; }
.casillas tr.resultado td { font-weight: 700; border-top: 1px solid var(--borde-fuerte); background: var(--superficie-2); }
.aviso-linea { margin: 0; font-size: 0.85rem; color: var(--ambar); }
.aviso-linea.error { color: var(--gasto); }

/* ---------- formularios ---------- */
.fiscal-contacto { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; font-size: 0.8rem; color: var(--suave); margin-top: 0.3rem; align-items: center; }
.fiscal-contacto em { color: var(--ambar); font-style: normal; }
.formulario { display: grid; gap: 0.9rem; }
.fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.85rem; }
.campo { display: grid; gap: 0.3rem; align-content: start; }
.campo > span { font-size: 0.82rem; font-weight: 600; color: var(--texto); }
.campo small, .casilla small, .nota { color: var(--suave); font-size: 0.8rem; }
.campo input, .campo select { width: 100%; }
.campo input[type='color'] { width: 4.5rem; height: 2.4rem; padding: 0.2rem; cursor: pointer; }
.importe-input { font-size: 1.2rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.casilla { display: flex; gap: 0.65rem; align-items: flex-start; padding: 0.6rem 0.75rem; border: 1px solid var(--borde); border-radius: var(--radio-s); background: var(--superficie-2); cursor: pointer; }
.casilla:hover { border-color: var(--borde-fuerte); }
.casilla:has(input:checked) { border-color: var(--acento); background: var(--acento-suave); }
.casilla input { margin-top: 0.2rem; flex: none; }
.casilla span { display: grid; gap: 0.1rem; }
.lista-editable .casilla-b, .columnas-lista .casilla-b { display: flex; align-items: center; gap: 0.45rem; flex: 0 0 auto; font-size: 0.88rem; }
fieldset { border: 1px solid var(--borde); border-radius: var(--radio-s); padding: 0.6rem 0.85rem; margin: 0; display: flex; gap: 1.25rem; flex-wrap: wrap; }
fieldset label { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; }
fieldset legend { font-size: 0.82rem; font-weight: 600; padding: 0 0.3rem; }
.desglose { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.88rem; color: var(--suave); font-variant-numeric: tabular-nums; min-height: 1.3em; padding: 0.6rem 0.75rem; background: var(--superficie-2); border-radius: var(--radio-s); }
.desglose:empty { display: none; }
.desglose b { color: var(--texto); }
.zona-adjuntos { border-top: 1px solid var(--borde); padding-top: 0.85rem; }
.titulo-adjuntos { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.adjuntos { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 0.25rem; }
.adjuntos li { display: flex; align-items: center; gap: 0.25rem; }
.adjuntos li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.adjuntos .pendiente { color: var(--suave); }

/* ---------- diálogo ---------- */
.dialogo { border: 1px solid var(--borde); border-radius: 16px; padding: 0; width: min(40rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); background: var(--superficie); color: var(--texto); box-shadow: var(--sombra-2); }
.dialogo[open] { animation: aparecer 0.18s ease-out; }
@keyframes aparecer { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dialogo::backdrop { background: rgb(16 24 40 / 0.45); backdrop-filter: blur(2px); }
.dialogo form { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.dialogo header { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--borde); }
.dialogo header h2 { margin: 0; font-size: 1.1rem; }
.dialogo .x { font-size: 1.4rem; line-height: 1; padding: 0.2rem 0.5rem; min-height: 0; color: var(--suave); }
.dialogo .x:hover { background: var(--etiqueta); color: var(--texto); }
.dialogo .cuerpo { padding: 1.2rem 1.4rem 1.3rem; overflow-y: auto; }
.dialogo footer { display: flex; gap: 0.5rem; justify-content: flex-end; padding: 0.85rem 1.4rem; border-top: 1px solid var(--borde); background: var(--superficie-2); border-radius: 0 0 16px 16px; }

/* ---------- acceso ---------- */
.acceso { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(60rem 40rem at 20% -10%, var(--acento-suave), transparent 60%), var(--fondo); }
.acceso .panel { width: 100%; display: grid; gap: 1rem; padding: 2rem; box-shadow: var(--sombra-2); }
.acceso h1 { display: flex; align-items: center; gap: 0.6rem; }
.acceso h1::before { content: ''; width: 2.25rem; height: 2.25rem; background: url('/icono.svg') no-repeat center / contain; }
.error { color: var(--gasto); margin: 0; min-height: 1.2em; }

/* ---------- avisos flotantes ---------- */
.aviso {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  background: var(--aviso-fondo);
  color: var(--fondo);
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  font-weight: 500;
  box-shadow: var(--sombra-2);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  max-width: calc(100vw - 2rem);
  z-index: 50;
}
.aviso.visible { opacity: 1; transform: translate(-50%, 0); }
.aviso.error { background: var(--gasto); color: #fff; }

/* ---------- email del negocio: la firma se pega desde Gmail con su formato ---------- */
.firma-editable { min-height: 5rem; padding: 0.6rem 0.75rem; border: 1px solid var(--borde-fuerte); border-radius: var(--radio-s); background: var(--superficie); color: var(--texto); font-size: 0.9rem; overflow-wrap: anywhere; }
.firma-editable:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px var(--anillo); }
.firma-editable img { max-width: 100%; height: auto; }
details.ayuda { margin: 0 0 0.85rem; }
details.ayuda summary { cursor: pointer; color: var(--acento); font-weight: 500; }
details.ayuda ol { margin: 0.5rem 0 0; padding-left: 1.25rem; line-height: 1.6; }
.envios { margin-top: 0.85rem; }
.envios .aviso-linea { margin: 0.25rem 0; }

/* ---------- pantallas medianas: el menú lateral pasa a ser un cajón ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .lateral { position: fixed; inset: 0 auto 0 0; width: 16.5rem; transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--sombra-2); }
  .app.menu-abierto .lateral { transform: none; }
  .app.menu-abierto .velo { display: block; position: fixed; inset: 0; background: rgb(16 24 40 / 0.45); z-index: 15; }
  .barra-movil {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0.55rem 1rem;
    background: var(--superficie);
    border-bottom: 1px solid var(--borde);
  }
  .barra-movil img { border-radius: 6px; }
  .boton-menu { padding: 0.35rem; min-height: 0; margin-left: -0.35rem; }
  .boton-menu:hover { background: var(--etiqueta); }
  .pagina-cabecera { padding: 1.4rem 1.25rem 0; }
  .contenido { padding: 1rem 1.25rem 3rem; }
}

@media (max-width: 720px) {
  .ocultable { display: none; }
  h1 { font-size: 1.35rem; }
  .pagina-cabecera { padding: 1.1rem 0.9rem 0; }
  .pagina-cabecera p { font-size: 0.88rem; }
  .contenido { padding: 0.9rem 0.9rem 3rem; }
  .barra { align-items: stretch; }
  .botones { width: 100%; }
  .botones button, .botones a.boton { flex: 1; justify-content: center; }
  .totales { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .tarjeta { padding: 0.8rem 0.9rem; }
  .tarjeta strong { font-size: 1.2rem; }
  .tarjeta > span { font-size: 0.68rem; letter-spacing: 0.03em; }
  .tarjeta small, .tarjeta small.variacion { font-size: 0.72rem; }
  .navegar { flex: 1; }
  .navegar select { flex: 1; }
  .vistas select { flex: 1; }
  .filtros select { flex: 1 1 45%; max-width: none; }
  .segmentos { max-width: 100%; overflow-x: auto; }
  .panel { padding: 1rem; }
  .columnas-lista { position: fixed; left: 0.75rem !important; right: 0.75rem !important; top: auto; bottom: 0.75rem; max-height: 70vh; }
}

/* Botones de cada modelo: ocupan el ancho de la tarjeta y bajan de línea si no caben */
.acciones-modelo { flex-wrap: wrap; justify-content: stretch; margin-top: 0.25rem; }
.acciones-modelo > * { flex: 1 1 12rem; justify-content: center; text-align: center; white-space: normal; }
.modelo > .secundario { width: 100%; }
a.boton.primario { background: var(--acento); color: var(--acento-texto); border-color: transparent; font-weight: 600; }
a.boton.primario:hover { background: var(--acento-hover); }
.pestanas-impuestos { margin-bottom: 1.1rem; }
.modelo h3 { margin: 0.25rem 0 -0.35rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--suave); }
.modelo .tabla-envoltorio { box-shadow: none; }
.modelo .tabla th, .modelo .tabla td { padding: 0.45rem 0.5rem; }
.modelo .tabla th { white-space: normal; }

/* Avisos de plazos (Visión general e Impuestos) */
.avisos-plazos { display: flex; gap: 0.5rem 1rem; align-items: baseline; flex-wrap: wrap; padding: 0.75rem 1rem; margin-bottom: 1.1rem; border: 1px solid var(--ambar); background: var(--ambar-suave); border-radius: var(--radio); }
.avisos-plazos > b { color: var(--ambar); }
.avisos-plazos ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.35rem 1.25rem; flex-wrap: wrap; }
.avisos-plazos li { display: inline-flex; gap: 0.35rem; align-items: baseline; flex-wrap: wrap; }
.avisos-plazos li a { font-weight: 600; }
.avisos-plazos li.urgente a, .avisos-plazos li.urgente .sub { color: var(--gasto); }
