/* =========================================================
   Tema Global
   Variables base de color, sombras y radios reutilizados
   en toda la aplicacion.
   ========================================================= */
:root {
    --bg: #f8fafc;
    --surface: rgba(255, 255, 255, 0.96);
    --surface-strong: #ffffff;
    --surface-dark: #0f172a;
    --surface-dark-alt: #1e293b;
    --text: #0f172a;
    --muted: #64748b;
    --muted-soft: #94a3b8;
    --line: rgba(148, 163, 184, 0.22);
    --brand: #0f766e;
    --brand-strong: #115e59;
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.12);
    --success: #059669;
    --success-soft: rgba(5, 150, 105, 0.14);
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
    --shadow-soft: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 12px 24px rgba(15, 23, 42, 0.04);
    --radius-lg: 18px;
}

/* =========================================================
   Reset y Base
   Normaliza box model, tipografia, enlaces y elementos de
   formulario compartidos por todas las vistas.
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.06), transparent 26%),
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.06), transparent 20%),
        linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
}

body.modal-open {
    overflow: hidden;
}

body.menu-open {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

input,
select,
textarea,
button {
    font: inherit;
}

button {
    cursor: pointer;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.9rem 0.95rem;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.98);
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(15, 118, 110, 0.3);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* =========================================================
   Botones Globales
   Estilos base para botones primarios, secundarios, outline
   y variantes compactas usadas en todo el sistema.
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 42px;
    padding: 0.78rem 1.05rem;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand), var(--brand-strong));
    color: #fff;
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1;
    letter-spacing: 0.01em;
    white-space: nowrap;
    box-shadow: 0 10px 22px rgba(15, 118, 110, 0.14);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(15, 118, 110, 0.18);
}

.btn:disabled,
.btn.is-loading {
    opacity: 0.7;
    cursor: wait;
}

.btn-outline,
.btn-secondary {
    box-shadow: none;
}

.btn-outline {
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.24);
    color: var(--text);
}

.btn-outline:hover {
    border-color: rgba(15, 118, 110, 0.22);
    background: #f8fafc;
    box-shadow: 0 10px 18px rgba(148, 163, 184, 0.12);
}

.btn-secondary {
    background: linear-gradient(135deg, #1f4c7c, #102f50);
}

.btn-secondary:hover {
    box-shadow: 0 14px 28px rgba(16, 47, 80, 0.18);
}

.btn-sm {
    min-height: 34px;
    padding: 0.52rem 0.78rem;
    font-size: 0.82rem;
    border-radius: 12px;
}

/* =========================================================
   Estructura Principal
   Define el shell general de la aplicacion: sidebar, area
   principal y contenedores base del layout autenticado.
   ========================================================= */
.layout,
.shell {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}



/* =========================================================
   Topbar y Contenido
   Barra superior fija, acciones del encabezado y separacion
   general del contenido interno.
   ========================================================= */
.topbar,
.topbar-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.25rem 1.6rem;
    background: rgba(255, 255, 255, 0.84);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1,
.topbar-modern h2 {
    margin: 0.18rem 0 0;
    font-size: 1.35rem;
}

.topbar small,
.topbar-modern small {
    color: var(--muted);
}

.content,
.content-modern {
    padding: 1.8rem;
}

.content > * + *,
.content-modern > * + * {
    margin-top: 1.25rem;
}

/* =========================================================
   Encabezados, Grids y Tarjetas
   Cabeceras de pagina, metricas, cards y estructuras de
   columnas reutilizadas en modulos operativos.
   ========================================================= */
.page-title,
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1.55rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.9) 100%);
    box-shadow: var(--shadow-soft);
}

.page-title > div,
.page-header > div {
    flex: 1 1 320px;
}

.page-title h2,
.page-header h2 {
    margin: 0.2rem 0 0.35rem;
    font-size: clamp(1.65rem, 2vw, 2.2rem);
    line-height: 1.05;
}

.page-header p,
.page-title p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.header-summary,
.metric-grid,
.grid.cards,
.grid.two,
.grid.three,
.workspace-grid,
.balance-grid,
.report-links,
.process-layout {
    display: grid;
    gap: 1rem;
}

.header-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-width: min(460px, 100%);
    align-self: stretch;
}

.header-summary > div,
.metric-card,
.report-card {
    min-width: 0;
    min-height: 100%;
    padding: 1.05rem 1.1rem;
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.94) 100%);
    box-shadow: var(--shadow-soft);
}

.header-summary span,
.metric-card span,
.report-card span {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--muted);
    font-size: 0.86rem;
}

.header-summary strong,
.metric-card strong,
.report-card strong {
    display: block;
    font-size: 1.35rem;
}

.metric-grid,
.grid.cards {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric-card.danger {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(254, 226, 226, 0.72));
}

.workspace-grid,
.grid.two {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.process-layout {
    grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.9fr);
    align-items: start;
}

.process-layout-single {
    grid-template-columns: minmax(0, 1fr);
}

.process-main {
    min-width: 0;
}

.process-aside {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.process-form {
    gap: 1rem;
}

.process-main-compact {
    gap: 0.8rem;
    padding: 1rem 1.05rem 1.1rem;
}

.section-head-compact {
    margin-bottom: 0.35rem;
    gap: 0.75rem;
}

.section-head-compact p {
    line-height: 1.45;
}

.quick-actions-compact {
    gap: 0.45rem;
}

.quick-actions-compact .btn {
    min-height: 42px;
    padding: 0.72rem 0.95rem;
}

.process-form-compact {
    gap: 0.8rem 0.9rem;
}

.process-form-compact label {
    gap: 0.32rem;
}

.process-form-compact input,
.process-form-compact select,
.process-form-compact textarea {
    min-height: 46px;
    padding: 0.72rem 0.82rem;
}

.process-form-compact textarea {
    min-height: 88px;
}

.client-search-shell-compact {
    gap: 0.5rem;
}

.client-search-shell-compact .client-search-selected {
    padding: 0.72rem 0.82rem;
    gap: 0.28rem;
}

.client-search-shell-compact .client-search-panel {
    padding: 0.45rem;
}

.live-panel-compact {
    padding: 0.82rem 0.9rem;
    gap: 0.55rem;
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

.live-panel-compact strong {
    font-size: 1rem;
}

.process-submit-compact {
    min-height: 48px;
}

.form-span-full {
    grid-column: 1 / -1;
}

.form-span-2 {
    grid-column: span 2;
}

.process-totals {
    margin-top: 0.25rem;
}

.process-submit {
    min-height: 52px;
    font-size: 1rem;
}

.grid.three,
.balance-grid,
.report-links {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card,
.balance-card {
    display: grid;
    align-content: start;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    min-width: 0;
    padding: 1.35rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, var(--surface) 0%, rgba(255, 255, 255, 0.94) 100%);
    box-shadow: var(--shadow);
}

.card-feature {
    background:
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.08), transparent 24%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.92));
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    width: 100%;
}

