/* ══════════════════════════════════════════════════════════════
   TEMA ELLIE (Django) -- mismo lenguaje visual que BIOSOFT (sidebar
   fijo + topbar + stat-cards + badges + botones en degradé), pero
   con la paleta de marca de Ellie (verde menta #54E6D4, del
   isotipo) en vez del azul de BIOSOFT. Solo presentación -- ningún
   cálculo vive acá.
   ══════════════════════════════════════════════════════════════ */

/* ── Tipografía: Quicksand (trazo redondeado, hace juego con el
   isotipo redondeado de Ellie) -- alojada localmente en vez de por
   CDN de Google Fonts, para que la app siga funcionando sin
   conexión a internet (es una app de escritorio/red local). Solo
   subset "latin" (cubre español: áéíóúñü¿¡) en 4 pesos estáticos. ── */
@font-face {
    font-family: 'Quicksand';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/quicksand-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Quicksand';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/quicksand-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Quicksand';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/quicksand-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Quicksand';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/quicksand-700.woff2') format('woff2');
}

:root {
    --ellie-mint:        #54E6D4;  /* verde menta -- color de marca (isotipo) */
    --ellie-mint-dark:   #2FBFA8;
    --ellie-mint-light:  #E3FBF6;
    --ellie-primary:     #00B39A;  /* verde fuerte -- texto de marca, links, gradiente de botones */
    --ellie-primary-dark:#00695C;
    --ellie-red:         #E53935;
    --ellie-red-dark:    #C62828;
    --ellie-orange:      #FB8C00;
    --ellie-purple:      #8E24AA;
    --ellie-pink:        #EC407A;
    --ellie-sidebar-w:   224px;
    --ellie-bg:          #F1F8F6;
    --ellie-card-shadow: 0 2px 8px rgba(0,179,154,.14), 0 1px 3px rgba(0,0,0,.06);
    --ellie-text:        #101516;
    --ellie-subtext:     #66807B;
    --ellie-border:      #D3F0E9;

    /* Alias retrocompatibles -- un puñado de plantillas (banco_app,
       facturador_app, panel_master, plan_cuentas, tecnico_app,
       calendario_tributario_app) usan estos nombres en estilos inline;
       se mantienen apuntando a los tokens nuevos en vez de tocar cada
       plantilla. */
    --ios-blue: var(--ellie-mint);
    --ios-green: var(--ellie-primary);
    --ios-red: var(--ellie-red);
    --ios-orange: #FFC72C;
    --ios-gray: #A6ACB4;
    --ios-label2: var(--ellie-subtext);
    --ios-separator: var(--ellie-border);
}

/* ── Reset / Base ────────────────────────────────────────────── */
* { box-sizing: border-box; }
body {
    margin: 0;
    background-color: var(--ellie-bg);
    color: var(--ellie-text);
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    font-size: 14px;
}
a { color: inherit; text-decoration: none; }

h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.5rem; color: var(--ellie-text); }
h2 { font-size: 1.2rem; font-weight: 700; margin: 0 0 0.3rem; color: var(--ellie-text); }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.25rem; color: var(--ellie-text); }
p.caption, .caption { color: var(--ellie-subtext); font-size: 0.85rem; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width: var(--ellie-sidebar-w);
    background: #fff;
    border-right: 1px solid var(--ellie-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    /* En el celular, 100vh es más alto que lo visible (no descuenta la barra
       de direcciones) y el pie del menú -- empresa y la 🔑 de Claves -- quedaba
       cortado debajo de la pantalla. 100dvh = alto visible real; los
       navegadores que no lo conocen se quedan con el 100vh de arriba. */
    height: 100dvh;
    z-index: 100;
    transition: width .2s;
    box-shadow: 2px 0 12px rgba(0,179,154,.1);
}
.sidebar-logo {
    height: 68px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,179,154,.3);
}
.sidebar-logo-text { display: flex; flex-direction: column; line-height: 1.15; overflow: hidden; }
.sidebar-logo-text .logo-title { font-size: 17px; font-weight: 700; color: var(--ellie-text); }
.sidebar-logo-text .logo-sub { font-size: 10px; color: var(--ellie-subtext); font-weight: 600; letter-spacing: .4px; text-transform: uppercase; }

