/* =========================================================
   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);
}

/* Los decimales marcados como manuales no deben mostrar controles nativos. */
input[data-manual-decimal-input] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[data-manual-decimal-input]::-webkit-outer-spin-button,
input[data-manual-decimal-input]::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

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;
}

.invoice-workbench {
    display: grid;
    gap: 1rem;
}

.invoice-panel {
    display: grid;
    gap: 0.9rem;
    min-width: 0;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
}

.invoice-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.invoice-panel-head h4 {
    margin: 0;
    font-size: 1rem;
}

.invoice-panel-head p {
    margin: 0.22rem 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.invoice-panel-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--brand-strong);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.invoice-meta-grid {
    display: grid;
    gap: 0.75rem 0.85rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.invoice-workbench-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.95fr);
    align-items: start;
}

.invoice-summary-stage,
.invoice-workbench-notes,
.invoice-workbench-submit {
    grid-column: 1 / -1;
}

.invoice-panel-items {
    overflow: hidden;
}

.invoice-panel-items .line-item-card {
    padding: 0.85rem;
    border-radius: 16px;
}

.invoice-panel-items .line-item-grid {
    grid-template-columns: minmax(0, 1.85fr) minmax(92px, 0.62fr) minmax(138px, 0.82fr) minmax(170px, 0.86fr);
}

.line-catalog-shell-inline {
    padding: 0.88rem 0.95rem;
}

.invoice-items-summary {
    background: linear-gradient(135deg, rgba(240, 253, 250, 0.88), rgba(239, 246, 255, 0.92));
}

.invoice-line-items-list {
    max-height: min(56vh, 720px);
    overflow-y: auto;
    padding-right: 0.25rem;
}

.invoice-panel-checkout {
    position: sticky;
    top: 1rem;
}

.invoice-checkout-fields {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.invoice-quick-cash {
    display: grid;
    gap: 0.7rem;
    padding: 0.9rem 0.95rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(241, 245, 249, 0.92));
}

.invoice-quick-cash-head strong,
.invoice-quick-cash-head small {
    display: block;
}

.invoice-quick-cash-head small {
    margin-top: 0.18rem;
    color: var(--muted);
    line-height: 1.45;
}

.invoice-quick-cash-grid {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.invoice-quick-cash-grid-amounts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.invoice-quick-cash .btn {
    min-height: 40px;
}

.invoice-total-board {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 1rem;
    min-height: clamp(320px, 42vh, 560px);
}

.invoice-total-board-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    min-height: 0;
    padding: 0.95rem 1.05rem;
    border: 1px solid rgba(15, 118, 110, 0.16);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(219, 234, 254, 0.82));
}

.invoice-total-board-hero-copy {
    display: grid;
    gap: 0.16rem;
    min-width: 0;
}

.invoice-total-board-hero-copy span,
.invoice-total-board-hero-copy small {
    display: block;
}

.invoice-total-board-hero strong {
    font-size: 1.6rem;
    line-height: 1.05;
    text-align: right;
    white-space: nowrap;
}

.invoice-total-board-hero-copy small {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.invoice-total-board-metrics {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.55rem;
}

.invoice-total-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    min-width: 0;
    padding: 0.78rem 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.76);
}

.invoice-total-stat span {
    color: var(--muted);
}

.invoice-total-stat strong {
    font-size: 1.04rem;
    text-align: right;
    flex-shrink: 0;
}

.invoice-advanced-notes {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.9);
}

.invoice-advanced-notes summary {
    cursor: pointer;
    list-style: none;
    padding: 0.9rem 1rem;
    font-weight: 700;
}

.invoice-advanced-notes summary::-webkit-details-marker {
    display: none;
}

.invoice-advanced-grid {
    display: grid;
    gap: 0.8rem;
    padding: 0 1rem 1rem;
}

.invoice-submit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    padding: 0.95rem 1rem;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.04), rgba(15, 118, 110, 0.08));
}

.invoice-submit-bar strong,
.invoice-submit-bar small {
    display: block;
}

.invoice-submit-bar small {
    margin-top: 0.2rem;
    color: var(--muted);
    line-height: 1.45;
}

.invoice-submit-bar .btn {
    min-width: 220px;
}

@media (max-width: 1180px) {
    .invoice-workbench-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .invoice-panel-checkout {
        position: static;
    }

    .invoice-meta-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .invoice-meta-grid,
    .invoice-checkout-fields,
    .invoice-panel-items .line-item-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .invoice-total-board-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .invoice-panel-items .line-item-grid > :first-child,
    .invoice-panel-items .line-item-grid > :last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .invoice-meta-grid,
    .invoice-checkout-fields,
    .invoice-panel-items .line-item-grid,
    .invoice-advanced-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .invoice-quick-cash-grid,
    .invoice-quick-cash-grid-amounts {
        grid-template-columns: minmax(0, 1fr);
    }

    .invoice-total-board-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .invoice-total-board-hero strong {
        text-align: left;
        white-space: normal;
    }

    .invoice-total-board {
        min-height: 0;
    }

    .invoice-total-board-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .invoice-panel-head,
    .invoice-submit-bar,
    .invoice-section-head {
        flex-direction: column;
        align-items: stretch;
    }

    .invoice-submit-bar .btn {
        width: 100%;
        min-width: 0;
    }

    .invoice-total-board-hero strong {
        font-size: 1.45rem;
    }
}

@media (max-width: 520px) {
    .invoice-total-board-metrics {
        grid-template-columns: minmax(0, 1fr);
    }
}

.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;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 0.9rem;
}

.table-pagination-meta {
    color: var(--muted);
    font-size: 0.86rem;
}

.table-pagination-pages {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.table-pagination-button {
    min-width: 44px;
}

.table-pagination-button.is-active {
    border-color: rgba(15, 118, 110, 0.22);
    background: rgba(15, 118, 110, 0.1);
    color: var(--brand-strong);
}

.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;
    flex-wrap: wrap;
}

.line-items-inline > :first-child,
.line-items-head > :first-child,
.line-item-head > :first-child {
    flex: 1 1 220px;
    min-width: 0;
}

.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;
    overflow-wrap: anywhere;
}

.line-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    flex: 0 0 auto;
    max-width: 100%;
}

.line-item-quick-qty {
    display: grid;
    gap: 0.18rem;
    min-width: 164px;
    max-width: 100%;
}

.line-item-quick-qty span {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.line-item-quick-qty-controls {
    display: grid;
    grid-template-columns: 34px minmax(72px, 1fr) 34px;
    gap: 0.35rem;
    align-items: center;
}

.line-item-quick-qty-btn {
    min-height: 36px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.line-item-quick-qty-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(15, 118, 110, 0.28);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.line-item-quick-qty-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.line-item-quick-qty-input {
    width: 100%;
    min-width: 0;
    padding: 0.52rem 0.58rem;
    text-align: center;
    font-weight: 700;
}

.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-card.is-collapsed {
    gap: 0.35rem;
}

.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[hidden] {
    display: none;
}

.line-item-grid > *,
.line-item-product {
    min-width: 0;
}

.line-item-grid > label {
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
    margin: 0;
    color: #334155;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.line-item-grid > label > span {
    display: inline-block;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
    word-break: break-word;
}

.line-item-grid > label > small {
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.35;
}

.import-shell {
    display: grid;
    gap: 1.25rem;
}

.import-intro {
    display: grid;
    gap: 0.75rem;
}

.import-intro p {
    margin: 0;
    color: var(--text, #0f172a);
    font-size: 0.92rem;
    line-height: 1.45;
}

.import-intro .actions-row {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
}

.import-file-name {
    color: var(--muted);
    font-size: 0.84rem;
    align-self: center;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.import-status {
    display: block;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    border: 1px dashed rgba(148, 163, 184, 0.45);
    background: rgba(248, 250, 252, 0.7);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.import-status[data-tone="ok"] {
    border-style: solid;
    border-color: rgba(15, 118, 110, 0.35);
    background: rgba(15, 118, 110, 0.08);
    color: var(--brand-strong);
}

.import-status[data-tone="danger"] {
    border-style: solid;
    border-color: rgba(220, 38, 38, 0.45);
    background: rgba(254, 226, 226, 0.55);
    color: #b91c1c;
}

.import-mapping,
.import-preview {
    display: grid;
    gap: 0.55rem;
    padding: 1rem 1.1rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.85));
}

.import-mapping h4,
.import-preview-head h4 {
    margin: 0;
    font-size: 0.98rem;
    color: var(--brand-strong);
}

.import-mapping > p {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    border: 0;
    background: transparent;
    padding: 0;
}

.import-mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.65rem;
    margin-top: 0.25rem;
}

.import-mapping-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 10px;
    background: rgba(248, 250, 252, 0.6);
    font-size: 0.82rem;
}

.import-mapping-field > span {
    display: block;
    color: var(--brand-strong);
    font-weight: 700;
    font-size: 0.84rem;
}

.import-mapping-field > span small {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-weight: 400;
    font-size: 0.72rem;
}

.import-mapping-field .import-required {
    color: #b91c1c;
    font-style: normal;
    margin-left: 0.2rem;
}

.import-mapping-field select {
    min-height: 32px;
    padding: 0.3rem 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 8px;
    background: #fff;
    font-size: 0.82rem;
}

.import-preview-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.import-preview-head small {
    color: var(--muted);
    font-size: 0.8rem;
}

.import-preview-wrap {
    max-height: 360px;
    overflow: auto;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
}

.import-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.import-preview-table th,
.import-preview-table td {
    padding: 0.45rem 0.55rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    text-align: left;
    white-space: nowrap;
}

.import-preview-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    color: var(--brand-strong);
    z-index: 1;
    font-weight: 700;
}