.section-head > div,
.page-header > div,
.topbar-leading > div {
    min-width: 0;
}

.section-head h3,
.balance-card h3,
.card h3 {
    margin: 0;
    font-size: 1.08rem;
}

.section-head p {
    margin: 0.2rem 0 0;
    color: var(--muted);
}

/* =========================================================
   Acciones y Formularios
   Botoneras, formularios, paneles en vivo y bloques de
   resumen usados en compras, ventas, gastos y procesos.
   ========================================================= */
.quick-actions,
.actions-row,
.report-tools,
.kpi-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
}

.quick-actions .btn,
.actions-row .btn,
.report-tools .btn {
    flex: 1 1 180px;
}

.actions-row {
    align-items: center;
    justify-content: flex-end;
}

.actions-row form {
    margin: 0;
}

.history-filters-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
    margin-bottom: 0.9rem;
}

.history-filters-actions {
    align-self: end;
    justify-content: flex-end;
}

.history-filters-actions .btn {
    flex: 0 0 auto;
    min-width: 132px;
}

.history-caption {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    margin-bottom: 0.85rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.history-caption strong {
    color: var(--text);
    font-size: 1rem;
}

.document-actions {
    gap: 0.65rem;
}

.document-actions .btn,
.document-actions form {
    flex: 0 0 auto;
}

.document-action-form {
    display: flex;
}

.document-actions .btn {
    min-width: 88px;
}

.btn-pdf {
    background: linear-gradient(135deg, #1d4ed8, #0f766e);
    box-shadow: 0 12px 24px rgba(29, 78, 216, 0.18);
}

.btn-pdf:hover {
    box-shadow: 0 16px 30px rgba(29, 78, 216, 0.22);
}

.btn-danger-soft {
    border: 1px solid rgba(220, 38, 38, 0.14);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(254, 242, 242, 0.98));
    color: #b91c1c;
    box-shadow: none;
}

.btn-danger-soft:hover {
    border-color: rgba(220, 38, 38, 0.24);
    background: linear-gradient(180deg, rgba(254, 242, 242, 1), rgba(255, 228, 230, 0.98));
    box-shadow: 0 10px 18px rgba(220, 38, 38, 0.10);
}

.form {
    display: grid;
    gap: 0.95rem;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
    color: #334155;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.form.two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.col-span-2 {
    grid-column: 1 / -1;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 1rem;
}

.inline-form label {
    min-width: 180px;
    flex: 1 1 180px;
}

.client-search-shell {
    position: relative;
    display: grid;
    gap: 0.65rem;
}

.client-search-shell > label {
    margin: 0;
}

.client-search-panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 18;
    padding: 0.55rem;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.1);
}

.client-search-status {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    margin: 0.1rem 0.1rem 0.55rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.1);
    color: var(--muted);
    font-size: 0.77rem;
    line-height: 1.3;
}

.client-search-results {
    display: grid;
    gap: 0.45rem;
    max-height: 280px;
    overflow-y: auto;
}

.client-option {
    width: 100%;
    padding: 0.82rem 0.9rem;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    text-align: left;
    box-shadow: none;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.client-option:hover {
    border-color: rgba(15, 118, 110, 0.22);
    background: rgba(240, 253, 250, 0.95);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.06);
}

.client-option strong,
.client-option span,
.client-option small {
    display: block;
}

.client-option strong {
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.35;
}

.client-option span {
    margin-top: 0.16rem;
    color: #334155;
    font-size: 0.8rem;
}

.client-option small {
    margin-top: 0.28rem;
    color: var(--muted);
    font-size: 0.76rem;
}

.client-search-selected {
    display: grid;
    gap: 0.35rem;
    padding: 0.82rem 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.96));
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.client-search-selected.is-selected {
    border-color: rgba(15, 118, 110, 0.18);
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(219, 234, 254, 0.52));
    box-shadow: 0 10px 18px rgba(15, 118, 110, 0.08);
}

.client-search-selected-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.client-search-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    color: #475569;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.client-search-selected.is-selected .client-search-badge {
    background: rgba(15, 118, 110, 0.14);
    color: var(--brand-strong);
}

.client-search-clear {
    padding: 0.18rem 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.client-search-clear:hover {
    color: var(--brand-strong);
}

.client-search-selected span,
.client-search-selected strong,
.client-search-selected small {
    display: block;
}

.client-search-selected span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.client-search-selected strong {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.35;
}

.client-search-selected small {
    color: var(--muted);
    line-height: 1.45;
}

.line-items-shell,
.line-items-list {
    display: grid;
    gap: 0.75rem;
}

.line-items-inline,
.line-items-head,
.line-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.85rem;
}

.line-items-head strong,
.line-item-head strong,
.line-items-inline strong,
.line-items-head small,
.line-item-head small,
.line-items-inline small {
    display: block;
}

.line-items-inline small,
.line-items-head small,
.line-item-head small {
    margin-top: 0.18rem;
    color: var(--muted);
    line-height: 1.4;
}

.line-items-summary {
    display: grid;
    gap: 0.7rem;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.98));
}

.line-items-summary-head strong,
.line-items-summary-head small {
    display: block;
}

.line-items-summary-head small {
    margin-top: 0.18rem;
    color: var(--muted);
    line-height: 1.4;
}

.line-items-summary-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.line-summary-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.52rem 0.7rem;
    border: 1px solid rgba(15, 118, 110, 0.14);
    border-radius: 999px;
    background: rgba(240, 253, 250, 0.92);
    color: var(--text);
    font-size: 0.84rem;
    line-height: 1.3;
}

.line-summary-pill strong {
    font-size: 0.84rem;
}

.line-summary-pill span {
    color: var(--muted);
    font-size: 0.78rem;
}

.line-item-card {
    display: grid;
    gap: 0.75rem;
    padding: 0.92rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.98));
    overflow: visible;
}

.line-item-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(0, 1.7fr) minmax(120px, 0.75fr) minmax(140px, 0.9fr) minmax(190px, 1fr);
    align-items: start;
}

.line-item-grid > *,
.line-item-product {
    min-width: 0;
}

.line-item-caption {
    display: inline-block;
    margin-bottom: 0.38rem;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.line-item-identity {
    display: grid;
    gap: 0.22rem;
    min-height: 72px;
    padding: 0.78rem 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
}

.line-item-identity strong,
.line-item-identity small {
    display: block;
}

.line-item-identity strong {
    font-size: 0.92rem;
    line-height: 1.35;
}

.line-item-identity small {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.line-item-product .product-selection-inline {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.22rem 0.65rem;
    align-items: center;
    padding: 0.58rem 0.7rem;
    border-radius: 12px;
}

.line-item-product .product-selection-inline .client-search-badge {
    min-height: 24px;
    padding: 0.18rem 0.55rem;
    font-size: 0.68rem;
}

.line-item-product .product-selection-inline strong {
    font-size: 0.88rem;
    line-height: 1.25;
}

.line-item-product .product-selection-inline small {
    grid-column: 2 / 4;
    margin-top: 0;
    font-size: 0.74rem;
    line-height: 1.35;
}

.line-item-product .product-selection-inline .client-search-clear {
    padding: 0;
    font-size: 0.76rem;
    white-space: nowrap;
}

.line-item-metrics {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.8rem 0.85rem;
    border: 1px solid rgba(15, 118, 110, 0.12);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.07), rgba(219, 234, 254, 0.45));
}