.sidebar-collapse-btn {
    position: absolute; top: 22px; right: -11px;
    width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; cursor: pointer; color: #fff; font-size: 14px; line-height: 1;
    background: var(--ellie-primary); border: 2px solid #fff; padding: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    transition: background .12s;
}
.sidebar-collapse-btn:hover { background: var(--ellie-primary-dark); }
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .nav-item span:not(.nav-item-icon),
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-footer-company,
.sidebar.collapsed .sidebar-footer-version { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; color: var(--ellie-subtext);
    font-size: 13px; font-weight: 500; cursor: pointer;
    border-left: 3px solid transparent; transition: all .15s;
    margin-bottom: 2px; border-radius: 10px;
    white-space: nowrap;
}
.nav-item:hover {
    background: var(--ellie-mint-light); color: var(--ellie-text);
}
.nav-item.active {
    background: var(--ellie-mint-light); color: var(--ellie-primary-dark);
    border-left-color: var(--ellie-primary); font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(0,179,154,.18);
}
.nav-item-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item-external { opacity: .88; }
.sidebar-divider { height: 1px; background: var(--ellie-border); margin: 8px 10px; }
.sidebar-section-label {
    font-size: 10px; font-weight: 700; color: var(--ellie-subtext);
    text-transform: uppercase; letter-spacing: .6px;
    padding: 14px 12px 4px;
}
.sidebar-nav .nav-item + .sidebar-section-label { margin-top: 4px; }
.sidebar.collapsed .sidebar-section-label { display: none; }

.sidebar-footer {
    padding: 12px 16px 14px; border-top: 1px solid var(--ellie-border);
    background: var(--ellie-mint-light); flex-shrink: 0;
}
.sidebar-footer-label { font-size: 10px; font-weight: 700; color: var(--ellie-subtext); text-transform: uppercase; letter-spacing: .5px; }
.sidebar-footer-value { font-size: 12.5px; font-weight: 700; color: var(--ellie-text); margin-top: 1px; line-height: 1.3; }
.sidebar-footer-sub { font-size: 11px; color: var(--ellie-subtext); margin-top: 1px; }
.sidebar-footer-version { font-size: 10px; color: var(--ellie-subtext); margin-top: 8px; font-weight: 600; }

/* ── Main content ────────────────────────────────────────────── */
.main-wrap { flex: 1; display: flex; flex-direction: column; min-height: 100vh; margin-left: 0; transition: margin-left .2s; }
body.has-sidebar { display: flex; }
body.has-sidebar .main-wrap { margin-left: var(--ellie-sidebar-w); }
body.has-sidebar.sidebar-collapsed .main-wrap { margin-left: 64px; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
    background: #fff; border-bottom: 1px solid var(--ellie-border);
    padding: 0 22px; height: 58px; display: flex; align-items: center;
    justify-content: space-between; position: sticky; top: 0; z-index: 50;
    box-shadow: 0 2px 8px rgba(0,179,154,.08);
    gap: 12px;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--ellie-text); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-viewing { font-size: 12.5px; color: var(--ellie-subtext); }
.sri-estado {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 10px; border-radius: 999px; border: 1px solid var(--ellie-border);
    background: #fff; cursor: pointer; font-size: 12px; font-weight: 600;
    color: var(--ellie-subtext); line-height: 1;
}
.sri-estado:hover { background: var(--ellie-mint-light); }
.sri-estado-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
    background: var(--ios-gray); transition: background-color .15s;
}
.sri-estado-dot.sri-estado-checking { background: var(--ios-orange); animation: sriPulse 1s ease-in-out infinite; }
.sri-estado-dot.sri-estado-ok { background: var(--ellie-primary); box-shadow: 0 0 5px var(--ellie-primary); }
.sri-estado-dot.sri-estado-error { background: var(--ellie-red); box-shadow: 0 0 5px var(--ellie-red); }
.sri-estado-dot.sri-estado-na { background: var(--ios-gray); }
.sri-estado-mensaje {
    font-size: 12px; font-weight: 600; color: var(--ellie-red);
    max-width: 320px; text-align: right; line-height: 1.25;
}
@keyframes sriPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ellie-subtext); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--ellie-mint) 0%, var(--ellie-mint-dark) 100%);
    color: var(--ellie-text);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    box-shadow: 0 0 0 2px var(--ellie-mint-dark);
    flex-shrink: 0;
}