.import-preview-table tr.import-row-error {
    background: rgba(254, 226, 226, 0.6);
}

.import-actions {
    justify-content: flex-end;
    gap: 0.55rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    margin-top: 0.25rem;
}

.import-actions .btn {
    min-width: 140px;
}

.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(92vw, 1240px);
    max-width: 100%;
    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));
}

.inventory-report-section-head {
    display: block;
    margin-bottom: 0.85rem;
}

.inventory-report-section-head .section-head-copy {
    max-width: none;
}

.inventory-category-card .table-wrap {
    margin-top: 0;
}

.inventory-category-strip {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.inventory-category-strip .kpi-pill {
    min-height: 100%;
}

.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-wrap-scrollable {
    max-height: min(62vh, 720px);
    overflow: auto;
    overscroll-behavior: contain;
}

.production-recipes-scroll {
    max-height: min(56vh, 560px);
    overflow: auto;
    overscroll-behavior: contain;
}

.production-recipes-card {
    grid-template-rows: auto auto minmax(0, 1fr);
    max-height: min(76vh, 760px);
    min-height: 0;
}

.production-recipes-card .catalog-toolbar {
    margin-bottom: 0;
}

.production-recipes-card .production-recipes-scroll {
    max-height: none;
    min-height: 0;
    height: 100%;
}

.catalog-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.catalog-search {
    flex: 1 1 320px;
    display: grid;
    gap: 0.38rem;
    max-width: 420px;
}

.catalog-search span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.catalog-results {
    flex: 0 0 auto;
    padding: 0.82rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
}

.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;
}

.document-products-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    gap: 0.7rem;
}

.document-products-summary > div {
    min-width: 0;
}

.document-products-summary span {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.document-products-summary strong {
    display: block;
    margin-top: 0.16rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.document-products-table {
    min-width: 560px;
    table-layout: fixed;
}

.document-products-table th:first-child,
.document-products-table td:first-child {
    width: 44%;
}

.document-products-table th:nth-child(2),
.document-products-table td:nth-child(2) {
    width: 16%;
}

.document-products-table th:nth-child(3),
.document-products-table td:nth-child(3),
.document-products-table th:nth-child(4),
.document-products-table td:nth-child(4) {
    width: 20%;
}

.document-products-table td {
    overflow-wrap: anywhere;
}

.document-products-table td:nth-child(2),
.document-products-table td:nth-child(3),
.document-products-table td:nth-child(4) {
    white-space: nowrap;
}

.document-products-notes p {
    margin: 0.25rem 0 0;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.table-empty-state td {
    padding: 1.25rem 1rem;
    text-align: center;
    color: var(--muted);
    background: rgba(248, 250, 252, 0.92);
}

.is-filter-hidden {
    display: none !important;
}

.is-pagination-hidden {
    display: none !important;
}

.purchase-history-filters {
    margin-bottom: 1rem;
}

.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;
    width: 100vw;
    min-height: 100dvh;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
    isolation: isolate;
    z-index: 120;
}

.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;
    z-index: 1;
    width: min(760px, 100%);
    max-height: calc(100vh - 2.5rem);
    overflow: auto;
    padding: 1.75rem 1.85rem;
    border-radius: 24px;
    background: var(--surface-strong);
    box-shadow: 0 30px 80px rgba(8, 21, 33, 0.32);
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

.modal-header h3 {
    margin: 0.15rem 0 0;
    font-size: 1.18rem;
    line-height: 1.25;
}

.modal-header .eyebrow {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.12);
    color: var(--brand-strong);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.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(94vw, 920px);
    }

    .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: 0.55rem 0.9rem 0.9rem;
    }

    .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) {
    .catalog-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .catalog-search,
    .catalog-results {
        max-width: none;
        width: 100%;
    }

    .purchase-history-filters .history-filters-actions {
        width: 100%;
    }

    .table-wrap-scrollable {
        max-height: none;
    }

    .production-recipes-scroll {
        max-height: min(62vh, 480px);
    }

    .production-recipes-card {
        max-height: min(74vh, 640px);
    }

    .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-quick-qty {
        width: 100%;
        min-width: 0;
    }

    .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;
    }

    .line-item-head {
        align-items: stretch;
    }

    .line-item-actions {
        width: 100%;
    }

    .line-item-actions .line-item-quick-qty {
        width: 100%;
    }

    .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: 0.5rem 0.7rem 0.9rem;
    }

    .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-wrap-mobile-slider {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        border: 1px solid rgba(226, 232, 240, 0.9);
        background: #ffffff;
        scrollbar-gutter: stable both-edges;
    }

    .table-wrap-mobile-slider.table-wrap-scrollable {
        overflow-y: auto;
    }

    .table-wrap-mobile-slider .table {
        width: max-content;
        min-width: 100%;
    }

    .table-wrap-mobile-slider .table.mobile-cards {
        min-width: 760px;
    }

    .table-wrap-mobile-slider .table.mobile-cards thead {
        display: table-header-group;
    }

    .table-wrap-mobile-slider .table.mobile-cards,
    .table-wrap-mobile-slider .table.mobile-cards tbody,
    .table-wrap-mobile-slider .table.mobile-cards tr {
        display: table;
        width: auto;
    }

    .table-wrap-mobile-slider .table.mobile-cards tbody {
        display: table-row-group;
        padding: 0;
    }

    .table-wrap-mobile-slider .table.mobile-cards tr {
        display: table-row;
        margin-bottom: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .table-wrap-mobile-slider .table.mobile-cards td,
    .table-wrap-mobile-slider .table.mobile-cards th {
        display: table-cell;
        width: auto;
    }

    .table-wrap-mobile-slider .table.mobile-cards td {
        white-space: nowrap;
    }

    .table-wrap-mobile-slider .table.mobile-cards td::before {
        content: none;
        display: none;
    }

    .table-wrap-mobile-slider .table.mobile-cards td:last-child {
        border-bottom: 1px solid rgba(16, 32, 51, 0.07);
    }

    .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;
        padding: 1.15rem 1.1rem 1.25rem;
        gap: 0.9rem;
    }

    .import-mapping,
    .import-preview {
        padding: 0.85rem 0.9rem;
    }

    .import-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .import-actions .btn {
        width: 100%;
    }

    .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: #eef1f5;

    --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;

    /* Sidebar operacional */
    --shell-sidebar-bg: #f8fafc;
    --shell-sidebar-border: rgba(15, 23, 42, 0.10);

    --shell-primary: #0f766e;
    --shell-primary-2: #0d9488;
    --shell-primary-soft: rgba(15, 118, 110, 0.10);
    --shell-primary-soft-2: rgba(13, 148, 136, 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: 268px;
    height: 100vh;
    padding: 0.85rem 0.7rem;
    color: var(--shell-text);
    background: var(--shell-sidebar-bg);
    border-right: 1px solid var(--shell-sidebar-border);
    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: none;
}

