/* =====================================================================
   StoreCobros · Sistema visual (inspirado en Adobe Design, sin copiarlo)
   Mobile-first. Base 360 px → 600 px (tableta) → 1024 px (escritorio).
   Colores de marca: violeta (primario), turquesa (positivo), naranja (aviso), rojo (alerta).
   ===================================================================== */

@font-face { font-family: "Source Sans 3"; font-weight: 400; font-display: swap; src: url("../fonts/source-sans-3-latin-400.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 600; font-display: swap; src: url("../fonts/source-sans-3-latin-600.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 700; font-display: swap; src: url("../fonts/source-sans-3-latin-700.woff2") format("woff2"); }

:root {
    /* Marca (extraída del logo) */
    --violeta: #3900a1;
    --turquesa: #178d9a;
    --naranja: #fd8b00;
    --rojo: #f6001c;

    /* Superficies y texto (neutros con un leve matiz violeta) */
    --bg: #ffffff;
    --bg-subtle: #f7f6fb;
    --border: #e4e1ec;
    --border-strong: #8e879f;     /* bordes de controles: 3,4:1 (UI) */
    --border-soft: #c9c4d6;
    --text: #1e1b2e;              /* 16,8:1 */
    --text-muted: #625d73;        /* 6,3:1 */

    /* Roles */
    --primary: var(--violeta);    /* botones, foco, navegación activa (blanco encima: 12,4:1) */
    --primary-hover: #2b007a;
    --primary-soft: #efe9fa;
    --focus: var(--violeta);
    --ok: #0b6c77;                /* turquesa oscurecido para texto: 5,4:1 sobre --ok-soft */
    --ok-soft: #e2f3f5;
    --warn: #9a4f00;              /* naranja oscurecido para texto: 5,4:1 sobre --warn-soft */
    --warn-soft: #fff1de;
    --danger: #c40016;            /* rojo oscurecido para texto: 6,3:1 sobre blanco */
    --danger-soft: #ffe9ec;
    --neutral: #4a4560;
    --neutral-soft: #f0eef5;

    --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --fs-xs: 0.8125rem;  /* 13 */
    --fs-sm: 0.875rem;   /* 14 */
    --fs-md: 1rem;       /* 16 */
    --fs-lg: 1.125rem;   /* 18 */
    --fs-xl: 1.375rem;   /* 22 */
    --fs-2xl: 1.75rem;   /* 28 */
    --fs-3xl: 2.5rem;    /* 40 */

    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
    --radius: 4px;
    --radius-lg: 6px;
    --control-h: 48px;
    --shadow-overlay: 0 12px 32px rgba(30, 27, 46, 0.18);
    --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-md);
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 var(--s3); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); font-weight: 600; }
p { margin: 0 0 var(--s4); }
a { color: var(--text); text-underline-offset: 2px; }
a:hover { color: var(--primary); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.cifra { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icono { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icono-lg { width: 24px; height: 24px; }

/* ----------------------------- Layout app ----------------------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: var(--nav-h); }
.barra-superior {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: var(--s3);
    min-height: 56px; padding: 0 var(--s4);
    background: var(--bg); border-bottom: 1px solid var(--border);
}
.marca { display: flex; align-items: center; gap: var(--s2); font-weight: 700; text-decoration: none; min-width: 0; }
.marca-logo { width: 22px; height: 34px; flex: none; }
.marca-nombre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-superior .espaciador { flex: 1; }
.usuario-nombre { display: none; font-size: var(--fs-sm); color: var(--text-muted); }
@media (min-width: 600px) { .usuario-nombre { display: inline; } }
.sin-margen { margin: 0; }
.principal { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s8); }
.encabezado-pagina { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s5); }
.encabezado-pagina h1 { margin: 0; }
.encabezado-pagina .subtitulo { color: var(--text-muted); margin: var(--s1) 0 0; }

.nav-inferior {
    position: fixed; inset: auto 0 0 0; z-index: 30;
    display: flex; height: var(--nav-h);
    background: var(--bg); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-inferior a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: var(--fs-xs); color: var(--text-muted); text-decoration: none; min-width: 0;
    border-top: 2px solid transparent;
}
.nav-inferior a[aria-current="page"] { color: var(--primary); border-top-color: var(--primary); font-weight: 600; }
.nav-lateral { display: none; }

@media (min-width: 1024px) {
    .app { padding-bottom: 0; display: grid; grid-template-columns: 232px 1fr; grid-template-rows: auto 1fr; }
    .barra-superior { grid-column: 1 / -1; }
    .nav-inferior { display: none; }
    .nav-lateral {
        display: block; border-right: 1px solid var(--border); background: var(--bg-subtle);
        padding: var(--s4) var(--s3); position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
    }
    .nav-lateral a {
        display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); min-height: 40px;
        text-decoration: none; color: var(--text); border-radius: var(--radius); border-left: 2px solid transparent;
    }
    .nav-lateral a:hover { background: var(--neutral-soft); color: var(--text); }
    .nav-lateral a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
    .nav-lateral .grupo { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin: var(--s5) var(--s3) var(--s2); }
    .principal { padding: var(--s8) var(--s8) var(--s10); }
}

/* ---------------------------- Layout simple ---------------------------- */
.simple { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-subtle); }
.simple-caja {
    width: 100%; max-width: 420px; margin: 0 auto; padding: var(--s8) var(--s4);
}
.simple-panel { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s6) var(--s5); }
.simple .marca { margin-bottom: var(--s6); font-size: var(--fs-lg); }
@media (min-width: 600px) { .simple-caja { padding-top: 12vh; } .simple-panel { padding: var(--s8); } }

/* ------------------------------ Botones ------------------------------- */
.boton {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
    min-height: var(--control-h); padding: 0 var(--s5);
    font: inherit; font-weight: 600; line-height: 1; text-decoration: none; cursor: pointer;
    border: 1px solid transparent; border-radius: var(--radius);
    background: var(--primary); color: #fff;
    -webkit-tap-highlight-color: transparent;
}
.boton:hover { background: var(--primary-hover); color: #fff; }
.boton-secundario { background: var(--bg); color: var(--primary); border-color: var(--border-soft); }
.boton-secundario:hover { background: var(--neutral-soft); color: var(--text); }
.boton-texto { background: transparent; color: var(--text); padding: 0 var(--s2); min-height: 40px; }
.boton-texto:hover { background: var(--neutral-soft); color: var(--text); }
.boton-peligro { background: var(--bg); color: var(--danger); border-color: var(--danger); }
.boton-peligro:hover { background: var(--danger-soft); color: var(--danger); }
.boton-compacto { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-sm); }
.boton-bloque { width: 100%; }
.boton[disabled], .boton[aria-busy="true"] { opacity: 0.6; cursor: progress; }

/* ---------------------------- Formularios ----------------------------- */
.campo { margin-bottom: var(--s4); }
.campo > label, .etiqueta { display: block; font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--s1); }
.campo .ayuda { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--s1); }
.campo .error-campo { font-size: var(--fs-sm); color: var(--danger); margin-top: var(--s1); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="search"],
input[type="number"], input[type="date"], select, textarea {
    width: 100%; min-height: var(--control-h); padding: var(--s2) var(--s3);
    font: inherit; font-size: var(--fs-md); color: var(--text);
    background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
[aria-invalid="true"] { border-color: var(--danger); }
.form-acciones { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s5); }
.form-rejilla { display: grid; gap: 0 var(--s4); }
.form-angosto { max-width: 640px; }
.campo-clave { position: relative; }
.campo-clave input { padding-right: 88px; }
.campo-clave .boton { position: absolute; top: 6px; right: 6px; min-height: 36px; }
@media (min-width: 600px) { .form-rejilla.dos { grid-template-columns: 1fr 1fr; } }
fieldset { border: 0; padding: 0; margin: 0 0 var(--s5); }
legend { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--s3); padding: 0; }