.line-item-metrics span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.line-item-metrics strong {
    display: block;
    margin-top: 0.16rem;
    font-size: 1rem;
}

.modal-card-wide {
    width: min(86vw, 1180px);
    max-width: 100%;
    min-height: 50vh;
    margin: 0 auto;
}

.line-items-modal-card {
    display: grid;
    gap: 1rem;
    max-height: 84vh;
    overflow-x: hidden;
    overflow-y: auto;
}

.line-items-modal-card .line-items-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
}

.line-catalog-shell {
    display: grid;
    gap: 0.7rem;
    padding: 0.95rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.96));
}

.line-catalog-shell > label {
    margin: 0;
}

.line-catalog-status {
    color: var(--muted);
    line-height: 1.4;
}

.line-catalog-results {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    max-height: min(26vh, 280px);
    overflow-y: auto;
}

.line-items-modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.2rem;
}

.line-item-product .client-search-panel {
    z-index: 42;
}

.live-panel,
.stack-list {
    display: grid;
    gap: 0.7rem;
}

.live-panel {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    padding: 1rem;
    border: 1px solid rgba(15, 118, 110, 0.12);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(219, 234, 254, 0.65));
}

.live-panel span,
.stack-row span,
.balance-row span,
.kpi-pill span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.live-panel strong,
.stack-row strong,
.balance-row strong,
.kpi-pill strong {
    display: block;
    margin-top: 0.2rem;
    font-size: 1.1rem;
}

.stack-row,
.balance-row,
.kpi-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.84);
}

.header-summary small,
.kpi-pill small,
.money-stack small,
.balance-row small {
    display: block;
    margin-top: 0.22rem;
    color: var(--muted-soft);
    font-size: 0.78rem;
    line-height: 1.45;
}

.money-stack strong {
    display: block;
}

/* =========================================================
   Dashboard y Analitica
   Hero principal, KPIs, graficos, accesos rapidos y tarjetas
   del panel ejecutivo.
   ========================================================= */
.dashboard {
    display: grid;
    gap: 1.05rem;
}

.dashboard-header {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    justify-content: space-between;
    flex-wrap: wrap;
}

.dashboard-range {
    width: min(560px, 100%);
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.75rem;
    align-items: end;
}

.dashboard-summary {
    margin: 0;
}

.dashboard-grids {
    display: grid;
    grid-template-columns: 1.75fr 1fr;
    gap: 1rem;
}

.dashboard-chart-card {
    gap: 0.75rem;
}

.chart-shell {
    position: relative;
    width: 100%;
    min-height: 320px;
    max-width: 100%;
    overflow: hidden;
}

.chart-shell canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-height: 100%;
}

.chart-shell--composition {
    min-height: 350px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.chart-shell--composition canvas {
    width: min(100%, 420px) !important;
    aspect-ratio: 1 / 1;
    height: auto !important;
    max-height: min(100%, 420px);
}

.dashboard-products {
    margin-bottom: 0.2rem;
}

.dashboard-actions {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-actions .btn {
    width: 100%;
}

.premium-dashboard {
    gap: 1.25rem;
}

.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
    gap: 1rem;
}

.dashboard-hero-main,
.dashboard-hero-side {
    padding: 1.5rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.94) 100%);
    box-shadow: var(--shadow-soft);
}

.dashboard-hero-main {
    background:
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.08), transparent 22%),
        linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.96) 100%);
}

.dashboard-hero-main h2 {
    margin: 0.25rem 0 0.5rem;
    font-size: clamp(2rem, 3vw, 2.6rem);
    line-height: 1.08;
}

.dashboard-hero-main p,
.dashboard-hero-side p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.dashboard-hero-side {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.dashboard-hero-side-head h3 {
    margin: 0.2rem 0 0.35rem;
    font-size: 1.15rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.35rem;
}

.hero-actions .btn {
    flex: 1 1 180px;
}

.hero-note-grid {
    display: grid;
    gap: 0.75rem;
}

.hero-note-item {
    padding: 0.95rem 1rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 14px;
    background: #f8fafc;
}

.hero-note-item span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hero-note-item strong {
    display: block;
    margin-top: 0.35rem;
    color: var(--text);
    font-size: 1rem;
}

.metric-card-premium {
    gap: 0.5rem;
}

.metric-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.metric-card-head span {
    margin-bottom: 0;
}

.metric-card-head small {
    color: var(--muted-soft);
    font-size: 0.78rem;
    white-space: nowrap;
}

.dashboard-grids-main {
    grid-template-columns: 1.5fr 1fr;
}

.dashboard-grids-secondary {
    grid-template-columns: 1.25fr 0.95fr;
}

.chart-shell--compact {
    min-height: 280px;
}

.dashboard-side-card {
    align-content: start;
}

.dashboard-link-list {
    display: grid;
    gap: 0.95rem;
}

.dashboard-link-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 14px;
    background: #f8fafc;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-link-card:hover {
    transform: translateY(-1px);
    border-color: rgba(15, 118, 110, 0.18);
    box-shadow: var(--shadow-soft);
}

.dashboard-link-card strong {
    display: block;
    color: var(--text);
    font-size: 0.96rem;
}

.dashboard-link-card small {
    display: block;
    margin-top: 0.25rem;
    color: var(--muted);
    line-height: 1.5;
}

.dashboard-link-card span {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--brand-strong);
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

.dashboard-link-card--report span {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
}

.text-right {
    text-align: right;
}

.currency-subtitle {
    display: block;
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stack-row small {
    display: block;
    color: var(--muted-soft);
}

/* =========================================================
   Tablas, Badges y Reportes
   Listados tabulares, estados visuales y tarjetas enlazadas
   para reporteria y vistas administrativas.
   ========================================================= */
.table-wrap {
    overflow: auto;
    margin-top: 0.2rem;
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: #ffffff;
}

.table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    background: #ffffff;
}

.table th,
.table td {
    padding: 0.92rem 0.95rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(16, 32, 51, 0.07);
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 0.83rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    background: #f8fafc;
}

.table tbody tr:hover {
    background: #f8fafc;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.34rem 0.7rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.badge-ok {
    color: var(--success);
    background: var(--success-soft);
}

.badge-danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.badge-neutral {
    color: #1d4ed8;
    background: rgba(59, 130, 246, 0.12);
}

.report-card {
    display: block;
    min-height: 100%;
    border: 1px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.report-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.report-card.is-active {
    border-color: rgba(15, 118, 110, 0.28);
    background:
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.12), transparent 28%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(233, 250, 247, 0.9));
    box-shadow: 0 18px 40px rgba(15, 118, 110, 0.12);
}