.sidebar-shell {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 0.55rem;
    min-height: 100%;
    height: 100%;
    align-content: start;
}

.sidebar-content {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.6rem;
    min-height: 0;
    overflow: hidden;
}

/* =========================================================
   Brand
   ========================================================= */

.brand,
.brand-block {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.6rem;
    border: 0;
    border-bottom: 1px solid var(--shell-sidebar-border);
    border-radius: 0;
    background: transparent;
    overflow: hidden;
}

.brand-block[data-app-initials]::before {
    content: attr(data-app-initials);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--shell-primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

.brand-block .eyebrow {
    display: none;
}

.brand-block h1,
.brand h2 {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--shell-text);
}

.brand-block p,
.brand small {
    display: none;
}

.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.15rem;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: 0;
}

.nav-group-title {
    display: block;
    padding: 0.2rem 0.7rem 0.3rem;
}

.nav-group-title span {
    display: block;
    color: var(--shell-muted);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.nav-group-title strong {
    display: none;
}

.nav-group-title.is-active strong {
    color: var(--shell-text);
}

/* =========================================================
   Navegación
   ========================================================= */

.nav,
.nav-modern {
    display: grid;
    gap: 0.1rem;
    margin-top: 0;
}

.nav a,
.nav-modern a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.7rem;
    border: 0;
    border-radius: 8px;
    color: var(--shell-text-soft);
    text-decoration: none;
    background: transparent;
    overflow: hidden;
    transition:
        background 0.15s ease,
        color 0.15s ease;
}

.nav a::before,
.nav-modern a::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 0;
    border-radius: 0 3px 3px 0;
    background: var(--shell-primary);
    transform: translateY(-50%);
    transition: height 0.15s ease;
}

.nav-ic {
    flex: 0 0 auto;
    width: 18px;
    font-size: 1rem;
    line-height: 1;
    color: var(--shell-muted);
    text-align: center;
    transition: color 0.15s ease;
}

.nav a:hover,
.nav-modern a:hover {
    color: var(--shell-text);
    background: rgba(15, 23, 42, 0.05);
}

.nav a:hover .nav-ic,
.nav-modern a:hover .nav-ic {
    color: var(--shell-text-soft);
}

.nav a.is-active,
.nav-modern a.is-active {
    color: var(--shell-primary);
    font-weight: 600;
    background: var(--shell-primary-soft);
}

.nav a.is-active .nav-ic,
.nav-modern a.is-active .nav-ic {
    color: var(--shell-primary);
}

.nav a.is-active::before,
.nav-modern a.is-active::before {
    height: 60%;
}

.nav-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-modern a.is-active .nav-label {
    font-weight: 600;
}

.nav-compact-label {
    display: none;
}

.nav-hint {
    display: none;
}

/* =========================================================
   Sidebar footnote
   ========================================================= */

.sidebar-footnote {
    position: relative;
    margin-top: auto;
    display: grid;
    gap: 0.35rem;
    padding: 0.5rem 0.4rem 0.2rem;
    border-radius: 0;
    background: transparent;
    border: 0;
    border-top: 1px solid var(--shell-sidebar-border);
}

.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: 0.6rem;
    padding: 0.35rem 1rem;
    min-height: 0;
    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;
}

.topbar-leading-minimal {
    flex: 0 0 auto;
    min-width: auto;
}

.topbar-trailing {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

.alert-center {
    position: relative;
}

.alert-center--brand {
    margin-left: auto;
    flex: 0 0 auto;
}

.alert-center-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.32);
    background: rgba(255, 255, 255, 0.85);
    color: #1f2937;
    font-size: 1.15rem;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.alert-center--brand .alert-center-trigger {
    width: 32px;
    height: 32px;
    font-size: 0.98rem;
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(79, 70, 229, 0.22);
    color: var(--shell-text, #1f2937);
}

.alert-center-trigger:hover {
    background: #fff;
    border-color: rgba(15, 118, 110, 0.45);
    color: var(--brand-strong, #0f766e);
    transform: translateY(-1px);
}

.alert-center--brand .alert-center-trigger:hover {
    border-color: rgba(79, 70, 229, 0.55);
    color: #4338ca;
}

.alert-center-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(245, 247, 251, 0.95);
    animation: alert-center-pulse 2.2s ease-in-out infinite;
}

.alert-center--brand .alert-center-badge {
    top: -3px;
    right: -3px;
    min-width: 16px;
    height: 16px;
    font-size: 0.62rem;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
}

@keyframes alert-center-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(245, 247, 251, 0.95), 0 0 0 0 rgba(220, 38, 38, 0.45); }
    50% { box-shadow: 0 0 0 2px rgba(245, 247, 251, 0.95), 0 0 0 6px rgba(220, 38, 38, 0); }
}

.alert-center-trigger[data-seen="1"] .alert-center-badge {
    display: none;
}

body.sidebar-collapsed .alert-center--brand {
    display: none;
}