/* --------------------------- Mensajes / avisos ------------------------- */
.aviso {
    display: flex; gap: var(--s3); align-items: flex-start;
    padding: var(--s3) var(--s4); margin-bottom: var(--s5);
    border-left: 3px solid var(--neutral); background: var(--neutral-soft); border-radius: var(--radius);
}
.aviso p { margin: 0; }
.aviso ul { margin: 0; padding-left: var(--s5); }
.aviso-exito { border-left-color: var(--ok); background: var(--ok-soft); }
.aviso-error { border-left-color: var(--danger); background: var(--danger-soft); }
.aviso-aviso { border-left-color: var(--warn); background: var(--warn-soft); }

/* ------------------------------ Etiquetas ------------------------------ */
.etiqueta-estado {
    display: inline-flex; align-items: center; gap: var(--s1);
    padding: 2px var(--s2); font-size: var(--fs-xs); font-weight: 600; line-height: 1.4;
    border-radius: var(--radius); background: var(--neutral-soft); color: var(--neutral); white-space: nowrap;
}
.etiqueta-estado .icono { width: 14px; height: 14px; }
.etiqueta-estado.ok { background: var(--ok-soft); color: var(--ok); }
.etiqueta-estado.alerta { background: var(--danger-soft); color: var(--danger); }
.etiqueta-estado.parcial { background: var(--warn-soft); color: var(--warn); }