.report-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.report-card .tag {
    display: inline-flex;
    margin-top: 0.85rem;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.12);
    font-size: 0.78rem;
    font-weight: 700;
}

.balance-total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    text-align: right;
}

/* =========================================================
   Estados, Alertas y Modales
   Mensajes de feedback, vacios de datos y ventanas modales
   del sistema.
   ========================================================= */
.empty-state {
    padding: 1rem;
    border: 1px dashed rgba(16, 32, 51, 0.18);
    border-radius: 18px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.52);
}

.alert {
    margin-bottom: 1rem;
    padding: 0.95rem 1rem;
    border-radius: 16px;
}

.alert.success {
    color: #065f46;
    background: rgba(16, 185, 129, 0.13);
}

.alert.danger {
    color: #991b1b;
    background: rgba(254, 226, 226, 0.92);
}

.modal-shell {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 80;
}

.modal-shell.is-open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 21, 33, 0.6);
    backdrop-filter: blur(6px);
}

.modal-card {
    position: relative;
    width: min(680px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    padding: 1.25rem;
    border-radius: 24px;
    background: var(--surface-strong);
    box-shadow: 0 30px 80px rgba(8, 21, 33, 0.32);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-header h3 {
    margin: 0.15rem 0 0;
}

.modal-close {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(16, 32, 51, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem;
    line-height: 1;
}

/* =========================================================
   Layout Invitado / Login
   Estilos exclusivos para autenticacion y pantalla de acceso.
   ========================================================= */
.guest-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 3vw, 2rem);
    background:
        linear-gradient(rgba(7, 13, 22, 0.38), rgba(7, 13, 22, 0.54)),
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.08), transparent 30%),
        radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.05), transparent 24%),
        url('../img/baco1.jpg') center/cover no-repeat !important;
    font-family: "Inter", "Segoe UI", Roboto, sans-serif;
}

.login-wrapper {
    width: min(980px, 100%);
}

.login-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
    min-height: 620px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 32px;
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(18px);
}

.login-side {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.14), transparent 20%),
        radial-gradient(circle at bottom left, rgba(148, 163, 184, 0.10), transparent 28%),
        linear-gradient(180deg, rgba(15, 23, 42, 0.58), rgba(15, 23, 42, 0.34));
    color: #f8fafc;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.login-side::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 42%);
    pointer-events: none;
}

.login-side-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(2rem, 4vw, 3rem);
}

.login-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.45rem 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.10);
    color: #e2e8f0;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
}

.login-side h1 {
    margin: 1.2rem 0 0.8rem;
    font-size: clamp(2rem, 2.8vw, 2.8rem);
    line-height: 1.04;
    letter-spacing: -0.03em;
    color: #ffffff;
}

.login-lead {
    max-width: 46ch;
    margin: 0 0 1.75rem;
    color: rgba(226, 232, 240, 0.82);
    font-size: 0.98rem;
    line-height: 1.72;
}

.login-feature-list {
    display: grid;
    gap: 0.8rem;
    margin-top: 1.25rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.82rem 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(241, 245, 249, 0.84);
    line-height: 1.45;
}

.feature-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f8fafc;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12);
}

.login-side-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.side-stat {
    padding: 0.95rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.07);
}

.side-stat strong {
    display: block;
    margin-bottom: 0.28rem;
    color: #ffffff;
    font-size: 0.96rem;
    font-weight: 700;
}

.side-stat span {
    color: rgba(226, 232, 240, 0.74);
    font-size: 0.88rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(1.4rem, 3vw, 2.5rem);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 250, 252, 0.84) 100%);
}

.login-form-header {
    margin-bottom: 1.45rem;
}

.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 0.95rem;
}

.login-logo {
    display: block;
    width: clamp(72px, 8vw, 96px);
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 10px 22px rgba(15, 23, 42, 0.10));
}