.alert-center-panel {
    position: fixed;
    width: min(380px, 92vw);
    max-height: min(70vh, 540px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 22px 60px rgba(8, 21, 33, 0.18);
    z-index: 1080;
}

.alert-center-panel[hidden] {
    display: none;
}

.alert-center-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0.85rem 1rem 0.55rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.alert-center-head strong {
    color: var(--brand-strong, #0f766e);
    font-size: 0.92rem;
}

.alert-center-head span {
    color: var(--muted, #64748b);
    font-size: 0.78rem;
}

.alert-center-body {
    overflow-y: auto;
    padding: 0.35rem 0 0.55rem;
}

.alert-center-group {
    padding: 0.55rem 0.85rem 0.3rem;
}

.alert-center-group + .alert-center-group {
    border-top: 1px dashed rgba(148, 163, 184, 0.22);
}

.alert-center-group header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.35rem;
    color: #334155;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.alert-center-group header i {
    color: var(--brand-strong, #0f766e);
}

.alert-center-count {
    margin-left: auto;
    padding: 0.06rem 0.45rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--brand-strong, #0f766e);
    font-size: 0.7rem;
}

.alert-center-group ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.2rem;
}

.alert-center-item a {
    display: flex;
    gap: 0.55rem;
    padding: 0.5rem 0.55rem;
    border-radius: 10px;
    color: #1f2937;
    text-decoration: none;
    transition: background 0.16s ease;
}

.alert-center-item a:hover {
    background: rgba(15, 118, 110, 0.06);
}

.alert-center-item strong {
    display: block;
    font-size: 0.85rem;
    line-height: 1.25;
}

.alert-center-item small {
    display: block;
    color: var(--muted, #64748b);
    font-size: 0.75rem;
    margin-top: 0.15rem;
    line-height: 1.35;
}

.alert-center-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #94a3b8;
    margin-top: 0.42rem;
    flex: 0 0 auto;
}

.alert-center-item--critical .alert-center-dot {
    background: #dc2626;
}

.alert-center-item--warning .alert-center-dot {
    background: #d97706;
}

.alert-center-item--info .alert-center-dot {
    background: #2563eb;
}

.alert-center-empty {
    display: grid;
    place-items: center;
    gap: 0.45rem;
    padding: 1.8rem 1rem;
    color: var(--muted, #64748b);
    text-align: center;
}

.alert-center-empty i {
    font-size: 2rem;
    color: var(--brand-strong, #0f766e);
}

.alert-center-empty p {
    margin: 0;
    font-size: 0.85rem;
}

.alert-center-foot {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(248, 250, 252, 0.6);
    font-size: 0.78rem;
}

.alert-center-foot a {
    color: var(--brand-strong, #0f766e);
    text-decoration: none;
    font-weight: 600;
}

.alert-center-foot a:hover {
    text-decoration: underline;
}

@media (max-width: 540px) {
    .alert-center-panel {
        width: calc(100vw - 1.5rem);
    }
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(79, 70, 229, 0.12);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 247, 255, 0.96));
    box-shadow: var(--shell-shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.user-menu-trigger:hover {
    transform: translateY(-1px);
    border-color: rgba(79, 70, 229, 0.2);
    box-shadow: 0 14px 24px rgba(15, 23, 42, 0.1);
}

.user-menu-trigger[aria-expanded="true"] {
    border-color: rgba(79, 70, 229, 0.26);
    box-shadow: 0 16px 28px rgba(79, 70, 229, 0.12);
}

.user-menu-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 14px;
    background: linear-gradient(135deg, #4f46e5, #0891b2);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1;
}

.user-menu-avatar-lg {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 1rem;
}

.user-menu-panel {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    z-index: 40;
    display: grid;
    gap: 0.95rem;
    width: min(320px, calc(100vw - 2rem));
    padding: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: 22px;
    background:
        radial-gradient(circle at top right, rgba(79, 70, 229, 0.08), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(248, 250, 252, 0.97));
    box-shadow: 0 22px 50px rgba(15, 23, 42, 0.12);
    transform-origin: top right;
    animation: shellFadeUp 0.18s ease;
}

.user-menu-panel[hidden] {
    display: none;
}

@keyframes shellFadeUp {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-menu-profile {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.85rem;
    align-items: center;
}

.user-menu-profile strong,
.user-menu-profile small {
    display: block;
}

.user-menu-profile strong {
    color: var(--shell-text);
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.user-menu-profile small {
    margin-top: 0.2rem;
    color: var(--shell-muted);
    line-height: 1.4;
}

.user-menu-meta {
    display: grid;
    gap: 0.7rem;
    padding: 0.9rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 18px;
    background: rgba(248, 250, 252, 0.85);
}

.user-menu-meta span,
.user-menu-meta strong {
    display: block;
}

.user-menu-meta span {
    color: var(--shell-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.user-menu-meta strong {
    margin-top: 0.18rem;
    color: var(--shell-text);
    font-size: 0.95rem;
    line-height: 1.35;
}

.user-menu-logout {
    margin: 0;
}

.user-menu-logout .btn {
    width: 100%;
}

.sidebar-desktop-toggle {
    display: inline-flex;
}

.sidebar-footnote .sidebar-desktop-toggle:not(.sidebar-icon-btn) {
    width: 100%;
    min-width: 0;
    min-height: 28px;
    padding: 0.22rem 0.5rem;
    border-radius: 8px;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    justify-content: center;
    color: var(--shell-muted);
    border-color: rgba(148, 163, 184, 0.3);
    background: transparent;
}

.sidebar-desktop-toggle-icon {
    font-size: 0.95rem;
    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: 0.5rem 1rem 1rem;
}

.content > * + *,
.content-modern > * + * {
    margin-top: 0.7rem;
}

/* =========================================================
   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: 72px;
        padding: 0.85rem 0.55rem;
    }

    body.sidebar-collapsed .sidebar-shell {
        gap: 0.85rem;
    }

    body.sidebar-collapsed .brand-block {
        min-height: 0;
        padding: 0.45rem;
        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: 10px;
        background: var(--shell-primary);
        color: #fff;
        font-size: 1rem;
        font-weight: 800;
        letter-spacing: 0.08em;
    }

    body.sidebar-collapsed .nav-group {
        gap: 0.15rem;
        padding: 0;
    }

    body.sidebar-collapsed .nav-modern a {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0;
        min-height: 42px;
        padding: 0.5rem;
        border-radius: 10px;
    }

    body.sidebar-collapsed .nav-ic {
        width: auto;
        font-size: 1.1rem;
    }

    body.sidebar-collapsed .nav-modern a::before {
        display: none;
    }

    body.sidebar-collapsed .sidebar-footnote {
        min-height: 52px;
        padding: 0.55rem;
        place-items: center;
    }

    body.sidebar-collapsed .sidebar-footnote [data-sidebar-toggle-label] {
        display: none;
    }
}

@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.4rem 0.85rem;
    }

    .content,
    .content-modern {
        padding: 0.5rem 0.85rem 1rem;
    }

    .topbar h1,
    .topbar-modern h2 {
        font-size: 1.22rem;
    }

    .topbar-logout {
        display: none;
    }

    .sidebar-logout {
        display: block;
    }

    .user-menu-trigger {
        width: 48px;
        height: 48px;
        border-radius: 16px;
    }

    .user-menu-panel {
        width: min(300px, calc(100vw - 1.2rem));
    }
}

/* =========================================================
   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: 0.5rem 0.7rem;
        border-radius: 12px;
    }

    .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.5rem 0.55rem;
        border-radius: 12px;
    }

    .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.45rem 0.6rem;
        border-radius: 10px;
    }

    .brand-block h1 {
        font-size: 0.92rem;
    }

    .brand-block p {
        display: none;
    }

    .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;
    }
}

/* =========================================================
   POS Workspace (Facturacion rapida)
   Layout de 3 columnas tipo punto de venta: cliente/meta a
   la izquierda, items al centro, totales + cobro pegados a
   la derecha. Optimizado para velocidad y densidad.
   ========================================================= */
.pos-workspace {
    --pos-gap: 0.7rem;
    --pos-radius: 14px;
    --pos-border: 1px solid rgba(148, 163, 184, 0.22);
    --pos-surface: #ffffff;
    --pos-muted-surface: rgba(248, 250, 252, 0.92);
    display: block;
    margin-bottom: 1rem;
}

.pos-form {
    display: grid;
    gap: var(--pos-gap);
}

.pos-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.55rem 0.85rem;
    border: var(--pos-border);
    border-radius: var(--pos-radius);
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(219, 234, 254, 0.45));
}

.pos-topbar-title h3 {
    margin: 0;
    font-size: 1.02rem;
    line-height: 1.1;
}

.pos-topbar-title small {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.35;
}

.pos-topbar-title kbd,
.pos-submit kbd,
.pos-card-head kbd,
.pos-hint kbd {
    display: inline-block;
    padding: 0.04rem 0.32rem;
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.85);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.7rem;
    line-height: 1;
    color: var(--brand-strong);
}

.pos-topbar-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.pos-topbar-actions .btn {
    min-height: 34px;
    padding: 0.32rem 0.7rem;
    font-size: 0.82rem;
}

.pos-grid {
    display: grid;
    gap: var(--pos-gap);
    grid-template-columns: minmax(260px, 0.95fr) minmax(0, 1.6fr) minmax(280px, 1fr);
    align-items: start;
}

.pos-col {
    display: grid;
    gap: var(--pos-gap);
    min-width: 0;
}

.pos-col-right {
    position: sticky;
    top: 0.7rem;
}

/* En escritorio la columna de cobro se acota al alto visible: el total
   queda siempre a la vista, el bloque de cobro hace scroll interno si hace
   falta y el boton "Guardar factura" se ancla al fondo sin scrollear. */
@media (min-width: 1101px) {
    .pos-col-right {
        display: flex;
        flex-direction: column;
        gap: var(--pos-gap);
        max-height: calc(100vh - 1.4rem);
    }

    .pos-col-right > .pos-total-card,
    .pos-col-right > .pos-submit {
        flex-shrink: 0;
    }

    .pos-col-right > .pos-card:not(.pos-total-card) {
        min-height: 0;
        overflow-y: auto;
    }
}

.pos-card {
    display: grid;
    gap: 0.55rem;
    min-width: 0;
    padding: 0.75rem 0.85rem;
    border: var(--pos-border);
    border-radius: var(--pos-radius);
    background: var(--pos-surface);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pos-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 0;
}

.pos-card-head strong {
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brand-strong);
}

.pos-hint {
    color: var(--muted);
    font-size: 0.72rem;
}

/* ---- Columna izquierda: cliente + meta ---- */
.pos-client {
    display: grid;
    gap: 0.4rem;
    position: relative;
}

.pos-client-input {
    width: 100%;
    min-height: 38px;
    padding: 0.45rem 0.65rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    background: #fff;
    font-size: 0.9rem;
}

.pos-client-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.pos-client .client-search-panel {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    z-index: 50;
    padding: 0.4rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.pos-client .client-search-results {
    max-height: 260px;
    overflow-y: auto;
}

.pos-client-selected {
    display: grid;
    gap: 0.15rem;
    padding: 0.5rem 0.65rem;
    border: 1px dashed rgba(148, 163, 184, 0.45);
    border-radius: 10px;
    background: var(--pos-muted-surface);
}

.pos-client-selected-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.pos-client-selected strong {
    font-size: 0.92rem;
    line-height: 1.2;
}

.pos-client-selected small {
    color: var(--muted);
    font-size: 0.74rem;
}

.pos-meta-grid {
    display: grid;
    gap: 0.45rem 0.55rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pos-meta-grid label {
    display: grid;
    gap: 0.18rem;
    font-size: 0.74rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
}

.pos-meta-grid input,
.pos-meta-grid select {
    min-height: 36px;
    padding: 0.4rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 9px;
    background: #fff;
    font-size: 0.88rem;
    color: var(--text, #0f172a);
    text-transform: none;
    letter-spacing: 0;
}

.pos-meta-span {
    grid-column: 1 / -1;
}

.pos-meta-hint {
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.35;
}

.pos-notes summary {
    cursor: pointer;
    list-style: none;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--brand-strong);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pos-notes summary::-webkit-details-marker {
    display: none;
}

.pos-notes summary::before {
    content: "+ ";
}

.pos-notes[open] summary::before {
    content: "- ";
}

.pos-notes-grid {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.5rem;
}

.pos-notes-grid textarea {
    min-height: 60px;
    padding: 0.4rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 9px;
    font-size: 0.85rem;
    resize: vertical;
}

/* ---- Columna central: items ---- */
.pos-items {
    min-height: 360px;
}

.pos-items-head strong {
    color: var(--brand-strong);
}

.pos-search {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.4rem;
    align-items: start;
}

.pos-search-input {
    grid-column: 1;
    width: 100%;
    min-height: 42px;
    padding: 0.55rem 0.75rem;
    border: 1.5px solid rgba(15, 118, 110, 0.3);
    border-radius: 10px;
    background: #fff;
    font-size: 0.95rem;
    font-weight: 500;
}

.pos-search-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.pos-search-add {
    grid-column: 2;
    align-self: stretch;
    min-height: 42px;
    white-space: nowrap;
}

.pos-search-status {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.35;
}

.pos-search-results {
    grid-column: 1 / -1;
    display: grid;
    gap: 0.3rem;
    max-height: 260px;
    overflow-y: auto;
}

.pos-search-results:empty {
    display: none;
}

.pos-hidden-summary {
    display: none !important;
}

.pos-items-list {
    display: grid;
    gap: 0.4rem;
    max-height: calc(100vh - 280px);
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.pos-items-list:empty {
    display: none;
}

.pos-items-list .line-item-card {
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: var(--pos-muted-surface);
}

.pos-items-list .line-item-head {
    gap: 0.5rem;
}

.pos-items-list .line-item-head strong {
    font-size: 0.92rem;
    line-height: 1.2;
}

.pos-items-list .line-item-head small {
    font-size: 0.76rem;
    line-height: 1.35;
    color: var(--muted);
}

.pos-items-list .line-item-actions .btn {
    min-height: 30px;
    padding: 0.22rem 0.6rem;
    font-size: 0.78rem;
}

.pos-items-list .line-item-grid {
    margin-top: 0.5rem;
    gap: 0.4rem 0.55rem;
    grid-template-columns: minmax(0, 1.6fr) minmax(70px, 0.55fr) minmax(100px, 0.7fr) minmax(140px, 0.8fr);
}

.pos-items-list .line-item-grid input,
.pos-items-list .line-item-grid select {
    min-height: 34px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}

.pos-items-empty {
    display: grid;
    place-items: center;
    gap: 0.2rem;
    padding: 2rem 1rem;
    border: 1.5px dashed rgba(148, 163, 184, 0.4);
    border-radius: 12px;
    background: var(--pos-muted-surface);
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

.pos-items-empty strong {
    color: var(--text, #0f172a);
    font-size: 0.95rem;
}

.pos-items[data-has-items="1"] .pos-items-empty {
    display: none;
}

/* ---- Columna derecha: totales + cobro ---- */
.pos-total-card {
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(15, 118, 110, 0.25);
    background: linear-gradient(160deg, rgba(15, 118, 110, 0.95), rgba(13, 148, 136, 0.92));
    color: #fff;
    gap: 0;
}

.pos-total-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 0.35rem 0.7rem;
    padding: 0.85rem 1rem 0.7rem;
}

.pos-total-hero span {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.pos-total-hero strong {
    grid-column: 1;
    grid-row: 2;
    font-size: 2.05rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.pos-total-hero em {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    padding-bottom: 0.32rem;
    color: rgba(255, 255, 255, 0.85);
    font-style: normal;
    font-weight: 600;
    font-size: 0.95rem;
}

.pos-total-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    padding: 0;
    background: rgba(255, 255, 255, 0.16);
}

.pos-total-grid > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: rgba(15, 118, 110, 0.92);
}

.pos-total-grid span {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.pos-total-grid strong {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
}

.pos-total-grid-wide {
    grid-column: 1 / -1;
    background: rgba(15, 118, 110, 0.96) !important;
}

.pos-checkout {
    background: var(--pos-surface);
}

.pos-quick-methods,
.pos-quick-amounts {
    display: grid;
    gap: 0.35rem;
}

.pos-quick-methods {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pos-quick-amounts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pos-quick-methods .btn,
.pos-quick-amounts .btn {
    min-height: 32px;
    padding: 0.28rem 0.5rem;
    font-size: 0.78rem;
}

.pos-checkout-grid {
    display: grid;
    gap: 0.45rem 0.55rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pos-checkout-grid label {
    display: grid;
    gap: 0.18rem;
    margin: 0;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pos-checkout-grid input,
.pos-checkout-grid select {
    min-height: 34px;
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 9px;
    background: #fff;
    font-size: 0.86rem;
    color: var(--text, #0f172a);
    text-transform: none;
    letter-spacing: 0;
}

.pos-checkout-full {
    grid-column: 1 / -1;
}

.pos-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 52px;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #0f766e, #0d9488);
    color: #fff;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15, 118, 110, 0.32);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.pos-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.38);
}

.pos-submit:active {
    transform: translateY(0);
}

.pos-submit kbd {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.35);
}

/* ---- Breakpoints ---- */
@media (max-width: 1280px) {
    .pos-grid {
        grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.45fr) minmax(260px, 0.95fr);
    }

    .pos-total-hero strong {
        font-size: 1.75rem;
    }
}

@media (max-width: 1100px) {
    .pos-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .pos-col-left {
        grid-column: 1 / 2;
    }

    .pos-col-center {
        grid-column: 2 / 3;
        grid-row: 1 / span 2;
    }

    .pos-col-right {
        grid-column: 1 / 2;
        position: static;
    }

    .pos-items-list {
        max-height: calc(100vh - 320px);
    }
}

@media (max-width: 820px) {
    .pos-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .pos-col-left,
    .pos-col-center,
    .pos-col-right {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .pos-col-right {
        position: sticky;
        bottom: 0;
        top: auto;
        z-index: 20;
    }

    .pos-items-list {
        max-height: 50vh;
    }

    .pos-meta-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .pos-meta-span {
        grid-column: span 2;
    }
}

@media (max-width: 560px) {
    .pos-meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pos-meta-span {
        grid-column: 1 / -1;
    }

    .pos-quick-methods,
    .pos-checkout-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pos-total-hero strong {
        font-size: 1.6rem;
    }

    .pos-items-list .line-item-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .pos-search {
        grid-template-columns: 1fr;
    }

    .pos-search-add {
        grid-column: 1;
    }
}

/* =========================================================
   Sidebar Profile (mi perfil al pie del menu)
   ========================================================= */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 10px;
    border: 1px solid transparent;
    color: var(--shell-text);
    text-decoration: none;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.sidebar-profile:hover {
    border-color: transparent;
    background: rgba(15, 23, 42, 0.05);
}

.sidebar-profile[aria-current="page"] {
    border-color: rgba(15, 118, 110, 0.28);
    background: var(--shell-primary-soft);
}

.sidebar-profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--shell-primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.74rem;
    letter-spacing: 0.02em;
}

.sidebar-profile-info {
    display: grid;
    gap: 0;
    min-width: 0;
    flex: 1 1 auto;
}

.sidebar-profile-info strong {
    color: var(--shell-text);
    font-size: 0.82rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-info small {
    color: var(--shell-muted);
    font-size: 0.68rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-edit {
    color: var(--shell-muted);
    font-size: 1rem;
    line-height: 1;
    flex: 0 0 auto;
}

.sidebar-profile-logout {
    margin: 0;
    flex: 1 1 0;
    min-width: 0;
}

.sidebar-profile-logout .btn {
    width: 100%;
}

.sidebar-footer-actions {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
    margin-top: 0.55rem;
}

.sidebar-footer-actions > * {
    flex: 1 1 0;
    min-width: 0;
}

.sidebar-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    min-height: 36px;
    padding: 0.32rem 0.55rem;
    border-radius: 9px;
    font-size: 0.78rem;
    line-height: 1;
    color: var(--shell-muted, #64748b);
    border-color: rgba(148, 163, 184, 0.35);
    background: transparent;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.sidebar-icon-btn i {
    font-size: 1rem;
    line-height: 1;
}

.sidebar-icon-btn:hover {
    background: rgba(15, 118, 110, 0.08);
    color: var(--brand-strong, #0f766e);
    border-color: rgba(15, 118, 110, 0.35);
}

.sidebar-logout-btn:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
    border-color: rgba(220, 38, 38, 0.35);
}

.sidebar-icon-btn-label {
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.sidebar-collapsed .sidebar-footer-actions {
    flex-direction: column;
    gap: 0.35rem;
}

body.sidebar-collapsed .sidebar-icon-btn-label {
    display: none;
}

body.sidebar-collapsed .sidebar-icon-btn {
    width: 40px;
    min-width: 40px;
    padding: 0.4rem 0;
    margin: 0 auto;
}

body.sidebar-collapsed .sidebar-footer-actions > * {
    flex: 0 0 auto;
}

/* Estado compactado (sidebar colapsado): solo avatar */
body.sidebar-collapsed .sidebar-profile {
    justify-content: center;
    padding: 0.5rem;
}

body.sidebar-collapsed .sidebar-profile-info,
body.sidebar-collapsed .sidebar-profile-edit {
    display: none;
}

/* =========================================================
   Vista Mi Perfil
   ========================================================= */
.profile-identity-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(79, 70, 229, 0.14);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.06), rgba(244, 247, 255, 0.9));
    box-shadow: var(--shadow-soft, 0 4px 14px rgba(15, 23, 42, 0.06));
    min-width: min(320px, 100%);
}

.profile-avatar-lg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
    flex: 0 0 auto;
}

.profile-identity-card strong {
    display: block;
    font-size: 1.05rem;
    line-height: 1.2;
}

.profile-identity-card small {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.35;
}

.profile-meta {
    margin-top: 0.18rem;
}

.profile-section-divider {
    display: grid;
    gap: 0.1rem;
    margin-top: 0.45rem;
    padding-top: 0.65rem;
    border-top: 1px dashed rgba(148, 163, 184, 0.45);
}

.profile-section-divider strong {
    font-size: 0.9rem;
    color: var(--brand-strong);
}

.profile-section-divider small {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.profile-tips {
    margin-top: 0.85rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.85);
}

.profile-tips strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--brand-strong);
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.profile-tips ul {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.5;
}

.profile-tips li + li {
    margin-top: 0.25rem;
}

/* =========================================================
   Historial de facturas colapsable
   ========================================================= */
.pos-history {
    padding: 0;
    overflow: hidden;
}

.pos-history > .pos-history-summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius-lg);
    transition: background 0.18s ease;
}

.pos-history > .pos-history-summary::-webkit-details-marker,
.pos-history > .pos-history-summary::marker {
    display: none;
    content: "";
}

.pos-history > .pos-history-summary:hover {
    background: rgba(248, 250, 252, 0.85);
}

.pos-history-summary-copy h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
}

.pos-history-summary-copy p {
    margin: 0.18rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.pos-history-count {
    margin-left: 0.3rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.pos-history-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 0.85rem;
    border: 1px solid rgba(15, 118, 110, 0.22);
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.08);
    color: var(--brand-strong);
    font-size: 0.8rem;
    font-weight: 600;
    flex: 0 0 auto;
}

.pos-history-toggle-hide,
.pos-history[open] .pos-history-toggle-show {
    display: none;
}

.pos-history[open] .pos-history-toggle-hide {
    display: inline;
}

.pos-history-chevron {
    display: inline-block;
    font-size: 1.05rem;
    line-height: 1;
    transform: rotate(90deg);
    transition: transform 0.18s ease;
}

.pos-history[open] .pos-history-chevron {
    transform: rotate(-90deg);
}

.pos-history-body {
    display: grid;
    gap: 0.85rem;
    padding: 0 1.1rem 1.1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    padding-top: 0.9rem;
}

.pos-history-export {
    justify-content: flex-end;
}

.quotation-history > .pos-history-summary {
    padding: 0.75rem 1rem;
}

.quotation-history .pos-history-summary-copy h3 {
    font-size: 0.96rem;
}

.quotation-history .pos-history-summary-copy p {
    margin-top: 0.1rem;
    font-size: 0.78rem;
}

.quotation-history-filters {
    display: grid;
    grid-template-columns: minmax(140px, 170px) minmax(140px, 170px) minmax(220px, 1fr) auto;
    align-items: end;
    gap: 0.55rem;
    padding: 0.65rem 1rem;
    margin: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(248, 250, 252, 0.45);
}

.quotation-history-filters label {
    display: grid;
    gap: 0.22rem;
    margin: 0;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
}

.quotation-history-filters input {
    width: 100%;
    min-height: 38px;
    padding: 0.44rem 0.65rem;
    border-radius: 10px;
}

.quotation-history-filters .btn {
    min-height: 38px;
    padding: 0.42rem 0.75rem;
    white-space: nowrap;
}

.quotation-history > .table-wrap {
    margin-top: 0;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
}

@media (max-width: 820px) {
    .quotation-history-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quotation-history-filters label:nth-child(3),
    .quotation-history-filters .btn {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .pos-history > .pos-history-summary {
        flex-direction: column;
        align-items: stretch;
        gap: 0.55rem;
    }

    .pos-history-toggle {
        justify-content: center;
    }

    .quotation-history-filters {
        grid-template-columns: 1fr;
        padding: 0.6rem 0.8rem;
    }

    .quotation-history-filters label:nth-child(3),
    .quotation-history-filters .btn {
        grid-column: auto;
    }
}

/* =========================================================
   POS Workspace - Variantes Produccion
   ========================================================= */
.pos-grid-production {
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
}

@media (max-width: 1100px) {
    .pos-grid-production {
        grid-template-columns: minmax(0, 1fr);
    }

    .pos-grid-production .pos-col-right {
        position: static;
    }
}

.pos-topbar-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.08);
    color: var(--brand-strong);
    font-size: 0.74rem;
    letter-spacing: 0.03em;
}

.pos-topbar-stat strong {
    font-size: 0.92rem;
    font-weight: 700;
}

.pos-production-summary .pos-total-hero strong {
    font-size: 2.4rem;
}

.pos-production-summary .pos-total-hero em {
    padding-bottom: 0.45rem;
}

.pos-production-summary .pos-total-grid > div {
    padding: 0.55rem 0.85rem;
}

.pos-production-summary .pos-total-grid span {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.78rem;
    line-height: 1.4;
}

.pos-meta-grid textarea {
    min-height: 70px;
    padding: 0.4rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 9px;
    background: #fff;
    font-size: 0.86rem;
    text-transform: none;
    letter-spacing: 0;
    resize: vertical;
}

/* =========================================================
   Settings - toggle de modulo
   ========================================================= */
.settings-toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.85);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}

.settings-toggle input[type="checkbox"] {
    margin-top: 0.18rem;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--brand, #0f766e);
    flex: 0 0 auto;
}

.settings-toggle span {
    display: grid;
    gap: 0.18rem;
    min-width: 0;
}

.settings-toggle strong {
    color: var(--text, #0f172a);
    font-size: 0.92rem;
}

.settings-toggle small {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* =========================================================
   POS - Compras: panel de producto personalizado
   ========================================================= */
.pos-supplier-label {
    margin: 0;
}

.pos-supplier-select {
    width: 100%;
    min-height: 38px;
    padding: 0.45rem 0.65rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    background: #fff;
    font-size: 0.9rem;
}

.pos-custom-product {
    display: grid;
    gap: 0.55rem;
    padding: 0.85rem 0.95rem;
    margin-top: 0.2rem;
    border: 1.5px dashed rgba(99, 102, 241, 0.4);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(244, 247, 255, 0.95));
}

.pos-custom-product[hidden] {
    display: none;
}

.pos-custom-product-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.pos-custom-product-head strong {
    font-size: 0.86rem;
    color: var(--brand-strong);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pos-custom-close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.2rem;
}

.pos-custom-close:hover {
    color: var(--text, #0f172a);
}

.pos-custom-product > small {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.pos-custom-grid {
    display: grid;
    gap: 0.45rem 0.55rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pos-custom-span {
    grid-column: 1 / -1;
}

.pos-custom-grid label {
    display: grid;
    gap: 0.18rem;
    margin: 0;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pos-custom-grid input,
.pos-custom-grid select {
    min-height: 34px;
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 9px;
    background: #fff;
    font-size: 0.86rem;
    color: var(--text, #0f172a);
    text-transform: none;
    letter-spacing: 0;
}

.pos-custom-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.25rem;
}

.pos-custom-actions .btn {
    min-height: 34px;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}

.line-item-card-custom {
    border-color: rgba(99, 102, 241, 0.35) !important;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.04), rgba(248, 250, 252, 0.95)) !important;
}

@media (max-width: 720px) {
    .pos-custom-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .pos-custom-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* =========================================================
   POS - Gastos: layout especifico
   ========================================================= */
.pos-grid-expense {
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.5fr) minmax(280px, 1fr);
}

@media (max-width: 1100px) {
    .pos-grid-expense {
        grid-template-columns: minmax(0, 1fr);
    }
}

.pos-custom-toggle-inline {
    align-self: flex-start;
    min-height: 28px;
    padding: 0.22rem 0.65rem;
    font-size: 0.76rem;
}

.pos-expense-input-card {
    gap: 0.4rem;
}

.pos-expense-amount-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.55rem;
    align-items: stretch;
}

.pos-expense-amount {
    width: 100%;
    min-height: 64px;
    padding: 0.65rem 0.95rem;
    border: 1.5px solid rgba(15, 118, 110, 0.3);
    border-radius: 12px;
    background: #fff;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text, #0f172a);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pos-expense-amount:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.18);
}

.pos-expense-currency {
    min-height: 64px;
    padding: 0.5rem 0.95rem;
    border: 1.5px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    background: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--brand-strong);
    letter-spacing: 0.04em;
}

.pos-expense-currency:focus {
    outline: none;
    border-color: var(--brand);
}

.pos-expense-hint {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.pos-expense-description {
    width: 100%;
    min-height: 110px;
    padding: 0.55rem 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    background: #fff;
    font-size: 0.9rem;
    resize: vertical;
}

.pos-expense-description:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

@media (max-width: 640px) {
    .pos-expense-amount {
        font-size: 1.6rem;
        min-height: 52px;
    }
    .pos-expense-currency {
        min-height: 52px;
        font-size: 0.95rem;
    }
}

/* =========================================================
   Inventario - Catalogo (layout denso)
   ========================================================= */
.inventory-shell {
    display: grid;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.inventory-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(219, 234, 254, 0.45));
}

.inventory-topbar-title h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.15;
}

.inventory-topbar-title small {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.35;
}

.inventory-topbar-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.inventory-topbar-actions .btn {
    min-height: 32px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.inventory-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
}

.inventory-kpis-services {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inventory-kpi {
    display: grid;
    gap: 0.15rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.inventory-kpi span {
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.inventory-kpi strong {
    color: var(--text, #0f172a);
    font-size: 1.05rem;
    line-height: 1.1;
    font-weight: 700;
}

.inventory-kpi em {
    color: var(--muted);
    font-style: normal;
    font-size: 0.75rem;
}

.inventory-kpi-warning {
    border-color: rgba(220, 38, 38, 0.32);
    background: rgba(254, 226, 226, 0.4);
}

.inventory-kpi-warning strong {
    color: #b91c1c;
}

.inventory-kpi-in {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(209, 250, 229, 0.4);
}

.inventory-kpi-in strong {
    color: #047857;
}

.inventory-kpi-out {
    border-color: rgba(220, 38, 38, 0.28);
    background: rgba(254, 226, 226, 0.35);
}

.inventory-kpi-out strong {
    color: #b91c1c;
}

.inventory-history-date-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 0.4rem;
    align-items: end;
    grid-column: span 2;
}

.inventory-history-date-actions {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0.1rem;
}

.inventory-history-date-actions .btn {
    min-height: 36px;
}

@media (max-width: 1100px) {
    .inventory-history-date-form {
        grid-column: 1 / -1;
    }
}

@media (max-width: 560px) {
    .inventory-history-date-form {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .inventory-history-date-actions {
        grid-column: 1 / -1;
    }
}

/* =========================================================
   Reportes - layout denso (chips + filtros + KPIs)
   ========================================================= */
.reports-shell {
    display: grid;
    gap: 0.55rem;
    margin-bottom: 0.7rem;
}

.reports-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(219, 234, 254, 0.45));
}

.reports-topbar-title h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.15;
}

.reports-topbar-title small {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.4;
}

.reports-topbar-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.reports-topbar-actions .btn {
    min-height: 32px;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

/* Chips de tipos de reporte: tarjetas con mas presencia */
.reports-chips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.55rem;
    padding: 0;
    background: transparent;
    border: none;
}

.reports-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.18rem;
    padding: 0.7rem 0.95rem;
    min-height: 62px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 14px;
    background: #fff;
    color: var(--text, #0f172a);
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.reports-chip strong {
    font-size: 1rem;
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.reports-chip small {
    font-size: 0.66rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    line-height: 1;
}

.reports-chip:hover {
    border-color: rgba(15, 118, 110, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.reports-chip.is-active {
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(13, 148, 136, 0.95));
    border-color: rgba(15, 118, 110, 0.85);
    color: #fff;
    box-shadow: 0 8px 20px rgba(15, 118, 110, 0.3);
    transform: translateY(-1px);
}

.reports-chip.is-active strong {
    color: #fff;
}

.reports-chip.is-active small {
    color: rgba(255, 255, 255, 0.88);
}

/* Toolbar de filtros */
.reports-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.5rem 0.6rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 12px;
    background: #fff;
}

.reports-filters > .reports-filter {
    flex: 1 1 150px;
    min-width: 140px;
    max-width: 220px;
}

.reports-filter {
    display: grid;
    gap: 0.18rem;
    margin: 0;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.reports-filter input,
.reports-filter select {
    min-height: 34px;
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    background: #fff;
    font-size: 0.86rem;
    color: var(--text, #0f172a);
    text-transform: none;
    letter-spacing: 0;
}

.reports-filter input:focus,
.reports-filter select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.reports-filter-actions {
    display: flex;
    align-items: flex-end;
    flex: 0 0 auto;
}

.reports-filter-actions .btn {
    min-height: 34px;
}

.reports-rate-context {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.08);
    color: var(--brand-strong);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    margin-left: auto;
    flex: 0 0 auto;
}

/* KPIs strip de reportes (reutiliza .inventory-kpi) */
.reports-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
}

@media (max-width: 720px) {
    .reports-filters > .reports-filter {
        flex: 1 1 calc(50% - 0.3rem);
        max-width: none;
    }

    .reports-rate-context {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .reports-filter-actions {
        width: 100%;
    }

    .reports-filter-actions .btn {
        width: 100%;
    }
}

.inventory-kpi-money strong {
    font-size: 0.98rem;
}

.inventory-create-panel {
    position: relative;
    border-color: rgba(99, 102, 241, 0.32);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.04), rgba(248, 250, 252, 0.95));
}

.inventory-create-panel[hidden] {
    display: none;
}

.inventory-create-panel .pos-custom-close {
    position: absolute;
    top: 0.6rem;
    right: 0.7rem;
}

.inventory-catalog-card {
    padding: 0.75rem 0.85rem;
}

.inventory-catalog-toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 1.6fr) repeat(3, minmax(120px, 1fr)) auto;
    gap: 0.5rem;
    align-items: end;
    margin-bottom: 0.6rem;
}

.inventory-filter {
    display: grid;
    gap: 0.18rem;
    margin: 0;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.inventory-filter input,
.inventory-filter select {
    min-height: 36px;
    padding: 0.4rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 9px;
    background: #fff;
    font-size: 0.86rem;
    color: var(--text, #0f172a);
    text-transform: none;
    letter-spacing: 0;
}

.inventory-filter input:focus,
.inventory-filter select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.inventory-filter-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    padding-bottom: 0.2rem;
    line-height: 1.1;
}

.inventory-filter-meta strong {
    color: var(--brand-strong);
    font-size: 1.2rem;
    font-weight: 700;
}

.inventory-filter-meta small {
    color: var(--muted);
    font-size: 0.7rem;
}

@media (max-width: 1100px) {
    .inventory-catalog-toolbar {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
    }

    .inventory-filter-meta {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: baseline;
        gap: 0.35rem;
        justify-content: flex-end;
    }
}

@media (max-width: 720px) {
    .inventory-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inventory-catalog-toolbar {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

@media (max-width: 480px) {
    .inventory-kpis {
        grid-template-columns: minmax(0, 1fr);
    }

    .inventory-catalog-toolbar {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* =========================================================
   Ajustes moviles POS
   Capa exclusiva para pantallas pequenas: evita desbordes en
   facturacion, notas de entrega, compras y cotizaciones.
   ========================================================= */
@media (max-width: 720px) {
    .shell-main {
        height: auto;
        min-height: 100dvh;
        overflow-y: visible;
    }

    .topbar,
    .topbar-modern {
        position: relative;
        top: auto;
        z-index: 30;
        min-height: 56px;
        padding: max(0.48rem, env(safe-area-inset-top)) 0.75rem 0.36rem;
        align-items: center;
        justify-content: flex-start;
        background: transparent;
        border-bottom: 0;
        box-shadow: none;
        backdrop-filter: none;
    }

    .topbar-leading,
    .topbar-leading-minimal {
        width: auto;
        flex: 0 0 auto;
        align-items: center;
        min-width: 0;
    }

    .menu-toggle {
        width: 42px;
        height: 42px;
        padding: 0.58rem;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.96);
        box-shadow: 0 8px 22px rgba(15, 23, 42, 0.09);
    }

    .content-modern {
        padding-top: 0.25rem;
    }

    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .pos-workspace {
        margin-inline: -0.15rem;
    }

    .pos-form {
        gap: 0.55rem;
    }

    .pos-topbar {
        align-items: stretch;
        gap: 0.55rem;
        padding: 0.65rem;
        border-radius: 12px;
    }

    .pos-topbar-title,
    .pos-topbar-actions {
        min-width: 0;
        width: 100%;
    }

    .pos-topbar-title h3 {
        font-size: 0.98rem;
    }

    .pos-topbar-title small {
        font-size: 0.72rem;
        overflow-wrap: anywhere;
    }

    .pos-topbar-title kbd,
    .pos-submit kbd,
    .pos-card-head kbd,
    .pos-hint kbd {
        display: none;
    }

    .pos-topbar-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pos-topbar-actions .btn,
    .pos-submit,
    .pos-search-add,
    .pos-quick-methods .btn,
    .pos-quick-amounts .btn {
        width: 100%;
    }

    .pos-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.55rem;
    }

    .pos-col-left,
    .pos-col-center,
    .pos-col-right {
        grid-column: 1 / -1;
        grid-row: auto;
        min-width: 0;
    }

    .pos-col-right {
        position: static;
        z-index: auto;
    }

    .pos-card {
        padding: 0.65rem;
        border-radius: 12px;
    }

    .pos-card-head {
        align-items: flex-start;
    }

    .pos-hint {
        font-size: 0.68rem;
        text-align: right;
    }

    .pos-meta-grid,
    .pos-checkout-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.42rem;
    }

    .pos-meta-span,
    .pos-checkout-full {
        grid-column: 1 / -1;
    }

    .pos-meta-grid input,
    .pos-meta-grid select,
    .pos-checkout-grid input,
    .pos-checkout-grid select,
    .pos-client-input,
    .pos-search-input,
    .pos-notes-grid textarea {
        min-width: 0;
        font-size: 16px;
    }

    .pos-client .client-search-panel {
        position: static;
        margin-top: 0.35rem;
        max-height: 54vh;
        overflow-y: auto;
    }

    .pos-search {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.38rem;
    }

    .pos-search-input,
    .pos-search-add,
    .pos-search-status,
    .pos-search-results {
        grid-column: 1;
    }

    .pos-search-results {
        max-height: 42vh;
    }

    .pos-items {
        min-height: auto;
    }

    .pos-items-list {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .pos-items-list .line-item-card,
    .line-item-card {
        min-width: 0;
        padding: 0.65rem;
        border-radius: 12px;
    }

    .pos-items-list .line-item-head,
    .line-item-head {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0.45rem;
    }

    .pos-items-list .line-item-head > :first-child,
    .line-item-head > :first-child {
        min-width: 0;
    }

    .pos-items-list .line-item-actions,
    .line-item-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.4rem;
        width: 100%;
    }

    .pos-items-list .line-item-actions .btn,
    .line-item-actions .btn {
        width: 100%;
        min-width: 0;
        padding-inline: 0.45rem;
        white-space: normal;
    }

    .line-item-quick-qty {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }

    .line-item-quick-qty-controls {
        grid-template-columns: 38px minmax(0, 1fr) 38px;
    }

    .pos-items-list .line-item-grid,
    .line-item-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.48rem;
    }

    .pos-items-list .line-item-grid > *,
    .line-item-grid > *,
    .line-item-product {
        min-width: 0;
    }

    .line-item-product {
        padding: 0.65rem;
        border-radius: 12px;
    }

    .line-item-identity strong,
    .line-item-identity small,
    .line-item-head strong,
    .line-item-head small,
    .money-stack strong,
    .money-stack small {
        overflow-wrap: anywhere;
    }

    .line-item-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pos-total-card {
        border-radius: 12px;
    }

    .pos-total-hero {
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 0.75rem 0.85rem 0.65rem;
    }

    .pos-total-hero strong {
        min-width: 0;
        font-size: 1.42rem;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .pos-total-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pos-total-grid > div {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.18rem;
        padding: 0.52rem 0.7rem;
    }

    .pos-total-grid strong {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .pos-quick-methods {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pos-quick-amounts {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .pos-custom-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pos-custom-actions .btn {
        width: 100%;
        min-width: 0;
    }

    .pos-submit {
        min-height: 46px;
        border-radius: 12px;
        font-size: 0.96rem;
    }

    .document-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.42rem;
    }

    .document-actions .btn,
    .document-actions form {
        min-width: 0;
        width: 100%;
        flex: none;
    }

    .table.mobile-cards td {
        overflow-wrap: anywhere;
    }

    .table.mobile-cards td[data-label="Acciones"]::before {
        margin-bottom: 0.55rem;
    }
}

@media (max-width: 480px) {
    .content,
    .content-modern {
        padding-inline: 0.45rem;
    }

    .pos-workspace {
        margin-inline: 0;
    }

    .pos-topbar,
    .pos-card {
        border-radius: 10px;
    }

    .pos-topbar-actions,
    .pos-meta-grid,
    .pos-checkout-grid,
    .pos-quick-methods,
    .document-actions {
        grid-template-columns: minmax(0, 1fr);
    }

    .pos-quick-amounts,
    .line-item-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pos-custom-actions {
        grid-template-columns: minmax(0, 1fr);
    }

    .pos-total-hero {
        grid-template-columns: minmax(0, 1fr);
    }

    .pos-total-hero em {
        grid-column: 1;
        grid-row: 3;
        padding-bottom: 0;
        font-size: 0.82rem;
    }

    .pos-total-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .pos-items-empty {
        padding: 1.25rem 0.75rem;
    }

    .table.mobile-cards tr {
        border-radius: 12px;
    }

    .table.mobile-cards td {
        padding: 0.7rem 0.75rem;
    }
}