/* ------------------------------- Tablas -------------------------------- */
.tabla { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tabla th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border-soft); }
.tabla td { padding: var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
/* En pantallas pequeñas cada fila se convierte en un bloque apilado (etiqueta: valor). */
@media (max-width: 599px) {
    .tabla-adaptable thead { display: none; }
    .tabla-adaptable, .tabla-adaptable tbody, .tabla-adaptable tr, .tabla-adaptable td { display: block; width: 100%; }
    .tabla-adaptable tr { padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
    .tabla-adaptable td { border: 0; padding: var(--s1) 0; display: flex; justify-content: space-between; gap: var(--s4); }
    .tabla-adaptable td::before { content: attr(data-etiqueta); color: var(--text-muted); font-size: var(--fs-xs); flex: none; }
    .tabla-adaptable td.principal-celda { font-weight: 600; font-size: var(--fs-md); }
    .tabla-adaptable td.principal-celda::before { content: none; }
}

/* ------------------------------ Secciones ------------------------------ */
.seccion { margin-bottom: var(--s8); }
.seccion-titulo { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding-bottom: var(--s2); margin-bottom: var(--s4); border-bottom: 1px solid var(--border); }
.seccion-titulo h2 { margin: 0; font-size: var(--fs-lg); }
.lista-acciones { display: flex; flex-wrap: wrap; gap: var(--s2); }
.lista-acciones form { margin: 0; }
.vacio { padding: var(--s8) var(--s4); text-align: center; color: var(--text-muted); border: 1px dashed var(--border-soft); border-radius: var(--radius); }

/* ------------------------- Indicadores (dashboard) ------------------------- */
.indicadores { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border); border-left: 1px solid var(--border); margin-bottom: var(--s8); }
.indicador { padding: var(--s4); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; }
.indicador-etiqueta { font-size: var(--fs-sm); color: var(--text-muted); }
.indicador-valor { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (min-width: 1024px) { .indicadores { grid-template-columns: repeat(4, 1fr); } .indicador-valor { font-size: var(--fs-2xl); } }

.pie-simple { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--s5); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .nav-inferior, .nav-lateral, .barra-superior { display: none !important; } .app { display: block; padding: 0; } }

/* =====================================================================
   Fase 3 · Componentes de cartera
   ===================================================================== */

/* Indicadores como enlaces */
a.indicador { display: block; text-decoration: none; color: var(--text); }
a.indicador:hover { background: var(--bg-subtle); color: var(--text); }
.indicador-etiqueta, .indicador-valor, .indicador-detalle { display: block; }
.indicador-detalle { font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.indicador-alerta .indicador-valor { color: var(--danger); }
.indicador-alerta { box-shadow: inset 0 3px 0 var(--danger); }

.acciones-rapidas { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin: calc(-1 * var(--s4)) 0 var(--s8); }
.acciones-rapidas .boton:first-child { grid-column: 1 / -1; }
@media (min-width: 600px) { .acciones-rapidas { display: flex; flex-wrap: wrap; } }
.rejilla-dashboard { display: grid; gap: 0 var(--s8); }
@media (min-width: 1024px) { .rejilla-dashboard { grid-template-columns: 1fr 1fr; } .rejilla-dashboard .seccion:first-child { grid-column: 1 / -1; } }

/* Lista de filas (clientes, abonos, deudas) */
.lista-filas { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.lista-filas > li { border-bottom: 1px solid var(--border); }
.fila {
    display: flex; align-items: center; gap: var(--s3); min-height: 60px; padding: var(--s3) var(--s1);
    text-decoration: none; color: var(--text);
}
.fila:hover { background: var(--bg-subtle); color: var(--text); }
.fila-principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fila-titulo { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: var(--s2); }
.fila-sub { font-size: var(--fs-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-fin { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.fila-monto { font-weight: 700; }
.fila-anulada .fila-titulo, .fila-anulada .fila-monto, tr.fila-anulada td { text-decoration: line-through; color: var(--text-muted); }

/* Buscador */
.buscador { position: relative; margin-bottom: var(--s3); }
.buscador input { padding-left: 44px; min-height: 52px; font-size: var(--fs-lg); background: var(--bg-subtle); }
.buscador input:focus { background: var(--bg); }
.buscador-icono { position: absolute; left: 14px; top: 16px; color: var(--text-muted); pointer-events: none; }
.resultados-vivos { margin-bottom: var(--s4); }
.resultados-vivos[hidden] { display: none; }
@media (max-width: 1023px) { .buscador { position: sticky; top: 56px; z-index: 10; background: var(--bg); padding: var(--s2) 0; margin-top: calc(-1 * var(--s2)); } .buscador-icono { top: 24px; } }

/* Pestañas de filtro */
.pestanas { display: flex; gap: var(--s1); overflow-x: auto; margin-bottom: var(--s4); border-bottom: 1px solid var(--border); scrollbar-width: none; }
.pestanas a { padding: var(--s2) var(--s3); white-space: nowrap; text-decoration: none; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 44px; display: flex; align-items: center; }
.pestanas a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

/* Ficha de cliente / deuda / abono */
.ficha-cabecera { margin-bottom: var(--s6); }
.volver { display: inline-flex; align-items: center; gap: var(--s1); font-size: var(--fs-sm); color: var(--text-muted); text-decoration: none; min-height: 40px; }
.ficha-cabecera h1 { margin: var(--s1) 0 var(--s1); overflow-wrap: anywhere; }
.ficha-contacto { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); margin-bottom: var(--s4); }
.saldo-bloque { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s4) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: var(--s4); }
.saldo-etiqueta { font-size: var(--fs-sm); color: var(--text-muted); }
.saldo-valor { font-size: var(--fs-3xl); font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.saldo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--fs-sm); }
.saldo-compacto { padding: var(--s3) 0; }
.saldo-compacto .saldo-valor { font-size: var(--fs-2xl); }
.ficha-acciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s2); }
@media (min-width: 600px) { .ficha-acciones { display: flex; flex-wrap: wrap; } }

.resultado-abono { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s4); margin: var(--s3) 0 var(--s4); background: var(--ok-soft); border-left: 3px solid var(--ok); border-radius: var(--radius); }
.resultado-abono.anulado { background: var(--neutral-soft); border-left-color: var(--neutral); }
.resultado-abono.anulado .resultado-monto { text-decoration: line-through; }
.resultado-monto { font-size: var(--fs-2xl); font-weight: 700; }