.form-kicker {
    display: inline-block;
    margin-bottom: 0.6rem;
    color: #0f766e;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.login-form h2 {
    margin: 0 0 0.45rem;
    color: #0f172a;
    font-size: clamp(1.75rem, 2.3vw, 2.2rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.login-form-header p {
    margin: 0;
    color: #64748b;
    font-size: 0.94rem;
    line-height: 1.6;
}

.login-form-fields {
    display: grid;
    gap: 0.9rem;
}

.field {
    display: grid;
    gap: 0.4rem;
}

.field span {
    color: #334155;
    font-size: 0.88rem;
    font-weight: 600;
}

.login-form input {
    width: 100%;
    height: 50px;
    padding: 0 0.95rem;
    border: 1px solid rgba(148, 163, 184, 0.20);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.86);
    color: #0f172a;
    font-size: 0.94rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-sizing: border-box;
}

.login-form input::placeholder {
    color: #97a3b6;
}

.login-form input:focus {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(15, 118, 110, 0.32);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
}

.login-btn {
    height: 52px;
    margin-top: 0.25rem;
    border: none;
    border-radius: 16px;
    background: linear-gradient(180deg, #18212e 0%, #0f172a 100%);
    color: #ffffff;
    font-size: 0.94rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    cursor: pointer;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(15, 23, 42, 0.18);
    opacity: 0.98;
}

.login-btn:active {
    transform: translateY(0);
}

.login-form-note {
    margin: 0.9rem 0 0;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.5;
    text-align: center;
}

.demo-users {
    margin-top: 1.5rem;
    padding: 1.15rem;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #f8fafc;
}

.demo-users strong {
    display: block;
    margin-bottom: 0.9rem;
    color: #0f172a;
    font-size: 0.92rem;
}

.demo-user-grid {
    display: grid;
    gap: 0.8rem;
}

.demo-user-item {
    padding: 0.85rem 0.9rem;
    border-radius: 14px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
}

.demo-role {
    display: inline-block;
    margin-bottom: 0.3rem;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.demo-user-item p {
    margin: 0;
    color: #64748b;
    font-size: 0.93rem;
}

.alert.danger {
    margin-bottom: 1rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid rgba(220, 38, 38, 0.14);
    border-radius: 16px;
    background: rgba(254, 242, 242, 0.92);
    color: #b91c1c;
    font-size: 0.88rem;
}

@media (max-width: 980px) {
    .login-wrapper {
        width: min(460px, 100%);
    }

    .login-card {
        grid-template-columns: 1fr;
        min-height: 78dvh;
        max-width: 460px;
        margin-inline: auto;
    }

    .login-side {
        display: none;
    }

    .login-form {
        padding: 1.55rem;
    }
}

@media (max-width: 576px) {
    .guest-body {
        align-items: center;
        padding: 0.85rem;
    }

    .login-wrapper {
        width: min(100%, 430px);
    }

    .login-card {
        min-height: 80dvh;
        border-radius: 24px;
        background: rgba(255, 255, 255, 0.18);
        box-shadow: 0 20px 44px rgba(15, 23, 42, 0.18);
    }

    .login-form h2 {
        font-size: 1.58rem;
    }

    .login-form {
        flex: 1 1 auto;
        justify-content: center;
        padding: 1.15rem;
    }

    .login-form-header {
        margin-bottom: 1.2rem;
        text-align: center;
    }

    .login-form-header p {
        font-size: 0.9rem;
    }

    .login-logo {
        width: 88px;
    }

    .login-btn,
    .login-form input {
        height: 48px;
    }
}
/* =========================================================
   Impresion y Utilidades
   Reglas para vistas imprimibles y helpers de apoyo.
   ========================================================= */
.quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
}

.float-right {
    float: right;
}

.print-body {
    padding: 1rem;
    background: #edf2f7;
}

.print-actions {
    max-width: 1100px;
    margin: 0 auto 1rem;
    display: flex;
    gap: 0.75rem;
}

.print-container {
    max-width: 1100px;
    margin: 0 auto;
}

.ledger-negative {
    color: var(--danger);
}

.ledger-positive {
    color: var(--success);
}

/* =========================================================
   Responsive
   Ajustes para tablet y movil: sidebar off-canvas, tablas
   apiladas, formularios y espaciados adaptativos.
   ========================================================= */
@media (min-width: 1100px) {
    .process-form-compact {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: start;
    }

    .process-form-compact .col-span-2.form-span-2 {
        grid-column: span 2;
    }
}

@media (max-width: 1240px) {
    .modal-card-wide {
        width: min(88vw, 1040px);
    }

    .line-item-grid {
        grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.85fr) minmax(140px, 0.95fr);
    }

    .line-item-metrics {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1024px) {
    .layout,
    .shell {
        display: block;
    }

    .process-layout,
    .process-layout-single {
        grid-template-columns: 1fr;
    }

    .modal-card-wide {
        width: min(92vw, 920px);
        min-height: 50vh;
    }

    .line-items-modal-card {
        max-height: 86vh;
        padding: 1rem;
        border-radius: 22px;
    }

    .line-item-grid {
        grid-template-columns: minmax(0, 1fr) minmax(110px, 0.85fr) minmax(130px, 0.95fr);
    }

    .line-item-metrics {
        grid-column: 1 / -1;
    }

    .sidebar,
    .shell-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(320px, 84vw);
        padding: 1rem;
        z-index: 80;
        overflow-y: auto;
        transform: translateX(-102%);
        transition: transform 0.24s ease;
        box-shadow: 0 24px 80px rgba(8, 21, 33, 0.34);
    }

    .sidebar-mobile-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        margin-bottom: 0.9rem;
    }

    body.menu-open .sidebar,
    body.menu-open .shell-sidebar {
        transform: translateX(0);
    }

    .nav,
    .nav-modern {
        display: grid;
        grid-auto-flow: row;
        overflow: visible;
        padding-bottom: 0;
    }

    .nav-overlay {
        position: fixed;
        inset: 0;
        z-index: 70;
        background: rgba(8, 21, 33, 0.45);
        backdrop-filter: blur(3px);
    }

    .dashboard-grids {
        grid-template-columns: 1fr;
    }

    .dashboard-hero,
    .dashboard-grids-main,
    .dashboard-grids-secondary {
        grid-template-columns: 1fr;
    }

    .chart-shell--composition {
        min-height: 300px;
    }

    .chart-shell--composition canvas {
        width: min(420px, 100%) !important;
        max-width: 100%;
        max-height: 320px;
    }

    .dashboard-header {
        align-items: stretch;
    }

    .dashboard-range {
        grid-template-columns: 1fr;
        width: 100%;
    }

    body.menu-open .nav-overlay {
        display: block;
    }

    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .header-summary {
        min-width: 0;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

@media (max-width: 900px) {
    .login-card {
        grid-template-columns: 1fr;
    }

    .page-title,
    .page-header,
    .section-head,
    .modal-header {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar,
    .topbar-modern {
        align-items: flex-start;
        padding-right: 1rem;
    }

    .topbar-actions {
        width: auto;
        margin-left: auto;
    }

    .content,
    .content-modern,
    .login-form,
    .login-side {
        padding: 1.15rem;
    }

    .header-summary {
        grid-template-columns: 1fr;
    }

    .modal-card {
        width: 100%;
    }

    .hero-actions .btn {
        flex: 1 1 100%;
    }

    .topbar-logout {
        display: none;
    }

    .sidebar-logout {
        display: block;
    }
}

@media (max-width: 720px) {
    .form.two-cols {
        grid-template-columns: 1fr;
    }

    .btnCompactar{
        display: none !important;
    }

    .form-span-2,
    .form-span-full {
        grid-column: auto;
    }

    .line-items-head,
    .line-item-head,
    .line-item-grid {
        grid-template-columns: 1fr;
        display: grid;
    }

    .line-items-inline {
        display: grid;
        grid-template-columns: 1fr;
    }

    .line-item-metrics {
        grid-template-columns: 1fr 1fr;
    }

    .line-items-inline .btn,
    .line-items-head .btn,
    .line-item-head .btn {
        width: 100%;
    }

    .line-items-modal-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .page-header,
    .header-summary,
    .quick-actions,
    .actions-row,
    .report-tools {
        width: 100%;
    }

    .quick-actions .btn,
    .actions-row .btn,
    .report-tools .btn,
    .section-head .btn {
        width: 100%;
    }

    .history-filters-form {
        grid-template-columns: 1fr;
    }

    .history-filters-actions {
        justify-content: stretch;
    }

    .history-filters-actions .btn {
        flex: 1 1 auto;
    }

    .inline-form label,
    .inline-form .btn {
        width: 100%;
        flex: 1 1 100%;
    }

    .document-actions {
        justify-content: stretch;
    }

    .document-actions .btn,
    .document-actions form {
        flex: 1 1 calc(50% - 0.5rem);
    }

    .document-action-form .btn {
        width: 100%;
    }

    .content,
    .content-modern {
        padding: 1rem 0.85rem 1.2rem;
    }

    .page-header,
    .card,
    .balance-card {
        gap: 0.8rem;
    }

    .card,
    .balance-card,
    .header-summary > div {
        padding: 1rem;
        border-radius: 18px;
    }

    .topbar,
    .topbar-modern {
        padding: 0.95rem 0.85rem;
    }

    .topbar-leading {
        align-items: flex-start;
        width: calc(100% - 58px);
        flex: 1 1 auto;
    }

    .topbar-actions {
        width: auto;
        margin-left: auto;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .table.mobile-cards {
        min-width: 100%;
    }

    .table.mobile-cards thead {
        display: none;
    }

    .table.mobile-cards,
    .table.mobile-cards tbody,
    .table.mobile-cards tr,
    .table.mobile-cards td {
        display: block;
        width: 100%;
    }

    .table.mobile-cards tbody {
        padding: 0.2rem 0;
    }

    .table.mobile-cards tr {
        margin-bottom: 0.9rem;
        border: 1px solid rgba(16, 32, 51, 0.08);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.92);
        overflow: hidden;
        box-shadow: var(--shadow-soft);
    }

    .table.mobile-cards td {
        padding: 0.8rem 0.9rem;
        border-bottom: 1px solid rgba(16, 32, 51, 0.06);
        white-space: normal;
        word-break: break-word;
    }

    .table.mobile-cards td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.35rem;
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .table.mobile-cards td:last-child {
        border-bottom: 0;
    }

    .modal-shell {
        padding: 0.6rem;
        align-items: flex-end;
    }

    .modal-card {
        border-radius: 22px 22px 0 0;
        max-height: 90vh;
    }

    .client-search-panel {
        position: static;
        padding: 0.65rem 0 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .menu-toggle {
        width: 42px;
        height: 42px;
        padding: 0.55rem;
    }

    .stack-row,
    .balance-row,
    .kpi-pill {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* =========================================================
   Navegacion Agrupada
   Version enriquecida del sidebar con grupos, etiquetas y
   bloque informativo final.
   ========================================================= */
.nav-stack {
    display: grid;
    gap: 1rem;
    margin-top: 1.1rem;
}

.nav-group {
    display: grid;
    gap: 0.55rem;
    padding: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.nav-group-title {
    padding: 0 0.3rem;
}

.nav-group-title span {
    display: block;
    color: rgba(147, 197, 253, 0.82);
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.nav-group-title strong {
    display: block;
    margin-top: 0.12rem;
    color: rgba(248, 250, 252, 0.92);
    font-size: 0.92rem;
}

.nav-group-title.is-active strong {
    color: #ffffff;
}

.nav-modern {
    margin-top: 0;
}

.nav-modern a {
    display: block;
    background: rgba(255, 255, 255, 0.03);
}

.nav-label {
    display: block;
    font-weight: 700;
}

.nav-hint {
    display: block;
    margin-top: 0.2rem;
    color: rgba(241, 245, 249, 0.62);
    font-size: 0.78rem;
    line-height: 1.35;
}

.sidebar-footnote {
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-footnote strong {
    display: block;
    color: #f8fafc;
    font-size: 0.98rem;
}

.sidebar-footnote small {
    display: block;
    margin-top: 0.35rem;
    color: rgba(241, 245, 249, 0.68);
    line-height: 1.5;
}

.sidebar-logout {
    display: none;
    margin-top: 0.9rem;
}

.sidebar-logout .btn {
    width: 100%;
}

@media (max-width: 720px) {
    .nav-group-title {
        padding: 0;
    }
}
/* =========================================================
   SHELL SAAS PREMIUM
   Más expresivo, más producto, sin verse recargado
   ========================================================= */

:root {
    --shell-bg:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.10), transparent 24%),
        radial-gradient(circle at 85% 15%, rgba(14, 165, 233, 0.08), transparent 18%),
        radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.06), transparent 20%),
        #f5f7fb;

    --shell-panel: rgba(255, 255, 255, 0.72);
    --shell-panel-strong: rgba(255, 255, 255, 0.94);
    --shell-card: rgba(255, 255, 255, 0.88);

    --shell-border: rgba(15, 23, 42, 0.08);
    --shell-border-strong: rgba(15, 23, 42, 0.14);

    --shell-text: #0f172a;
    --shell-text-soft: #334155;
    --shell-muted: #64748b;

    --shell-primary: #4f46e5;
    --shell-primary-2: #06b6d4;
    --shell-primary-soft: rgba(79, 70, 229, 0.10);
    --shell-primary-soft-2: rgba(6, 182, 212, 0.10);

    --shell-shadow-xs: 0 2px 10px rgba(15, 23, 42, 0.04);
    --shell-shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
    --shell-shadow-md: 0 16px 40px rgba(15, 23, 42, 0.08);
    --shell-shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);

    --shell-radius-xl: 28px;
    --shell-radius-lg: 22px;
    --shell-radius-md: 16px;
    --shell-radius-sm: 12px;
}

/* =========================================================
   Base shell
   ========================================================= */

body.app-shell {
    min-height: 100vh;
    background: var(--shell-bg);
    color: var(--shell-text);
    overflow: hidden;
}

.shell {
    display: flex;
    min-height: 100vh;
    height: 100vh;
    gap: 0;
    position: relative;
    transition: all 0.22s ease;
}

/* =========================================================
   Sidebar
   ========================================================= */

.sidebar,
.shell-sidebar {
    position: relative;
    width: 312px;
    height: 100vh;
    padding: 1.1rem;
    color: var(--shell-text);
    background: rgba(255, 255, 255, 0.42);
    backdrop-filter: blur(18px);
    border-right: 1px solid rgba(255, 255, 255, 0.35);
    box-sizing: border-box;
    overflow: hidden;
    transition: width 0.22s ease, padding 0.22s ease, opacity 0.22s ease;
}

.sidebar::before,
.shell-sidebar::before {
    content: "";
    position: absolute;
    inset: 14px 10px 14px 10px;
    border-radius: 30px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(248, 250, 252, 0.82));
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: var(--shell-shadow-md);
    pointer-events: none;
}

.sidebar-shell {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 1rem;
    min-height: 100%;
    height: 100%;
    align-content: start;
}

.sidebar-content {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 1rem;
    min-height: 0;
    overflow: hidden;
}

/* =========================================================
   Brand
   ========================================================= */

.brand,
.brand-block {
    position: relative;
    display: grid;
    gap: 0.45rem;
    padding: 1.2rem 1.15rem;
    border: 1px solid rgba(79, 70, 229, 0.12);
    border-radius: 24px;
    background:
        radial-gradient(circle at top right, rgba(79, 70, 229, 0.12), transparent 34%),
        radial-gradient(circle at bottom left, rgba(6, 182, 212, 0.10), transparent 38%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
    box-shadow: var(--shell-shadow-sm);
    overflow: hidden;
}

.brand::after,
.brand-block::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.25), transparent);
}

.brand-block[data-app-initials]::before {
    content: attr(data-app-initials);
    display: none;
}

.brand-block h1,
.brand h2 {
    margin: 0;
    font-size: 1.22rem;
    line-height: 1.15;
    font-weight: 750;
    letter-spacing: -0.035em;
    color: var(--shell-text);
}

.brand-block p,
.brand small {
    margin: 0;
    max-width: 24ch;
    color: var(--shell-muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    color: var(--shell-primary);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.10);
}

/* =========================================================
   Navegación agrupada
   ========================================================= */

.nav-stack {
    display: grid;
    gap: 1rem;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.32rem;
    margin-right: -0.18rem;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.38) transparent;
}