/* ── Page content ────────────────────────────────────────────── */
.content { padding: 22px 24px 3rem; flex: 1; max-width: 1600px; width: 100%; margin: 0 auto; }
body:not(.has-sidebar) .content { padding: 0; max-width: none; margin: 0; }

/* ── Stat / KPI cards (usadas por .ellie-card en todas las páginas) ── */
.ellie-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 16px; margin-bottom: 20px; }
.ellie-card {
    background: #fff; border-radius: 12px; padding: 18px 20px;
    box-shadow: var(--ellie-card-shadow);
    border: 1px solid var(--ellie-border);
    border-top: 3px solid var(--ellie-mint);
    display: flex; flex-direction: column; gap: 4px;
}
.ellie-card.green  { border-top-color: var(--ellie-primary); }
.ellie-card.red    { border-top-color: var(--ellie-red); }
.ellie-card.orange { border-top-color: var(--ellie-orange); }
.ellie-card.purple { border-top-color: var(--ellie-purple); }
.ellie-card.pink   { border-top-color: var(--ellie-pink); }
.ellie-card .label { color: var(--ellie-subtext); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.ellie-card .value { color: var(--ellie-text); font-size: 1.65rem; font-weight: 700; margin-top: 2px; }
.ellie-card .delta, .ellie-card .sub { font-size: 12px; color: var(--ellie-primary); margin-top: 1px; }

/* Animación de entrada (fade + subida) -- se usa puntual donde se pida,
   no global en todas las páginas (ver Inicio). */
@keyframes ellie-entrada { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.ellie-entrada { animation: ellie-entrada 0.55s cubic-bezier(.2,.7,.3,1) both; }
.ellie-entrada-2 { animation-delay: .08s; }

/* ── Diagrama del proceso (Producción → Proceso) ──────────────────
   Pasos fijos del sistema vs. etapas de producción configurables, uno
   junto al otro con flechas entre medio; se envuelve solo en pantallas
   angostas (overflow-x en el contenedor de la página ya viene resuelto
   por .ellie-table-wrap para otras tablas -- acá basta con flex-wrap). */
.ellie-proceso-flow { display: flex; align-items: stretch; flex-wrap: wrap; gap: 0.5rem 0.3rem; margin-bottom: 1rem; }
.ellie-proceso-paso {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; min-width: 128px; padding: 0.8rem 0.7rem;
    border-radius: 12px; border: 1px solid var(--ellie-border);
    background: #fff; box-shadow: var(--ellie-card-shadow);
    position: relative;
}
.ellie-proceso-acciones { display: flex; gap: 0.15rem; margin-bottom: 0.3rem; }
.ellie-proceso-acciones .btn-icon { width: 24px; height: 24px; font-size: 0.75rem; margin: 0; }
.ellie-proceso-acciones .btn-icon:disabled { opacity: 0.3; cursor: default; }
.ellie-proceso-acciones .btn-icon:disabled:hover { background: var(--ellie-mint-light); color: var(--ellie-primary-dark); transform: none; }
.ellie-proceso-icono { font-size: 1.4rem; line-height: 1; margin-bottom: 0.3rem; }
.ellie-proceso-nombre { font-size: 0.82rem; font-weight: 700; color: var(--ellie-text); }
.ellie-proceso-detalle { font-size: 0.72rem; color: var(--ellie-subtext); margin-top: 0.15rem; }
.ellie-proceso-fijo { border-top: 3px solid var(--ellie-purple); }
.ellie-proceso-etapa { border-top: 3px solid var(--ellie-primary); background: var(--ellie-mint-light); }
.ellie-proceso-vacio { border-top: 3px dashed var(--ellie-orange); opacity: 0.8; }
.ellie-proceso-flecha { display: flex; align-items: center; font-size: 1.3rem; color: var(--ellie-subtext); flex-shrink: 0; }
.ellie-proceso-leyenda-swatch {
    display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: middle;
    margin-right: 0.3rem; border: 1px solid var(--ellie-border);
}
.ellie-proceso-leyenda-swatch.ellie-proceso-fijo { background: var(--ellie-purple); border-top: none; }
.ellie-proceso-leyenda-swatch.ellie-proceso-etapa { background: var(--ellie-primary); border-top: none; }

/* ── Cards genéricas con encabezado (opcionales, para pantallas que las adopten) ── */
.card { background: #fff; border-radius: 12px; box-shadow: var(--ellie-card-shadow); border: 1px solid var(--ellie-border); margin-bottom: 20px; }
.card-header {
    padding: 14px 18px; border-bottom: 1px solid var(--ellie-border);
    display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(135deg, #fff 0%, var(--ellie-mint-light) 100%);
    border-radius: 12px 12px 0 0;
}
.card-header h2 { font-size: 14px; font-weight: 700; margin: 0; }
.card-body { padding: 18px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-green  { background: var(--ellie-mint-light); color: var(--ellie-primary-dark); }
.badge-red    { background: #FDECEA; color: var(--ellie-red-dark); }
.badge-orange { background: #FFF3E0; color: #E65100; }
.badge-teal   { background: var(--ellie-mint-light); color: var(--ellie-primary-dark); }
.badge-gray   { background: #EDF2F0; color: #607068; }

/* ── Estado de celda/fila (Tarjetas de Crédito) ─────────────────── */
td.tc-ok    { background: var(--ellie-mint-light); color: var(--ellie-primary-dark); font-weight: 700; }
td.tc-warn  { background: #FFF9DB; color: #856404; }
td.tc-bad   { background: #FDECEA; color: var(--ellie-red-dark); font-weight: 700; }
td.tc-muted { background: #F4F6F7; color: #95A5A6; }

/* ── Botones ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    border-radius: 10px; font-weight: 600; padding: 0.5rem 1.15rem;
    border: none; cursor: pointer; font-size: 0.88rem;
    letter-spacing: .1px; transition: all 0.18s ease;
}
.btn-primary {
    background: linear-gradient(135deg, #22C6AE 0%, var(--ellie-primary-dark) 100%);
    color: #fff;
    box-shadow: 0 3px 10px rgba(0,179,154,.35);
}
.btn-primary:hover { box-shadow: 0 5px 16px rgba(0,179,154,.5); transform: translateY(-1px); color: #fff; }
.btn-secondary { background-color: rgba(142,78,198,0.1); color: var(--ellie-purple); }
.btn-secondary:hover { background-color: rgba(142,78,198,0.18); }
.btn-outline { background: #fff; color: var(--ellie-primary-dark); border: 1.5px solid var(--ellie-mint-dark); }
.btn-outline:hover { background: var(--ellie-mint-light); border-color: var(--ellie-primary); }
.btn-danger { background: linear-gradient(135deg, #EF5350 0%, var(--ellie-red-dark) 100%); color: #fff; box-shadow: 0 3px 10px rgba(229,57,53,.25); }
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(229,57,53,.35); color: #fff; }
.btn-sm { padding: 0.32rem 0.85rem; font-size: 0.78rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── Botones de ícono (acciones de fila en tablas: ver/editar/eliminar) ── */
.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 0; margin: 0 2px;
    border-radius: 8px; border: none; cursor: pointer;
    font-size: 0.92rem; line-height: 1; transition: all 0.15s ease;
    background: var(--ellie-mint-light); color: var(--ellie-primary-dark);
}
.btn-icon:hover { background: var(--ellie-primary); color: #fff; transform: translateY(-1px); }
.btn-icon.btn-icon-danger { background: #FDECEA; color: var(--ellie-red-dark); }
.btn-icon.btn-icon-danger:hover { background: var(--ellie-red-dark); color: #fff; }

/* ── Barra de íconos con etiqueta al pasar el mouse (toolbars tipo Compras) ──
   Cada botón muestra solo su ícono; el texto que antes iba al lado ahora
   aparece como una burbuja oscura arriba, vía data-tooltip -- mismo patrón
   en cualquier pantalla que lo adopte. */
.ellie-icon-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.ellie-icon-toolbar .ellie-toolbar-sep { width: 1px; align-self: stretch; background: var(--ellie-border); }
.btn-toolbar-icon {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0;
    border-radius: 9px; border: 1px solid var(--ellie-border);
    background: #fff; color: var(--ellie-primary-dark);
    font-size: 1.05rem; line-height: 1; cursor: pointer;
    transition: all 0.15s ease;
}
.btn-toolbar-icon:hover { background: var(--ellie-mint-light); border-color: var(--ellie-mint-dark); transform: translateY(-1px); color: var(--ellie-primary-dark); }
.btn-toolbar-icon.btn-toolbar-icon-active { background: var(--ellie-primary); border-color: var(--ellie-primary); color: #fff; }
.btn-toolbar-icon.btn-toolbar-icon-active:hover { background: var(--ellie-primary-dark); border-color: var(--ellie-primary-dark); color: #fff; }
.btn-toolbar-icon.btn-toolbar-icon-danger { color: var(--ellie-red-dark); }
.btn-toolbar-icon.btn-toolbar-icon-danger:hover { background: #FDECEA; border-color: var(--ellie-red-dark); }

.btn-toolbar-icon::after,
.btn-toolbar-icon::before {
    position: absolute; left: 50%; opacity: 0; visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease; z-index: 30;
}
.btn-toolbar-icon::after {
    content: attr(data-tooltip);
    bottom: calc(100% + 9px); transform: translateX(-50%) translateY(4px);
    background: var(--ellie-text); color: #fff;
    padding: 5px 10px; border-radius: 7px;
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0;
    white-space: nowrap; pointer-events: none;
}
.btn-toolbar-icon::before {
    content: ""; bottom: calc(100% + 4px); transform: translateX(-50%) translateY(4px);
    border: 5px solid transparent; border-top-color: var(--ellie-text);
}
.btn-toolbar-icon:hover::after, .btn-toolbar-icon:hover::before,
.btn-toolbar-icon:focus-visible::after, .btn-toolbar-icon:focus-visible::before {
    opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}

/* ── Formularios ──────────────────────────────────────────────── */
label { display: block; font-size: 0.8rem; color: var(--ellie-subtext); font-weight: 600; margin-bottom: 0.3rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="search"], input[type="file"],
select, textarea {
    width: 100%;
    border-radius: 9px;
    border: 1px solid var(--ellie-border);
    background-color: #fff;
    color: var(--ellie-text);
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--ellie-mint-dark);
    box-shadow: 0 0 0 3px rgba(84,230,212,0.25);
}
.field { margin-bottom: 0.9rem; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { flex: 1; }

/* ── Cuadros de filtro más compactos ──────────────────────────────
   Todo formulario de filtro del sistema (Cliente/Proveedor, Estado,
   Fecha, Mes, "Solo sin clasificar", etc.) usa <form method="get"> --
   a diferencia de un alta o edición, que siempre va por POST. Se
   aprovecha esa distinción para achicar SOLO los cuadros de filtro
   (padding, separación entre campos, tamaño de etiqueta/input) sin
   tocar los formularios de alta/edición, que necesitan su espacio. */
form[method="get"].ellie-card,
form[method="get"] .ellie-card {
    padding: 10px 14px;
}
form[method="get"] .field { margin-bottom: 0.35rem; }
form[method="get"] .field-row { gap: 0.6rem; row-gap: 0.35rem; align-items: end; }
form[method="get"] label { margin-bottom: 0.15rem; font-size: 0.72rem; }
form[method="get"] input[type="text"], form[method="get"] input[type="date"],
form[method="get"] input[type="number"], form[method="get"] select {
    padding: 0.35rem 0.55rem; font-size: 0.85rem;
}

/* ── Buscador con lista (reemplaza <select> largos) ──────────────
   searchable_select.js envuelve cualquier <select> con muchas
   opciones en este componente: input de texto + lista filtrable.
   El <select> original sigue en el DOM (oculto visualmente, no con
   display:none) para que el formulario se siga enviando igual. ── */
.ss-wrap { position: relative; }
.ss-native {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.ss-input {
    padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2366807B'%3E%3Cpath d='M5.5 7.5l4.5 4.5 4.5-4.5' stroke='%2366807B' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.6rem center; background-size: 14px;
    cursor: text;
}
.ss-wrap.open .ss-input {
    border-color: var(--ellie-mint-dark);
    box-shadow: 0 0 0 3px rgba(84,230,212,0.25);
}
/* .ss-list vive fuera de .ss-wrap (appendChild a <body>, position:fixed
   posicionado por JS con getBoundingClientRect) para no quedar recortada
   por ancestros con overflow:hidden -- ej. .ellie-table-wrap, que es
   justo donde vive el selector de "Tipo Gasto" por fila. */
.ss-list {
    /* z-index por encima de .ellie-row-popover-panel (1000) -- si el
       select buscable vive dentro de un popover tipo modal (ej. "Cobro" en
       Cartera de Clientes), su lista de resultados tiene que ganarle al
       panel, si no queda tapada y el buscador parece no encontrar nada. */
    position: fixed; z-index: 1100;
    max-height: 260px; overflow-y: auto; margin: 0; padding: 4px;
    list-style: none;
    background: #fff; border: 1px solid var(--ellie-mint-dark);
    border-radius: 9px;
    box-shadow: var(--ellie-card-shadow);
    display: none;
}
.ss-list.open { display: block; }
.ss-item {
    padding: 0.45rem 0.6rem; border-radius: 6px; cursor: pointer;
    font-size: 0.88rem; color: var(--ellie-text);
}
.ss-item.ss-active { background-color: var(--ellie-mint-light); }
.ss-item.ss-selected { font-weight: 700; color: var(--ellie-primary-dark); }
.ss-empty { padding: 0.5rem 0.6rem; font-size: 0.85rem; color: var(--ellie-subtext); }

/* ── Mensajes flotantes (toasts) ──────────────────────────────────
   Pila fija en la esquina, cada uno se desvanece solo -- sin JS, con una
   animación CSS que entra y a los pocos segundos vuelve a salir. Usado
   por Ventas -> Retenciones ("Vincular automáticamente") para avisar,
   uno por uno, qué retención no encontró su factura. */
.ellie-toast-stack {
    position: fixed; bottom: 20px; right: 20px; z-index: 1100;
    display: flex; flex-direction: column-reverse; gap: 8px;
    max-height: calc(100vh - 40px); overflow: hidden;
    pointer-events: none;
}
.ellie-toast {
    background: var(--ellie-text); color: #fff;
    padding: 9px 14px; border-radius: 9px;
    font-size: 0.82rem; font-weight: 600;
    box-shadow: var(--ellie-card-shadow);
    border-left: 4px solid var(--ellie-orange);
    animation: ellie-toast-in .25s ease, ellie-toast-out .4s ease 6s forwards;
}
@keyframes ellie-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes ellie-toast-out {
    from { opacity: 1; }
    to   { opacity: 0; transform: translateY(-6px); }
}

/* ── Ventana flotante para "Editar" dentro de filas de tabla ─────
   row_popover.js reubica el <form> de un <details class="ellie-row-
   popover"> acá afuera como un modal centrado con fondo oscurecido,
   en vez de un panel empujado a la fuerza dentro de la celda angosta
   de la tabla (que lo recorta, choca con el botón de eliminar, o lo
   deja fuera de la pantalla sin forma de bajar a ver el resto). ── */
.ellie-row-popover-backdrop {
    position: fixed; inset: 0; z-index: 999;
    background: rgba(16,21,22,0.4);
}
.ellie-row-popover-panel {
    position: fixed; z-index: 1000;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 420px; max-width: calc(100vw - 32px);
    max-height: 85vh; overflow-y: auto;
    background: #fff; border-radius: 12px;
    border: 1px solid var(--ellie-border);
    box-shadow: 0 16px 48px rgba(0,0,0,.28);
    padding: 1.1rem 1.25rem 1.25rem;
}
/* <details class="ellie-row-popover" data-wide> -- para formularios con
   muchas etiquetas largas o pares de campos lado a lado (ej. "Nuevo
   activo" en Activos Fijos): sin esto, todos los popovers quedan
   pegados a 420px sin importar cuánto contenido tengan, y un formulario
   así se ve amontonado (ver row_popover.js, que lee data-wide). */
.ellie-row-popover-panel--wide {
    width: 640px;
}
.ellie-row-popover-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.9rem;
}
.ellie-row-popover-title { font-weight: 700; font-size: 0.95rem; color: var(--ellie-text); }
.ellie-row-popover-close {
    background: none; border: none; cursor: pointer;
    font-size: 1.5rem; line-height: 1; color: var(--ellie-subtext);
    padding: 0.1rem 0.5rem; border-radius: 8px;
}
.ellie-row-popover-close:hover { background: var(--ellie-mint-light); color: var(--ellie-primary-dark); }
.ellie-row-popover-panel form { margin: 0; }
.ellie-row-popover-panel .field-row {
    display: flex; flex-direction: column; gap: 0;
}
/* Misma especificidad que la regla genérica de arriba (.ellie-row-popover-
   panel .field-row) -- tiene que ir DESPUÉS en el archivo para ganarle y
   que un popover data-wide de verdad ponga los campos en fila. Antes
   estaba declarada ANTES, así que la regla genérica la pisaba siempre y
   ningún popover "wide" mostraba sus campos lado a lado -- se veían todos
   apilados uno por uno, ocupando el doble de alto de lo necesario (ver
   Ventas -> Cartera -> Cobro, Compras -> Pagos -> Pago). */
.ellie-row-popover-panel--wide .field-row {
    flex-direction: row;
    gap: 1rem;
}

/* ── Tablas ───────────────────────────────────────────────────── */
.ellie-table-wrap {
    background-color: #fff;
    border-radius: 12px;
    /* overflow-x:auto (no "hidden") -- una tabla de 8-10 columnas (Compras,
       Ventas, Cartera...) es más ancha que la pantalla de un celular;
       "hidden" simplemente recortaba las columnas de la derecha (el saldo,
       los botones de acción) sin ninguna forma de llegar a verlas. Con
       overflow-x:auto el cuadro se desliza con el dedo en vez de perder
       datos -- el único costo es que la esquina de la tabla ya no queda
       perfectamente redondeada mientras se hace scroll, tradeoff que vale
       la pena frente a contenido inaccesible. */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--ellie-card-shadow);
    border: 1px solid var(--ellie-border);
}
table.ellie-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
table.ellie-table th {
    background-color: var(--ellie-bg);
    color: var(--ellie-subtext);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--ellie-border);
}
table.ellie-table td { padding: 0.55rem 0.8rem; border-top: 1px solid var(--ellie-border); }
table.ellie-table tr:hover td { background-color: rgba(84,230,212,0.07); }
table.ellie-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Filtro instantáneo por columna, escrito directo en el título (ver
   core/static/core/js/table_column_filter.js) -- sin formulario de
   búsqueda ni botón aparte, se aplica solo con cada tecla. */
.ellie-th-filtro {
    display: block; width: 100%; margin-top: 0.25rem;
    font-size: 0.7rem; font-weight: 400; text-transform: none; letter-spacing: normal;
    color: var(--ellie-text); background: #fff;
    border: 1px solid var(--ellie-border); border-radius: 4px;
    height: 20px; line-height: 1; padding: 0 0.35rem; box-sizing: border-box;
}
.ellie-th-filtro:focus { outline: none; border-color: var(--ellie-mint-dark); }

/* ── Paginación (listas largas: Compras, Ventas, Historial...) ──────── */
.ellie-paginacion { display: flex; align-items: center; justify-content: center; gap: 0.35rem; margin: 1.2rem 0; flex-wrap: wrap; }

/* ── Alertas ──────────────────────────────────────────────────── */
.alert { border-radius: 10px; padding: 0.8rem 1.05rem; margin-bottom: 0.7rem; font-size: 0.88rem; border-left: 4px solid transparent; }
.alert-info { background-color: rgba(84,230,212,0.1); color: #0F6B5C; border-left-color: var(--ellie-mint); }
.alert-success { background-color: rgba(0,179,154,0.1); color: #00695C; border-left-color: var(--ellie-primary); }
.alert-warning { background-color: rgba(255,199,44,0.16); color: #8A6D00; border-left-color: #FFC72C; }
.alert-error { background-color: rgba(255,59,48,0.09); color: #C62828; border-left-color: var(--ellie-red); }
.alert a { text-decoration: underline; font-weight: 700; }

hr { border: none; border-top: 1px solid var(--ellie-border); margin: 1.2rem 0; }

/* ── Login / pantallas centradas ─────────────────────────────── */
.ellie-login-wrap {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(135deg, var(--ellie-mint-light) 0%, #EAF7F4 50%, #F4FBF9 100%);
}
.ellie-login-card {
    width: 380px;
    background-color: #fff;
    border-radius: 18px;
    padding: 2.2rem 2rem;
    box-shadow: 0 8px 40px rgba(0,179,154,.22), 0 2px 8px rgba(0,0,0,.06);
    border: 1px solid var(--ellie-border);
}
.ellie-login-card h1 { text-align: center; font-size: 1.35rem; }
.ellie-login-card p.caption { text-align: center; margin-bottom: 1.4rem; }

/* ── Mobile: hamburger + overlay ────────────────────────────── */
.hamburger {
    display: none; align-items: center; justify-content: center;
    width: 36px; height: 36px; flex-shrink: 0;
    background: var(--ellie-bg); border: 1px solid var(--ellie-border);
    border-radius: 8px; cursor: pointer; color: var(--ellie-text); font-size: 18px;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99; }
.sidebar-overlay.open { display: block; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,179,154,.35); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,179,154,.55); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    body.has-sidebar .sidebar { width: 64px; }
    body.has-sidebar .sidebar .sidebar-logo-text,
    body.has-sidebar .sidebar .nav-item span:not(.nav-item-icon),
    body.has-sidebar .sidebar .sidebar-footer-company,
    body.has-sidebar .sidebar .sidebar-footer-version,
    body.has-sidebar .sidebar-collapse-btn { display: none; }
    body.has-sidebar .main-wrap { margin-left: 64px; }
    .field-row { flex-direction: column; }
    /* form[method="get"] .field-row trae align-items:end (línea ~414) para
       alinear label+input por abajo cuando la fila es horizontal -- en
       columna (acá) ese mismo align-items pasa a controlar el eje
       horizontal y encoge cada campo pegándolo a la derecha (descuadrado).
       Misma especificidad que esa regla (form[method="get"] .field-row),
       gana por venir después en el archivo. */
    form[method="get"] .field-row { align-items: stretch; }
    /* Modificador para las pocas filas de filtro que, por tener solo 2-3
       campos cortos, se ven mejor horizontales aun en el celular en vez de
       apiladas -- ver ej. control_interno_app/facturas.html. */
    .field-row.field-row--horizontal { flex-direction: row; align-items: end; }
    .field-row.field-row--horizontal .field { flex: 1 1 120px; }
}
@media (max-width: 560px) {
    .hamburger { display: flex; }
    body.has-sidebar .sidebar {
        width: var(--ellie-sidebar-w);
        transform: translateX(calc(-1 * var(--ellie-sidebar-w)));
        transition: transform .25s ease; z-index: 200;
    }
    body.has-sidebar .sidebar.mobile-open { transform: translateX(0); }
    body.has-sidebar .sidebar .sidebar-logo-text,
    body.has-sidebar .sidebar .nav-item span:not(.nav-item-icon),
    body.has-sidebar .sidebar .sidebar-footer-company,
    body.has-sidebar .sidebar .sidebar-footer-version { display: revert; }
    body.has-sidebar .main-wrap { margin-left: 0; }
    .content { padding: 14px; }
    .topbar { padding: 0 12px; }
    .topbar-user span { display: none; }
    .topbar-viewing { display: none; }
    .ellie-login-card { width: 100%; padding: 1.6rem 1.2rem; }
}

/* ── Impresión de un bloque puntual (ej. "🖨️ Imprimir asiento" de
   Compras -> Editar factura, o Balance General/Estado de Resultados) --
   cualquier elemento con class="ellie-imprimible" es lo ÚNICO que sale en
   el papel: sidebar, topbar, formularios y el resto de la página quedan
   ocultos. Los botones que viven DENTRO del bloque imprimible (ej. los
   mismos "Imprimir"/"Descargar Excel") llevan class="no-imprimir" para
   tampoco salir impresos. Solo pensado para UN bloque imprimible por
   página -- si hubiera más de uno, todos saldrían apilados. ── */
@media print {
    body * { visibility: hidden; }
    .ellie-imprimible, .ellie-imprimible * { visibility: visible; }
    .ellie-imprimible {
        position: absolute; left: 0; top: 0; width: 100%;
        margin: 0; box-shadow: none; border: none;
    }
    .ellie-imprimible .no-imprimir { display: none !important; }
}