/* Datos (dl) */
.datos { display: grid; grid-template-columns: 1fr; gap: var(--s3) var(--s6); margin: 0 0 var(--s4); }
@media (min-width: 600px) { .datos { grid-template-columns: 1fr 1fr; } .datos-ancho { grid-column: 1 / -1; } }
.datos dt { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.datos dd { margin: 0; overflow-wrap: anywhere; }

/* Historial */
.historial { list-style: none; margin: 0; padding: 0; }
.historial-item { display: flex; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.historial-icono { width: 32px; height: 32px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--neutral-soft); color: var(--neutral); }
.historial-abono .historial-icono { background: var(--ok-soft); color: var(--ok); }
.historial-deuda_anulada .historial-icono, .historial-abono_anulado .historial-icono { background: var(--danger-soft); color: var(--danger); }
.historial-cuerpo { flex: 1; min-width: 0; text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.historial-cuerpo:hover { color: var(--text); }
.historial-linea { display: flex; justify-content: space-between; gap: var(--s3); }
.historial-linea > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.historial-monto { font-weight: 600; white-space: nowrap; }
.historial-abono .historial-monto { color: var(--ok); }
.historial-meta { font-size: var(--fs-sm); color: var(--text-muted); }
.historial-item.anulado .historial-monto, .historial-item.anulado strong { text-decoration: line-through; color: var(--text-muted); }

/* Formularios de operación */
.casilla { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s2) 0; min-height: 44px; cursor: pointer; }
.casilla input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }
.consentimiento { margin-bottom: var(--s4); }
.mas-datos, .panel-accion { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: var(--s4) 0; }
.mas-datos > summary, .panel-accion > summary { cursor: pointer; padding: var(--s3) 0; font-weight: 600; min-height: 48px; display: flex; align-items: center; list-style-position: inside; }
.mas-datos[open] > summary, .panel-accion[open] > summary { margin-bottom: var(--s2); }
.panel-accion + .panel-accion { margin-top: calc(-1 * var(--s4) - 1px); }
.panel-accion > form, .panel-accion > p { margin-bottom: var(--s4); }
.panel-peligro > summary { color: var(--danger); }