.nav-stack::-webkit-scrollbar {
    width: 8px;
}

.nav-stack::-webkit-scrollbar-track {
    background: transparent;
}

.nav-stack::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.22);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.nav-stack::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.34);
    background-clip: padding-box;
}

.nav-group {
    display: grid;
    gap: 0.55rem;
    padding: 0.3rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.34);
    border: 1px solid rgba(255, 255, 255, 0.45);
}

.nav-group-title {
    display: grid;
    gap: 0.12rem;
    padding: 0.2rem 0.45rem 0.05rem;
}

.nav-group-title span {
    display: block;
    color: var(--shell-muted);
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.nav-group-title strong {
    display: block;
    color: var(--shell-text-soft);
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: -0.015em;
    line-height: 1.28;
}

.nav-group-title.is-active strong {
    color: var(--shell-text);
}

/* =========================================================
   Navegación
   ========================================================= */

.nav,
.nav-modern {
    display: grid;
    gap: 0.34rem;
    margin-top: 0;
}

.nav a,
.nav-modern a {
    position: relative;
    display: grid;
    gap: 0.18rem;
    padding: 0.86rem 0.92rem 0.86rem 1rem;
    border: 1px solid transparent;
    border-radius: 16px;
    color: var(--shell-text-soft);
    text-decoration: none;
    background: transparent;
    overflow: hidden;
    transition:
        transform 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        color 0.18s ease;
}

.nav a::before,
.nav-modern a::before {
    content: "";
    position: absolute;
    left: 0.45rem;
    top: 50%;
    width: 4px;
    height: 0;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--shell-primary), var(--shell-primary-2));
    transform: translateY(-50%);
    transition: height 0.18s ease, opacity 0.18s ease;
    opacity: 0;
}