.campo-monto label { font-size: var(--fs-md); }
.entrada-monto { position: relative; }
.entrada-monto > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: var(--fs-xl); font-weight: 600; color: var(--text-muted); }
.entrada-monto input { padding-left: 36px; font-size: var(--fs-2xl); font-weight: 700; min-height: 60px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s2) 0; }
.chip {
    min-height: 40px; padding: 0 var(--s3); font: inherit; font-size: var(--fs-sm); font-weight: 600;
    background: var(--bg); color: var(--text); border: 1px solid var(--border-soft); border-radius: 999px; cursor: pointer;
}
.chip:hover { background: var(--neutral-soft); }
.chip[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.segmentado { display: flex; border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; margin-bottom: var(--s4); }
.segmentado label { flex: 1; position: relative; }
.segmentado input { position: absolute; opacity: 0; inset: 0; }
.segmentado span {
    display: flex; align-items: center; justify-content: center; gap: var(--s1); min-height: var(--control-h); padding: 0 var(--s2);
    font-weight: 600; font-size: var(--fs-sm); cursor: pointer; border-left: 1px solid var(--border-soft); text-align: center;
}
.segmentado label:first-child span { border-left: 0; }
.segmentado input:checked + span { background: var(--primary); color: #fff; }
.segmentado input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -4px; }

.opciones-deuda { display: flex; flex-direction: column; border: 1px solid var(--border-soft); border-radius: var(--radius); }
.opcion { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); min-height: 56px; cursor: pointer; border-top: 1px solid var(--border); }
.opcion:first-child { border-top: 0; }
.opcion input { width: 20px; height: 20px; flex: none; accent-color: var(--primary); margin: 0; }
.opcion:has(input:checked) { background: var(--bg-subtle); }
.opcion-cuerpo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.opcion-titulo { font-weight: 600; }
.opcion-sub { font-size: var(--fs-sm); color: var(--text-muted); }

/* Botón principal fijo sobre la barra inferior en móviles: siempre visible al registrar. */
@media (max-width: 1023px) {
    .barra-accion { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: var(--bg); padding: var(--s3) 0; margin-bottom: 0; border-top: 1px solid var(--border); z-index: 5; }
}

/* ---------------------------- Comprobante ---------------------------- */
.impresion { background: var(--bg-subtle); }
.impresion main { max-width: 420px; margin: 0 auto; padding: var(--s4); }
.acciones-impresion { display: flex; gap: var(--s2); justify-content: space-between; margin-bottom: var(--s4); }
.comprobante { background: var(--bg); border: 1px solid var(--border); padding: var(--s6) var(--s5); font-size: var(--fs-sm); position: relative; }
.comprobante header { text-align: center; border-bottom: 1px dashed var(--border-soft); padding-bottom: var(--s3); margin-bottom: var(--s3); }
.comprobante h1 { font-size: var(--fs-xl); margin-bottom: var(--s1); }
.comprobante header p { margin: 0; color: var(--text-muted); }
.comprobante h2 { font-size: var(--fs-md); text-transform: uppercase; letter-spacing: 0.08em; text-align: center; margin: var(--s3) 0; }
.comprobante dl { margin: 0 0 var(--s4); }
.comprobante dl div { display: flex; justify-content: space-between; gap: var(--s3); padding: 2px 0; }
.comprobante dt { color: var(--text-muted); }
.comprobante dd { margin: 0; text-align: right; }
.comprobante table { width: 100%; border-collapse: collapse; margin-bottom: var(--s3); }
.comprobante th, .comprobante td { padding: var(--s1) 0; border-bottom: 1px dashed var(--border-soft); text-align: left; }
.comprobante .num { text-align: right; font-variant-numeric: tabular-nums; }
.comprobante .total { display: flex; justify-content: space-between; margin: var(--s2) 0; font-size: var(--fs-md); }
.comprobante footer { text-align: center; margin-top: var(--s5); border-top: 1px dashed var(--border-soft); padding-top: var(--s3); }
.comprobante .pie-legal { font-size: var(--fs-xs); color: var(--text-muted); }
.sello-anulado { text-align: center; font-size: var(--fs-2xl); font-weight: 700; color: var(--danger); border: 3px solid var(--danger); padding: var(--s1); letter-spacing: 0.2em; }
@media print {
    .no-imprimir { display: none !important; }
    .impresion { background: #fff; }
    .impresion main { max-width: none; padding: 0; }
    .comprobante { border: 0; padding: 0; }
    @page { margin: 8mm; }
}

/* =====================================================================
   Fase 4 · Marca, accesibilidad, estados y diálogos
   ===================================================================== */

/* Marca */
.marca-logo { width: 20px; height: 31px; }
.marca-logo-tienda { width: 32px; height: 32px; object-fit: contain; flex: none; border-radius: var(--radius); }
.marca-acceso { gap: var(--s3); font-size: var(--fs-xl); }
.marca-acceso .marca-logo { width: 26px; height: 40px; }
.boton-secundario:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.boton-texto { color: var(--text); }
.indicadores .indicador:first-child .indicador-valor { color: var(--primary); }
.historial-deuda .historial-icono, .historial-ajuste .historial-icono { background: var(--primary-soft); color: var(--primary); }
.nav-lateral a:hover { background: var(--primary-soft); color: var(--primary); }
.pestanas a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.segmentado input:checked + span { background: var(--primary); color: #fff; }
.opcion:has(input:checked) { background: var(--primary-soft); }
.resultado-abono { border-left-color: var(--turquesa); }
/* Un punto naranja de marca junto al título de cada sección: detalle sutil del logo. */
.seccion-titulo h2::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--naranja); margin-right: var(--s2); vertical-align: middle; }