.nav a:hover,
.nav-modern a:hover {
    color: var(--shell-text);
    transform: translateY(-1px);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.92));
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow: var(--shell-shadow-xs);
}

.nav a.is-active,
.nav-modern a.is-active {
    color: var(--shell-text);
    background:
        radial-gradient(circle at 100% 0%, rgba(79, 70, 229, 0.10), transparent 30%),
        linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(244, 247, 255, 1));
    border-color: rgba(79, 70, 229, 0.14);
    box-shadow:
        0 10px 24px rgba(79, 70, 229, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.nav a.is-active::before,
.nav-modern a.is-active::before {
    height: 65%;
    opacity: 1;
}

.nav-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: -0.012em;
    color: inherit;
}

.nav-compact-label {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: rgba(79, 70, 229, 0.08);
    color: var(--shell-text);
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1;
}

.nav-hint {
    display: block;
    color: var(--shell-muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.nav-modern a.is-active .nav-hint {
    color: #5b5ce2;
}

/* =========================================================
   Sidebar footnote
   ========================================================= */

.sidebar-footnote {
    position: relative;
    margin-top: auto;
    display: grid;
    gap: 0.45rem;
    padding: 1rem;
    border-radius: 22px;
    background:
        radial-gradient(circle at top right, rgba(79, 70, 229, 0.08), transparent 36%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.92));
    border: 1px solid var(--shell-border);
    box-shadow: var(--shell-shadow-sm);
}

.sidebar-footnote strong {
    display: block;
    color: var(--shell-text);
    font-size: 1rem;
    letter-spacing: -0.015em;
}

.sidebar-footnote small {
    display: block;
    color: var(--shell-muted);
    line-height: 1.45;
}

.sidebar-logout,
.topbar-logout {
    margin-top: 0.45rem;
}

/* =========================================================
   Main
   ========================================================= */

.main,
.shell-main {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: transparent;
    overflow-y: auto;
}

/* =========================================================
   Topbar
   ========================================================= */

.topbar,
.topbar-modern {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.15rem 1.75rem;
    background: rgba(245, 247, 251, 0.74);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.topbar-leading {
    display: flex;
    align-items: center;
    gap: 0.95rem;
    min-width: 0;
    flex: 1 1 320px;
}

.topbar-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.7rem;
    flex: 0 1 auto;
    margin-left: auto;
}

.topbar-actions form {
    margin: 0;
}

.sidebar-desktop-toggle {
    display: inline-flex;
}

.sidebar-desktop-toggle-icon {
    font-size: 0.92rem;
    line-height: 1;
}

.topbar h1,
.topbar-modern h2 {
    margin: 0.15rem 0 0;
    font-size: 1.48rem;
    font-weight: 760;
    letter-spacing: -0.04em;
    color: var(--shell-text);
}

.topbar small,
.topbar-modern small {
    color: var(--shell-muted);
    font-size: 0.91rem;
}

.topbar-modern .eyebrow,
.topbar .eyebrow {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* =========================================================
   Botones del shell
   ========================================================= */

.btn-outline {
    color: var(--shell-text);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
    border: 1px solid var(--shell-border);
    border-radius: 14px;
    box-shadow: var(--shell-shadow-sm);
    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.btn-outline:hover {
    background: #fff;
    border-color: rgba(79, 70, 229, 0.16);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

/* =========================================================
   Contenido
   ========================================================= */

.content,
.content-modern {
    padding: 1.8rem;
}

.content > * + *,
.content-modern > * + * {
    margin-top: 1.3rem;
}

/* =========================================================
   Alertas del shell
   ========================================================= */

.alert {
    padding: 1rem 1.05rem;
    border-radius: 18px;
    border: 1px solid transparent;
    box-shadow: var(--shell-shadow-xs);
}

.alert.success {
    color: #065f46;
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.16);
}

.alert.danger {
    color: #991b1b;
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.16);
}

/* =========================================================
   Mobile
   ========================================================= */

.menu-toggle {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0.65rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 15px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
    box-shadow: var(--shell-shadow-sm);
}

.menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0;
    border-radius: 999px;
    background: var(--shell-text);
}

.nav-overlay {
    display: none;
}

.sidebar-mobile-bar {
    display: none;
}

.sidebar-mobile-label {
    color: var(--shell-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-mobile-copy {
    display: grid;
    gap: 0.32rem;
    min-width: 0;
}

.sidebar-mobile-copy strong {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 0.38rem 0.7rem;
    border: 1px solid rgba(79, 70, 229, 0.12);
    border-radius: 999px;
    color: var(--shell-text-soft);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 247, 255, 0.94));
    box-shadow: var(--shell-shadow-xs);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--shell-border);
    border-radius: 14px;
    color: var(--shell-text);
    background: rgba(255, 255, 255, 0.90);
    box-shadow: var(--shell-shadow-xs);
    font-size: 1.4rem;
    line-height: 1;
}