/* Accesibilidad */
.saltar { position: absolute; left: var(--s2); top: -48px; z-index: 100; padding: var(--s2) var(--s4); background: var(--primary); color: #fff; border-radius: var(--radius); font-weight: 600; }
.saltar:focus { top: var(--s2); color: #fff; }
main:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); box-shadow: 0 0 0 4px var(--primary-soft); }

/* Estado de carga en botones (aria-busy lo pone app.js al enviar) */
.boton[aria-busy="true"] { position: relative; color: transparent !important; }
.boton[aria-busy="true"] .icono { visibility: hidden; }
.boton[aria-busy="true"]::after {
    content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px;
    border: 2px solid currentColor; border-color: #fff #fff transparent transparent; border-radius: 50%;
    animation: girar 0.7s linear infinite;
}
.boton-secundario[aria-busy="true"]::after, .boton-texto[aria-busy="true"]::after, .boton-peligro[aria-busy="true"]::after { border-color: var(--primary) var(--primary) transparent transparent; }
@keyframes girar { to { transform: rotate(360deg); } }
.resultados-vivos[aria-busy="true"] { opacity: 0.6; }

/* Diálogo de confirmación (lo crea app.js para formularios con data-confirmar) */
.dialogo { border: 0; padding: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay); width: min(420px, calc(100vw - 32px)); color: var(--text); }
.dialogo::backdrop { background: rgba(30, 27, 46, 0.45); }
.dialogo-cuerpo { padding: var(--s6) var(--s5) var(--s4); }
.dialogo-cuerpo h2 { font-size: var(--fs-lg); margin-bottom: var(--s2); display: flex; gap: var(--s2); align-items: center; }
.dialogo-cuerpo p { margin: 0; color: var(--text-muted); }
.dialogo-acciones { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s3) var(--s5) var(--s5); }
.dialogo-acciones .boton { flex: 1; }
.boton-peligro-solido { background: var(--danger); color: #fff; border-color: var(--danger); }
.boton-peligro-solido:hover { background: #a10012; color: #fff; }
@media (min-width: 600px) { .dialogo-acciones .boton { flex: none; } }

/* Editor de logo */
.logo-editor { display: flex; flex-wrap: wrap; gap: var(--s5); align-items: flex-start; }
.logo-vista { width: 120px; height: 120px; flex: none; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle); overflow: hidden; }
.logo-vista img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-vacio { display: flex; flex-direction: column; align-items: center; gap: var(--s1); color: var(--text-muted); font-size: var(--fs-sm); }
.logo-acciones { flex: 1; min-width: 220px; }
.form-logo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.selector-archivo { position: relative; overflow: hidden; }
.selector-archivo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.selector-archivo:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.nombre-archivo { font-size: var(--fs-sm); overflow-wrap: anywhere; }
.comprobante-logo { display: block; max-width: 96px; max-height: 72px; margin: 0 auto var(--s2); object-fit: contain; }

/* Vacíos con icono */
.vacio .icono-lg { color: var(--border-strong); margin-bottom: var(--s2); }

@media (prefers-reduced-motion: reduce) { .boton[aria-busy="true"]::after { animation: none; border-color: currentColor; opacity: 0.6; } }