@media (min-width: 1025px) {
    body.sidebar-collapsed .shell-sidebar {
        width: 96px;
        padding: 0.9rem 0.75rem;
    }

    body.sidebar-collapsed .shell-sidebar::before {
        inset: 12px 8px;
        border-radius: 24px;
    }

    body.sidebar-collapsed .sidebar-shell {
        gap: 0.85rem;
    }

    body.sidebar-collapsed .brand-block {
        min-height: 68px;
        padding: 0.8rem;
        place-items: center;
        text-align: center;
    }

    body.sidebar-collapsed .brand-block .eyebrow,
    body.sidebar-collapsed .brand-block h1,
    body.sidebar-collapsed .brand-block p,
    body.sidebar-collapsed .nav-group-title,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .nav-hint,
    body.sidebar-collapsed .sidebar-footnote .eyebrow,
    body.sidebar-collapsed .sidebar-footnote strong,
    body.sidebar-collapsed .sidebar-footnote small,
    body.sidebar-collapsed .sidebar-logout {
        display: none;
    }

    body.sidebar-collapsed .brand-block[data-app-initials]::before {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border-radius: 14px;
        background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(6, 182, 212, 0.12));
        color: var(--shell-primary);
        font-size: 1rem;
        font-weight: 800;
        letter-spacing: 0.08em;
    }

    body.sidebar-collapsed .nav-group {
        gap: 0.35rem;
        padding: 0.22rem;
        border-radius: 16px;
    }

    body.sidebar-collapsed .nav-modern a {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 46px;
        padding: 0.5rem;
        border-radius: 14px;
    }

    body.sidebar-collapsed .nav-modern a::before {
        left: 50%;
        top: auto;
        bottom: 5px;
        width: 22px;
        height: 4px;
        transform: translateX(-50%);
    }

    body.sidebar-collapsed .nav-modern a.is-active::before {
        height: 4px;
        opacity: 1;
    }

    body.sidebar-collapsed .nav-compact-label {
        display: inline-flex;
    }

    body.sidebar-collapsed .sidebar-footnote {
        min-height: 52px;
        padding: 0.55rem;
        place-items: center;
    }
}

@media (max-width: 1024px) {
    .shell {
        display: block;
        height: auto;
    }

    .sidebar,
    .shell-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(330px, 86vw);
        height: 100dvh;
        padding: 1rem;
        z-index: 80;
        overflow-y: auto;
        transform: translateX(-104%);
        transition: transform 0.24s ease;
        box-shadow: var(--shell-shadow-lg);
        background: rgba(248, 250, 252, 0.96);
    }

    .sidebar::before,
    .shell-sidebar::before {
        content: none;
    }

    body.menu-open .sidebar,
    body.menu-open .shell-sidebar {
        transform: translateX(0);
    }

    .sidebar-mobile-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        margin-bottom: 0.55rem;
        padding: 0.15rem 0 0.8rem;
        position: relative;
        z-index: 1;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    }

    .nav-overlay {
        position: fixed;
        inset: 0;
        z-index: 70;
        background: rgba(8, 21, 33, 0.32);
        backdrop-filter: blur(4px);
    }

    body.menu-open .nav-overlay {
        display: block;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .sidebar-desktop-toggle {
        display: none;
    }
}

@media (max-width: 720px) {
    .topbar,
    .topbar-modern {
        padding: 0.95rem 0.9rem;
    }

    .content,
    .content-modern {
        padding: 1rem 0.9rem 1.2rem;
    }

    .topbar h1,
    .topbar-modern h2 {
        font-size: 1.22rem;
    }

    .topbar-logout {
        display: none;
    }

    .sidebar-logout {
        display: block;
    }
}

/* =========================================================
   Sidebar Mobile Fix
   Evita superposicion entre marca, grupos de menu y pie del
   sidebar en pantallas pequenas.
   ========================================================= */

.sidebar-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-content {
    flex: 1 1 auto;
    min-height: 0;
}

.nav-stack {
    min-height: 0;
}

.sidebar-footnote {
    flex-shrink: 0;
}

@media (max-width: 1024px) {
    .sidebar,
    .shell-sidebar {
        height: 100dvh;
        max-height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        padding: max(0.95rem, env(safe-area-inset-top)) 0.95rem max(0.95rem, env(safe-area-inset-bottom));
        -webkit-overflow-scrolling: touch;
        
    }


  
       
    

    .sidebar-shell {
        height: auto;
        min-height: auto;
        gap: 0.8rem;
        max-height: none;
        background: transparent;
    }

    .sidebar-mobile-bar {
        position: sticky;
        top: 0;
        margin-bottom: 0;
        justify-content: flex-end;
        padding: 0 0 0.45rem;
        background: transparent;
        backdrop-filter: none;
        border-bottom: 0;
        
    }

    .brand-block {
        padding: 1rem 1rem 0.95rem;
        border-radius: 20px;
    }

    .sidebar-content {
        flex: 0 0 auto;
        grid-template-rows: auto auto;
        gap: 0.75rem;
        min-height: 0;
        overflow: visible;
    }

    .nav-stack {
        flex: 0 0 auto;
        overflow: visible;
        padding: 0;
        margin: 0;
        scrollbar-gutter: auto;
    }

    .sidebar-footnote {
        margin-top: 0;
        position: relative;
        z-index: 1;
        padding: 0.9rem 0.95rem;
        border-radius: 18px;
    }

    .nav-group {
        gap: 0.32rem;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .nav-group + .nav-group {
        margin-top: 0.2rem;
        padding-top: 0.85rem;
        border-top: 1px solid rgba(15, 23, 42, 0.08);
    }

    .nav-modern a {
        min-height: 58px;
    }
}

@media (max-width: 720px) {
    .sidebar,
    .shell-sidebar {
        width: min(360px, 92vw);
        padding: max(0.8rem, env(safe-area-inset-top)) 0.8rem max(0.8rem, env(safe-area-inset-bottom));
    }

    .sidebar-mobile-bar {
        padding-bottom: 0.35rem;
    }

    .nav-stack {
        gap: 0.7rem;
    }

    .nav-group {
        gap: 0.28rem;
    }

    .nav-group-title {
        gap: 0.18rem;
        padding: 0.1rem 0.2rem 0.4rem;
    }

    .nav-group-title strong {
        font-size: 0.9rem;
        line-height: 1.32;
    }

    .nav-modern {
        margin-top: 0;
    }

    .nav-modern a {
        gap: 0.12rem;
        min-height: 54px;
        padding: 0.82rem 0.82rem 0.82rem 0.92rem;
        border-radius: 14px;
    }

    .nav-hint {
        font-size: 0.74rem;
        line-height: 1.3;
    }

    .sidebar-footnote {
        padding: 0.82rem 0.85rem;
        border-radius: 18px;
    }

    .brand-block p,
    .sidebar-footnote small {
        font-size: 0.84rem;
    }
}

@media (max-width: 480px) {
    .brand-block {
        padding: 0.92rem 0.9rem;
        border-radius: 18px;
    }

    .brand-block h1 {
        font-size: 1.08rem;
    }

    .brand-block p {
        max-width: none;
        font-size: 0.82rem;
        line-height: 1.38;
    }

    .nav-group-title strong {
        font-size: 0.88rem;
        line-height: 1.28;
    }

    .nav-hint {
        display: none;
    }

    .nav-modern a {
        padding: 0.82rem 0.8rem 0.82rem 0.92rem;
    }

    .sidebar-mobile-copy strong {
        font-size: 0.92rem;
    }
}
