/* ============================================================
   🎨 ventas-ocasion.css - Estilos página de Ventas de Ocasión
   Barraca Kollasuyo - Versión 3.0 (Layout robusto para SPA)
   ⭐ v3.1 - Calculadora dentro del formulario + layout lado a lado
   ============================================================ */

/* ===== FUENTE TÉRMICA PERSONALIZADA (HydrogenType) ===== */
@font-face {
    font-family: "HydrogenType";
    src: url("./hydrogen.ttf") format("truetype"),
         url("../hydrogen.ttf") format("truetype"),
         url("../../hydrogen.ttf") format("truetype"),
         url("/hydrogen.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: "Hydrogen";
    src: url("./hydrogen.ttf") format("truetype"),
         url("../hydrogen.ttf") format("truetype"),
         url("../../hydrogen.ttf") format("truetype"),
         url("/hydrogen.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}

/* ===== RESET & BASE ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

/* NOTA: Esta página se carga dentro del SPA (.spa-view).
   El contenedor principal usa min-height: 100% para adaptarse
   al espacio disponible sin depender de height fijo. */

/* ===== CONTAINER ===== */
.container {
    display: flex;
    flex-direction: column;
    /* ⭐ Sin max-width fijo: ocupa el 100% del ancho disponible */
    width: 100%;
    min-height: 0;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* ESCRITORIO (≥769px): el contenedor ocupa el 100% del spa-view padre */
@media (min-width: 769px) {
    .container {
        height: 100%;
    }
}

/* MÓVIL/TABLET (<769px): El container hereda la altura del spa-view,
   que nav.js ya calcula correctamente usando la API visualViewport.
   Esto evita los bugs de 100vh porque spaContent usa visualViewport.height.
   Se bloquea overflow-y en html/body/.spa-content/.spa-view para que
   el scroll global sea imposible. El único scroll interno es
   el de la tabla (table-scroll-area) y el resumen-view. */
@media (max-width: 768px) {
    .container {
        /* Hereda del spa-view (position:absolute; height:100% del spaContent),
           cuyo height es calculado por nav.js con visualViewport.height.
           Así se adapta correctamente a la barra de direcciones del navegador
           y a la barra de botones inferior sin generar scroll. */
        height: 100%;
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
        display: flex;
        flex-direction: column;
    }
    html,
    body.spa-container,
    .spa-content,
    .spa-view {
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: auto;
    }
    /* Anular min-height del .spa-view para que respete
       estrictamente el height calculado por nav.js */
    .spa-view {
        min-height: 0 !important;
    }
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

/* ⭐ ESCRITORIO: formulario + resumen lado a lado */
@media (min-width: 769px) {
    .content-wrapper {
        flex-direction: row;
        gap: 0;
    }
}

/* ===== CLIENT SECTION ===== */
.client-container {
    padding: 10px;
    background-color: #f1f5f9;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}

/* Sin calculadora: el cliente ocupa TODO el espacio */
.client-container.without-calculator {
    flex: 1;
}

/* Con calculadora visible: el formulario y la calculadora comparten el espacio vertical */
.client-container.with-calculator {
    flex: 1;
}

.client-section {
    margin-bottom: 8px;
    flex-shrink: 0;
}

.client-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.client-row .client-input {
    flex: 1;
    margin: 0;
    height: 38px;
}

.client-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.client-input {
    width: 100%;
    padding: 6px 12px;
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    box-sizing: border-box;
    line-height: 1.2;
}

.client-input:hover {
    background-color: #ffffff;
    border-color: #94a3b8;
}

.client-input:focus {
    border-color: var(--color-primary, #680d03);
    outline: none;
    box-shadow: 0 0 0 3px rgba(104, 13, 3, 0.12);
}

/* ===== CATEGORIA BUTTON (B / O) ===== */
.categoria-badge-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    user-select: none;
    box-sizing: border-box;
    flex-shrink: 0;
}

.categoria-badge-btn:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.categoria-badge-btn:active {
    transform: translateY(0);
}

/* ===== TABLE SECTION ===== */
.table-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.table-column-headers {
    display: flex;
    background-color: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #475569;
    text-transform: uppercase;
    box-sizing: border-box;
    flex-shrink: 0;
}

.col-head-measures {
    width: 65%;
    display: flex;
    align-items: center;
}

.col-head-summary {
    width: 35%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 4px;
}

.table-container {
    border: 1px solid #cbd5e1;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    flex: 1;
    background-color: white;
    position: relative;
    padding-right: 5px;
}

.table-container::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

.table-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.table-scroll-area {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.table-scroll-area::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

.custom-scrollbar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 5px;
    width: 3px;
    background-color: #ffffff;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.3s;
}

.custom-scrollbar.visible {
    opacity: 1;
}

.scroll-thumb {
    position: absolute;
    width: 3px;
    background-color: #C2C2C2;
    border-radius: 1px;
    min-height: 30px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.scroll-thumb:hover {
    background-color: #555;
}

/* ===== DATA TABLE ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table tr:hover {
    background-color: transparent;
}

/* Evitar destello azul/cian al hacer hover, active o clic en las filas de entrada */
.data-table tr.entry-header:hover,
.data-table tr.entry-value:hover,
.data-table tr.entry-header:active,
.data-table tr.entry-value:active {
    background-color: transparent !important;
}

/* Prevenir resaltes de pulsación en móviles sin afectar inputs */
.data-table {
    -webkit-tap-highlight-color: transparent;
}

/* Forzar que cualquier selección de texto en la tabla use tono ámbar en vez de cian/azul nativo */
.data-table ::selection,
.data-table input::selection,
.data-table textarea::selection {
    background-color: rgba(245, 158, 11, 0.35) !important;
    color: inherit !important;
}

.data-table td {
    padding: 0;
    border-bottom: 1px solid #d9d7d7;
    font-size: 1rem;
    overflow: hidden;
    min-height: 45px;
    vertical-align: top;
    position: relative;
}

.data-table td.entry-measures-col,
.data-table .entry-header td:first-child,
.data-table .entry-value td {
    border-right: 1px solid #eee;
    width: 65%;
    vertical-align: top;
    height: 45px;
    background-color: transparent;
    padding: 0;
    text-align: left;
}

.first-col-container {
    display: flex;
    gap: 5px;
    align-items: stretch;
    height: 100%;
    min-height: 45px;
}

.data-table td.entry-summary-col,
.data-table .entry-header td.entry-summary-col,
.data-table .entry-header td:last-child {
    width: 35%;
    text-align: right;
    font-weight: 500;
    background-color: #f0f0f0;
    padding: 8px 10px;
    vertical-align: top;
}

.data-table td.entry-summary-col input,
.data-table .entry-header td:last-child input {
    color: #000000;
    background: transparent;
    text-align: right;
    width: 100%;
}

.data-table td.entry-summary-col input::placeholder,
.data-table .entry-header td:last-child input::placeholder {
    color: rgba(0,0,0,0.45);
}

.data-table td.entry-summary-col input:focus,
.data-table .entry-header td:last-child input:focus {
    background-color: rgba(255,255,255,0.9);
    border: 1px solid #ccc;
    color: #000000;
}

.data-table input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    outline: none;
    padding: 8px 10px;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    box-sizing: border-box;
    text-align: inherit;
}

.header-input-group {
    display: flex;
    gap: 5px;
    width: 100%;
}

.header-input-group input {
    flex: 1;
    margin: 0;
    padding: 8px 10px;
}

.measures-cell-container {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 45px;
    position: relative;
    padding: 0 2px;
    box-sizing: border-box;
}

.measures-cell-container .cantidad-input {
    display: none;
    width: auto;
    min-width: 50px;
    max-width: 80px;
    height: 32px;
    padding: 2px 4px;
    font-size: 0.95rem;
    font-weight: 600;
    margin-right: 6px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    vertical-align: middle;
    flex-shrink: 0;
    background-color: #ffffff;
}

.measures-cell-container .cantidad-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.12);
}

.measures-cell-container .cantidad-input.has-value {
    background-color: #e8e8e8;
}

.measures-cell-container .measures-input {
    flex: 1;
    width: 100%;
    min-height: 45px;
    height: auto;
    border: none;
    background: transparent;
    outline: none;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 1.2rem !important;
    font-weight: 500;
    color: inherit;
    box-sizing: border-box;
    text-align: left;
    resize: none;
    overflow-y: hidden;
    line-height: 1.35;
    display: block;
}

.data-table .auto-expand {
    width: 100%;
    min-height: 45px;
    height: auto;
    border: none;
    background: transparent;
    outline: none;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 1rem;
    color: inherit;
    box-sizing: border-box;
    text-align: left;
    overflow: hidden;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    display: block;
}

.data-table .auto-expand > .cantidad-input {
    display: inline-block;
    width: auto;
    min-width: 52px;
    max-width: 90px;
    height: 28px;
    padding: 3px 4px;
    font-size: 0.95rem;
    margin-right: 12px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    vertical-align: middle;
}

.data-table .auto-expand > .cantidad-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.12);
}

.data-table .auto-expand > .cantidad-input.has-value {
    background-color: #e1e1e1;
}

.data-table .auto-expand > .cantidad-input.has-value:focus {
    background-color: #e1e1e1 !important;
}

.data-table input:focus,
.data-table textarea:focus,
.data-table .auto-expand:focus {
    background-color: #fff3cd !important;
    border: 1.5px solid #d4a017 !important;
    border-radius: 4px;
    outline: none !important;
    box-shadow: none !important;
}

.data-table input[data-type="sumatoria"]:focus,
.data-table input[data-type="pies"]:focus,
.data-table input[data-type="piezas"]:focus {
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
}

/* ===== ENTRY STYLES ===== */
.entry-header {
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

.entry-header td {
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

.entry-header input {
    font-weight: bold;
    color: #333;
}

.entry-value {
    font-weight: normal;
    color: #666;
    font-size: 0.9rem;
}

.entry-value td {
    font-weight: normal;
    color: #666;
    font-size: 0.9rem;
}

.entry-value input {
    font-weight: normal;
    color: #666;
}

.selected-entry {
    background-color: #fff3cd !important;
}

.selected-entry td {
    background-color: #fff3cd !important;
}

input[data-type="pies"]::placeholder,
input[data-type="piezas"]::placeholder {
    font-weight: normal !important;
    color: #ccc;
    font-style: italic;
    opacity: 0.6;
}

input[data-type="pies"],
input[data-type="piezas"] {
    font-weight: normal !important;
    font-size: 1rem !important;
}

input[data-type="subtotal"] {
    font-size: 1rem !important;
}

input[data-type="header"],
input[data-type="sumatoria"],
input[data-type="precio"] {
    padding: 0.1px 8px !important;
    height: 100% !important;
    box-sizing: border-box !important;
}

input[data-type="precio"] {
    background-color: rgba(34, 114, 11, 0.027) !important;
}

input[data-type="sumatoria"] {
    user-select: none;
    cursor: default;
    -webkit-user-select: none;
}

input[data-type="pies"],
input[data-type="piezas"] {
    user-select: none;
    cursor: default;
    -webkit-user-select: none;
}

.data-table tr:nth-child(2n) {
    border-bottom: 8px solid #bdbdbd;
}

/* ===== SUMMARY ===== */
.summary-section {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding: 0 5px;
    flex-shrink: 0;
    align-items: center;
}

.action-btn {
    background-color: white;
    color: #333;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 6px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    border: 1px solid #dcdcdc;
    cursor: pointer;
    font-size: 0.95rem;
    width: auto !important;
    height: 38px !important;
    min-height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.action-btn:hover {
    background-color: #f8f9fa;
    border-color: #c0c0c0;
}

.action-btn.primary {
    background-color: var(--color-primary, #680d03);
    color: #fff;
    border-color: transparent;
}

.action-btn.primary:hover {
    background-color: var(--color-primary-hover, #831608);
}

#addEntryBtn {
    background: #ffffff !important;
    color: #1e293b !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-weight: 600 !important;
    font-size: 0.92rem !important;
    width: auto !important;
    min-width: 110px !important;
    height: 38px !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease;
}

#addEntryBtn:hover {
    background-color: #f8fafc !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

/* ===== TABLE LAYOUT ===== */
.table-flex-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.total-row-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 6px 10px;
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    gap: 8px;
    box-sizing: border-box;
}

.total-row-footer .metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    box-sizing: border-box;
    line-height: 1.2;
}

.total-row-footer .metric-feet {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.total-row-footer .metric-amount {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.total-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: inherit;
    line-height: 1;
}

.total-amount {
    font-weight: 800;
    font-size: 0.95rem;
    color: inherit;
    padding: 0 2px;
    line-height: 1;
}

.total-currency {
    font-weight: 700;
    font-size: 0.82rem;
    color: inherit;
    opacity: 0.9;
}

/* ===== CLEAR/DELETE BUTTONS ===== */
.clear-all-btn {
    background-color: #ffffff;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 0 14px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.clear-all-btn:hover {
    background-color: #fee2e2;
    border-color: #f87171;
    color: #b91c1c;
}

.delete-btn {
    background-color: #680d03;
    color: white;
    border: none;
    padding: 0 10px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    box-sizing: border-box;
}

.delete-btn:hover {
    background-color: #c0392b;
}

/* ============================================================
   🧮 CALCULATOR
   ⭐ Ahora está dentro de client-container, así que en escritorio
      solo ocupa el ancho del panel del formulario.
   ============================================================ */
.calculator-container {
    background-color: #e2e8f0;
    border-top: 1px solid #cbd5e1;
    border-radius: 12px 12px 0 0;
    display: flex;
    flex-direction: column;
    padding: 8px;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 0;
    flex: 0 0 auto;
    min-height: 0;
}

/* OCULTO: display: none → no ocupa espacio en el layout */
.calculator-container.hidden {
    display: none;
}

.calculator-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 0.85fr;
    grid-template-rows: repeat(4, 46px);
    gap: 6px;
    min-height: 0;
}

.calc-btn {
    padding: 4px 2px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    background-color: #ffffff;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: background-color 0.12s ease, transform 0.08s ease, opacity 0.15s ease, border-color 0.12s ease;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
}

.calc-btn:hover {
    background-color: #f1f5f9;
    border-color: #94a3b8;
}

.calc-btn:active {
    background-color: #e2e8f0;
    transform: scale(0.97);
}

.calc-btn.calc-btn-zero {
    grid-column: span 2;
    font-size: 1.15rem;
}

.calc-btn.calc-btn-dot {
    background-color: #ffffff;
    color: #0f172a;
    font-weight: 700;
    font-size: 1.35rem;
}

.calc-btn.calc-btn-dot:hover {
    background-color: #f1f5f9;
}

.calc-btn.calc-btn-enter {
    background-color: var(--color-primary, #680d03);
    color: #ffffff;
    border: 1px solid transparent;
    font-weight: 700;
    font-size: 1.25rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.calc-btn.calc-btn-enter:hover {
    background-color: var(--color-primary-hover, #831608);
    border-color: transparent;
}

.calc-btn.calc-btn-enter:active {
    transform: scale(0.97);
    background-color: var(--color-primary-dark, #4e0902);
}

.calc-btn.operation {
    background-color: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    font-size: 1.15rem;
}

.calc-btn.operation:hover {
    background-color: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
}

.calc-btn.times {
    background-color: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    font-size: 1.2rem;
    font-weight: 700;
}

.calc-btn.times:hover {
    background-color: #e2e8f0;
    border-color: #94a3b8;
}

.calc-btn:disabled,
.calc-btn.btn-disabled {
    opacity: 0.3 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
}

.big-btn {
    grid-row: span 2;
    font-size: 1.35rem;
    font-weight: bold;
    height: 100%;
}

/* ⭐ En escritorio, la calculadora ocupa todo el ancho del panel del formulario */
@media (min-width: 769px) {
    .calculator-container {
        width: 100%;
    }
}

/* ============================================================
   📋 RESUMEN VIEW
   ============================================================ */
.resumen-view {
    position: absolute;
    inset: 0;
    background-color: #f8fafc;
    display: none;
    flex-direction: column;
    z-index: 200;
}

.resumen-view.active {
    display: flex;
}

/* ⭐ ESCRITORIO: resumen como panel lateral permanente */
@media (min-width: 769px) {
    .resumen-view {
        position: relative;
        inset: auto;
        flex: 1;
        display: flex !important;
        border-left: 1px solid #e2e8f0;
        min-width: 0;
        z-index: auto;
        background-color: #f1f5f9;
    }
    
    /* Ocultar barra de herramientas del resumen (botón volver) */
    .resumen-toolbar {
        display: none !important;
    }
    
    /* El contenido del resumen scrollea si es necesario */
    .resumen-content {
        flex: 1;
        overflow-y: auto;
    }
    
    /* Ocultar el botón "Resumen" del formulario en escritorio */
    #resumenBtn {
        display: none !important;
    }
}

.resumen-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background-color: #f4f4f4;
    border-bottom: 1px solid #ddd;
}

.resumen-toolbar-title {
    font-weight: 600;
    color: #333;
}

.resumen-back-btn {
    background-color: #ffffff;
    color: #333;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    border: 1px solid #e6e6e6;
    cursor: pointer;
    font-size: 0.9rem;
}

.resumen-content {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 8px 5px;
}

.resumen-view .receipt-container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 16px 18px;
    box-sizing: border-box;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
}

.resumen-view .receipt-header {
    text-align: center;
    margin-bottom: 14px;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 8px;
}

.resumen-tipo-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    background-color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    box-sizing: border-box;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23333' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.resumen-tipo-select:hover {
    background-color: #f5f5f5;
}

.resumen-tipo-select:focus {
    outline: none;
    background-color: #f0f7ff;
    border: 1px solid #3498db;
}

.resumen-tipo-select:disabled {
    background-color: transparent;
    opacity: 0.7;
    cursor: not-allowed;
    background-image: none;
    pointer-events: none;
}

.resumen-header-container {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.resumen-document-number {
    width: 70px;
    padding: 5px 6px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    background-color: transparent;
    border: none;
    border-radius: 4px;
    text-align: center;
    box-sizing: border-box;
    flex-shrink: 0;
}

.resumen-document-number:focus {
    outline: none;
    background-color: #f0f7ff;
}

.resumen-view .salutation {
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 12px;
    padding-left: 2px;
}

.resumen-view .receipt-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 0.85rem;
    table-layout: fixed;
}

.resumen-view .receipt-table th {
    background-color: #f8f8f8;
    color: #333;
    font-weight: 600;
    padding: 6px 5px;
    text-align: left;
    border-bottom: 1.5px solid #ddd;
}

.resumen-view .receipt-table td {
    padding: 6px 5px;
    border-bottom: 1px solid #eee;
    color: #555;
}

.resumen-cancelado-input {
    width: 13ch;
    height: 30px;
    line-height: 1;
    box-sizing: border-box;
    text-align: right;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0 6px;
    margin: 0;
    color: #0f172a;
    outline: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.resumen-cancelado-input::-webkit-inner-spin-button,
.resumen-cancelado-input::-webkit-outer-spin-button {
    opacity: 1;
    cursor: pointer;
    margin-left: 2px;
}

.resumen-cancelado-input.error {
    border-color: #dc3545;
    background-color: #fff5f5;
}

.resumen-cancelado-input:focus {
    border-color: var(--color-primary, #680d03);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(104, 13, 3, 0.12);
}

.resumen-view .totals-section {
    margin-top: 12px;
    border-top: 1.5px solid #333;
    padding-top: 10px;
}

.resumen-view .total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding: 2px 4px;
    font-size: 0.9rem;
    background: transparent !important;
    background-image: none !important;
    color: #333 !important;
    border: none !important;
}

.resumen-view .total-label {
    font-weight: 500;
    color: #444 !important;
    background: transparent !important;
}

.resumen-view .total-value {
    font-weight: 600;
    color: #333 !important;
    background: transparent !important;
}

.resumen-view .resumen-balances .resumen-balance-row {
    background: transparent !important;
    background-image: none !important;
}

.resumen-balance-row:has(#resumenSaldoCobrar),
#resumenSaldoCobrar {
    display: none !important;
}

.resumen-view .cancelado-input-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.resumen-view .cancelado-input-wrap .bs-inline {
    font-weight: bold;
    font-size: 1.05rem;
    color: #444;
    margin: 0;
}

.cancelado-mixto-container {
    width: 100%;
    margin-top: 4px;
    margin-bottom: 4px;
    padding: 6px 8px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px dashed #cbd5e1;
}

.canceled-mixto-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.canceled-mixto-row .total-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.resumen-view .forma-pago-row {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.resumen-forma-pago-select {
    padding: 3px 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.resumen-forma-pago-select:focus {
    border-color: #2E8B57;
    box-shadow: 0 0 0 2px rgba(46, 139, 87, 0.2);
}

.resumen-view .divider {
    height: 1px;
    background-color: #ddd;
    margin: 8px 0;
    width: 100%;
}

.resumen-view .amount-in-words {
    text-align: center;
    font-style: italic;
    color: #666;
    margin-top: 12px;
    padding: 8px;
    border-top: 1px dashed #ccc;
    border-bottom: 1px dashed #ccc;
    font-size: 0.85rem;
}

.resumen-view .resumen-balances {
    margin-top: 8px;
}

.balance-separator-line {
    border-top: 2px solid #cbd5e1;
    width: 25%;
    margin: 4px 0 4px auto;
}

.resumen-view .resumen-balance-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 4px;
    font-size: 0.9rem;
}

.resumen-view .empty-data {
    color: #999;
    font-style: italic;
    font-size: 0.8rem;
}

.resumen-view .text-right {
    text-align: right;
}

.resumen-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background-color: #ffffff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.resumen-actions .action-btn {
    flex: 1;
    width: auto !important;
    height: 38px !important;
    min-height: 38px !important;
    border-radius: 8px !important;
    padding: 8px 14px !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    transition: all 0.2s ease;
}

.resumen-actions #resumenRegistrarBtn {
    flex: 0 0 auto !important;
    width: 140px !important;
    max-width: 160px !important;
    min-width: 120px !important;
    margin-left: auto;
    background-color: var(--color-primary, #680d03) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15) !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
}

.resumen-actions #resumenRegistrarBtn:hover {
    background-color: var(--color-primary-hover, #831608) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
    transform: translateY(-1px);
}

.resumen-actions #resumenGenerarBtn {
    flex: 0 0 auto !important;
    width: 140px !important;
    max-width: 160px !important;
    min-width: 120px !important;
    margin-left: auto;
    background-color: #d97706 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 5px rgba(217, 119, 6, 0.25) !important;
    color: #ffffff !important;
    border: none !important;
    font-weight: 700 !important;
}

.resumen-actions #resumenGenerarBtn:hover {
    background-color: #b45309 !important;
    box-shadow: 0 4px 8px rgba(217, 119, 6, 0.35) !important;
    transform: translateY(-1px);
}

.resumen-actions .action-btn.icon-only,
.print-dropdown-container .action-btn.icon-only {
    flex: 0 0 88px !important;
    width: 88px !important;
    height: 38px !important;
    min-height: 38px !important;
    border-radius: 8px !important;
    padding: 8px 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    color: #334155 !important;
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}

.resumen-actions .action-btn.icon-only:hover,
.print-dropdown-container .action-btn.icon-only:hover {
    background-color: #f8fafc !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
}

.print-dropdown-container {
    position: relative;
    flex: 0 0 88px;
    display: flex;
}

.print-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    z-index: 1050;
    display: none;
    flex-direction: column;
    padding: 5px;
    animation: fadeInMenu 0.15s ease-out;
}

.print-dropdown-menu.active {
    display: flex;
}

.print-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    border-radius: 5px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s, color 0.15s;
}

.print-dropdown-item i {
    font-size: 0.95rem;
    width: 16px;
    text-align: center;
    color: #555;
}

.print-dropdown-item:hover {
    background-color: #f0f7f3;
    color: #2E8B57;
}

.print-dropdown-item:hover i {
    color: #2E8B57;
}

@keyframes fadeInMenu {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.resumen-actions .action-btn.generate-btn,
.action-btn.generate-btn {
    background-color: #003d82;
    color: white;
    font-weight: 600;
    border: none;
    border-radius: 6px !important;
    padding: 8px 14px !important;
    cursor: pointer;
    display: none !important;
}

.resumen-actions .action-btn.generate-btn:hover,
.action-btn.generate-btn:hover {
    background-color: #002d5f;
}

.resumen-actions .action-btn.generate-btn.visible,
.action-btn.generate-btn.visible {
    display: inline-flex !important;
}

/* ============================================================
/* ============================================================
   🖨️ MODAL DE VISTA PREVIA Y EMISIÓN MULTI-FORMATO (80mm, 58mm, A5)
   ============================================================ */

/* 1. Overlay y Contenedor Principal del Modal */
.ticket-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3500;
    padding: 16px;
    box-sizing: border-box;
}

.ticket-modal-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 680px;
    max-height: 94vh;
    overflow: hidden;
    animation: ticketModalIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ticketModalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* 2. Cabecera del Modal con Selector de Formato */
.ticket-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.ticket-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.ticket-modal-title i {
    color: var(--primary-color, #680d03);
}

.ticket-format-tabs {
    display: inline-flex;
    align-items: center;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 24px;
    gap: 3px;
}

.ticket-format-btn {
    border: none;
    background: transparent;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.18s ease;
    user-select: none;
}

.ticket-format-btn:hover:not(.active) {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.6);
}

.ticket-format-btn.active {
    background: #ffffff;
    color: var(--primary-color, #680d03);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
    font-weight: 700;
}

/* 3. Visor Central Dinámico (Papel Físico en Vivo) */
.ticket-modal-viewport {
    flex: 1;
    background: #e2e8f0;
    padding: 24px 14px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 64vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Hoja de Papel con Sombra Fiel */
.ticket-paper-sheet {
    background: #ffffff;
    color: #000000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    box-sizing: border-box;
    transition: width 0.22s ease, padding 0.22s ease;
    margin: 0 auto;
}

/* Texto con aspecto de ticket térmico */
.thermal {
    font-family: "Arial Narrow", Arial, sans-serif;
}

.thermal * {
    font-family: "Arial Narrow", Arial, sans-serif;
}

/* ===== MODO 80 MM (Diseño en Modal de Previsualización) ===== */
.ticket-paper-sheet.format-80mm {
    width: 380px;
    max-width: 100%;
    padding: 16px 14px;
    font-size: 11px;
    font-family: "Arial Narrow", Arial, sans-serif;
    line-height: 1.25;
}

/* Estilos internos 80mm */
.ticket-paper-sheet .t-center { text-align: center; }
.ticket-paper-sheet .t-right { text-align: right; }
.ticket-paper-sheet .t-bold { font-weight: 700; }
.ticket-paper-sheet .t-italic { font-style: italic; }
.ticket-paper-sheet .t-header-title { font-size: 16px; font-weight: 800; margin: 0; letter-spacing: 0.5px; }
.ticket-paper-sheet .t-sub-title { font-size: 12px; font-weight: 700; margin: 0 0 2px 0; }
.ticket-paper-sheet .t-desc { font-size: 8.5px; line-height: 1.15; margin: 3px 0; color: #333333; }
.ticket-paper-sheet .t-doc-type { font-size: 13px; font-weight: 800; margin: 6px 0 4px 0; letter-spacing: 0.5px; }
.ticket-paper-sheet .t-divider { border-top: 1px dashed #000000; margin: 5px 0; }
.ticket-paper-sheet .t-divider-solid { border-top: 1px solid #000000; margin: 4px 0; }
.ticket-paper-sheet .t-table { width: 100%; border-collapse: collapse; margin: 4px 0; table-layout: fixed; }
.ticket-paper-sheet .t-table th { font-weight: 700; border-top: 1px solid #000000; border-bottom: 1px solid #000000; padding: 3px 1px; font-size: 10px; }
.ticket-paper-sheet .t-table td { padding: 3px 1px; vertical-align: top; font-size: 9.5px; }
.ticket-paper-sheet .t-row { display: flex; justify-content: space-between; margin: 2px 0; }
.ticket-paper-sheet .t-row.t-right { justify-content: flex-end; text-align: right; }

/* ===== MODO 58 MM (Diseño en Modal de Previsualización) ===== */
.ticket-paper-sheet.format-58mm {
    width: 265px;
    max-width: 100%;
    padding: 10px 10px;
    font-size: 11px;
    font-family: "Arial Narrow", Arial, sans-serif;
    line-height: 1.25;
    letter-spacing: -0.1px;
}

.ticket-paper-sheet.format-58mm .t-header-title { 
    font-size: 13.5px; 
    font-weight: 800; 
    margin: 0; 
    font-family: inherit;
    letter-spacing: 0px;
}
.ticket-paper-sheet.format-58mm .t-sub-title { 
    font-size: 10.5px; 
    font-weight: 700; 
    font-family: inherit;
}
.ticket-paper-sheet.format-58mm .t-desc { 
    font-size: 9px; 
    line-height: 1.15; 
    margin: 2px 0; 
    font-family: inherit;
}
.ticket-paper-sheet.format-58mm .t-doc-type { 
    font-size: 11.5px; 
    font-weight: 800; 
    margin: 4px 0; 
    letter-spacing: 0.5px;
    font-family: inherit;
}

/* Items en 2 líneas legibles para 58mm (alineación en 32 columnas) */
.t58-item {
    border-bottom: 1px dashed #777;
    padding: 3px 0;
    font-family: inherit;
}
.t58-item:last-child {
    border-bottom: none;
}
.t58-line1 {
    font-weight: 700;
    font-size: 11px;
    color: #000;
    display: flex;
    justify-content: space-between;
    word-break: break-word;
    font-family: inherit;
}
.t58-line2 {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #222;
    margin-top: 1px;
    font-family: inherit;
}
.t58-subtotal {
    font-weight: 700;
    color: #000;
    font-size: 11px;
    font-family: inherit;
}
.ticket-paper-sheet.format-58mm .t-row {
    font-family: inherit;
    font-size: 10.5px;
}
.ticket-paper-sheet.format-58mm .t-divider {
    border-top: 1px dashed #000000;
    margin: 4px 0;
}
.ticket-paper-sheet.format-58mm .t-divider-solid {
    border-top: 1px solid #000000;
    margin: 4px 0;
}

/* ===== MODO A5 (Nota de Venta / Proforma Comercial 148×210mm) ===== */
.ticket-paper-sheet.format-a5 {
    width: 580px;
    max-width: 100%;
    padding: 24px;
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.35;
    border: 1px solid #cbd5e1;
}

.a5-header-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: start;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 2px solid #0f172a;
}
.a5-company-name {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: 0.5px;
    line-height: 1.15;
    margin-bottom: 4px;
}
.a5-company-info {
    font-size: 9px;
    color: #475569;
    line-height: 1.35;
}
.a5-doc-box {
    border: 2px solid #0f172a;
    border-radius: 6px;
    padding: 8px 14px;
    text-align: center;
    background: #f8fafc;
    min-width: 170px;
}
.a5-doc-box-type {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    color: #0f172a;
    border-bottom: 1px solid #cbd5e1;
    padding-bottom: 4px;
    margin-bottom: 4px;
}
.a5-doc-box-num {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary-color, #680d03);
}
.a5-doc-box-date {
    font-size: 9.5px;
    color: #64748b;
    margin-top: 2px;
}

.a5-client-bar {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 10.5px;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 8px;
}
.a5-client-bar strong {
    color: #0f172a;
}

.a5-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
}
.a5-table th {
    background: #0f172a;
    color: #ffffff;
    padding: 6px 8px;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    border: 1px solid #0f172a;
}
.a5-table td {
    padding: 5px 8px;
    font-size: 10px;
    border: 1px solid #cbd5e1;
    vertical-align: middle;
}
.a5-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.a5-footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
    align-items: start;
    margin-top: 10px;
}
.a5-literal-box {
    font-size: 9.5px;
    font-style: italic;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 10px;
}
.a5-policies-box {
    font-size: 8px;
    color: #64748b;
    line-height: 1.3;
}
.a5-totals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10.5px;
}
.a5-totals-table td {
    padding: 3px 6px;
}
.a5-totals-table .total-highlight {
    font-size: 13px;
    font-weight: 800;
    color: #0f172a;
    background: #f1f5f9;
    border-top: 2px solid #0f172a;
    border-bottom: 2px solid #0f172a;
}

.a5-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 36px;
    padding-top: 10px;
    text-align: center;
}
.a5-sign-line {
    border-top: 1px solid #475569;
    padding-top: 4px;
    font-size: 9.5px;
    color: #334155;
    font-weight: 600;
}

/* 4. Footer del Modal con Acciones */
.ticket-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.ticket-modal-actions-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-share {
    background: #0284c7;
    color: #ffffff;
    border: 1px solid #0284c7;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all 0.18s ease;
}
.btn-share:hover {
    background: #0369a1;
    border-color: #0369a1;
}

.btn-print-main {
    background: var(--primary-color, #680d03);
    color: #ffffff;
    border: 1px solid var(--primary-color, #680d03);
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 6px rgba(104, 13, 3, 0.25);
    transition: all 0.18s ease;
}
.btn-print-main:hover {
    background: #841004;
    border-color: #841004;
}

/* Responsive Modal en Móviles */
@media (max-width: 640px) {
    .ticket-modal-card {
        max-height: 98vh;
        border-radius: 12px 12px 0 0;
    }
    .ticket-modal-header {
        padding: 10px 12px;
        gap: 8px;
    }
    .ticket-format-tabs {
        width: 100%;
        justify-content: center;
        order: 3;
        margin-top: 4px;
    }
    .ticket-format-btn {
        flex: 1;
        justify-content: center;
        padding: 5px 8px;
        font-size: 0.78rem;
    }
    .ticket-modal-viewport {
        padding: 12px 6px;
    }
    .ticket-paper-sheet.format-a5 {
        width: 100%;
        padding: 12px;
        font-size: 9px;
    }
    .a5-company-name {
        font-size: 14px;
    }
    .ticket-modal-footer {
        padding: 10px 12px;
        flex-direction: column-reverse;
        gap: 8px;
    }
    .ticket-modal-actions-right {
        width: 100%;
    }
    .ticket-modal-actions-right button,
    #btnCerrarTicketModal {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================
   🖨️ REGLAS DE IMPRESIÓN DINÁMICAS (80mm, 58mm, A5)
   ============================================================ */
#ticketPrintArea {
    display: none;
}

@media print {
    /* Ocultar toda la interfaz y contenedores SPA cuando se imprime el ticket */
    body.is-printing-ticket > *:not(#ticketPrintArea) {
        display: none !important;
    }

    body.is-printing-ticket {
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
    }

    body.is-printing-ticket #ticketPrintArea {
        display: block !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
        z-index: 99999 !important;
    }

    body.is-printing-ticket #ticketPrintArea .ticket-paper-sheet {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 auto !important;
    }

    /* Calibración 80mm */
    body.is-printing-ticket.print-active-80mm #ticketPrintArea {
        width: 76mm !important;
    }
    body.is-printing-ticket.print-active-80mm #ticketPrintArea .ticket-paper-sheet {
        width: 76mm !important;
        padding: 2mm 2mm !important;
        font-family: "Arial Narrow", Arial, sans-serif !important;
        line-height: 1.25 !important;
    }
    body.is-printing-ticket.print-active-80mm #ticketPrintArea .ticket-paper-sheet * {
        font-family: "Arial Narrow", Arial, sans-serif !important;
    }

    /* Calibración 58mm (Hasta 32 caracteres en horizontal con Arial Narrow) */
    body.is-printing-ticket.print-active-58mm #ticketPrintArea {
        width: 52mm !important;
        max-width: 52mm !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    body.is-printing-ticket.print-active-58mm #ticketPrintArea .ticket-paper-sheet {
        width: 52mm !important;
        max-width: 52mm !important;
        padding: 2mm 2.5mm !important; /* Margen de 2.5mm para despegar del borde: 47mm útil exacto para hasta 32 caracteres */
        font-family: "Arial Narrow", Arial, sans-serif !important;
        font-size: 8.5pt !important;
        line-height: 1.25 !important;
        box-sizing: border-box !important;
    }
    body.is-printing-ticket.print-active-58mm #ticketPrintArea .ticket-paper-sheet * {
        font-family: "Arial Narrow", Arial, sans-serif !important;
    }
    body.is-printing-ticket.print-active-58mm #ticketPrintArea .ticket-paper-sheet .t-header-title {
        font-size: 11pt !important;
    }
    body.is-printing-ticket.print-active-58mm #ticketPrintArea .ticket-paper-sheet .t-doc-type {
        font-size: 9.5pt !important;
    }
    body.is-printing-ticket.print-active-58mm #ticketPrintArea .ticket-paper-sheet .t58-line1 {
        font-size: 8.5pt !important;
    }
    body.is-printing-ticket.print-active-58mm #ticketPrintArea .ticket-paper-sheet .t58-line2 {
        font-size: 8pt !important;
    }
    body.is-printing-ticket.print-active-58mm #ticketPrintArea .ticket-paper-sheet .t58-subtotal {
        font-size: 8.5pt !important;
    }

    /* Calibración A5 */
    body.is-printing-ticket.print-active-a5 #ticketPrintArea {
        width: 148mm !important;
        max-width: 148mm !important;
    }
    body.is-printing-ticket.print-active-a5 #ticketPrintArea .ticket-paper-sheet {
        width: 100% !important;
        max-width: 140mm !important;
        padding: 6mm 6mm !important;
    }
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 450px;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    animation: modalZoomIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalZoomIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    background-color: var(--color-primary, #680d03);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.close-modal {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.4rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0.85;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.close-modal:hover {
    background-color: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.modal-body {
    padding: 18px 20px;
    max-height: 75vh;
    overflow-y: auto;
    background-color: var(--color-surface, #ffffff);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--color-text, #334155);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border, #cbd5e1);
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: var(--color-bg, #f8fafc);
    color: var(--color-text, #0f172a);
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary, #680d03);
    background-color: var(--color-surface, #ffffff);
    box-shadow: 0 0 0 3px rgba(104, 13, 3, 0.12);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.btn {
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn-primary {
    background-color: var(--color-primary, #680d03);
    color: #ffffff;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
    background-color: var(--color-primary-hover, #831608);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.btn-primary:active {
    background-color: var(--color-primary-dark, #4e0902);
}

.btn-secondary {
    background-color: var(--color-surface, #ffffff);
    color: var(--color-text, #334155);
    border: 1px solid var(--color-border, #cbd5e1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-secondary:hover {
    background-color: var(--color-bg, #f8fafc);
    border-color: var(--color-border, #94a3b8);
    color: var(--color-text, #0f172a);
}

.create-client-btn {
    background-color: var(--color-surface, #ffffff);
    color: var(--color-primary, #680d03);
    border: 1px solid var(--color-border, #cbd5e1);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.create-client-btn:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
    color: #8b1104;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.create-client-btn:active {
    transform: translateY(0);
}

.create-client-btn svg,
.create-client-btn i {
    width: 18px;
    height: 18px;
    font-size: 1rem;
}

/* ===== AUTOCOMPLETE ===== */
.autocomplete-container {
    position: relative;
    width: 100%;
}

.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    margin-top: 2px;
}

.suggestions-dropdown.visible {
    display: block;
}

.suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background-color: #f0f7ff;
}

.suggestion-item .client-name {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.suggestion-item .client-details {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
}

.no-results {
    padding: 12px;
    text-align: center;
    color: #999;
    font-style: italic;
}

.loading-suggestions {
    padding: 12px;
    text-align: center;
    color: #999;
}

.loading-suggestions::after {
    content: "...";
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

/* ===== SALDO ANTERIOR COLOR ===== */
#resumenSaldoAnterior {
    color: #af0909 !important;
    font-weight: 600;
}

/* ============================================================
   📱 RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
    .client-row {
        gap: 6px;
    }

    .client-actions {
        justify-content: flex-end;
        gap: 6px;
    }

    .calculator-buttons {
        gap: 5px;
        grid-template-rows: repeat(4, 42px);
    }

    .calc-btn {
        padding: 3px 2px;
        font-size: 1rem;
    }

    .big-btn {
        font-size: 1.25rem;
    }

    .data-table td {
        min-height: 38px;
    }

    .data-table input {
        padding: 6px 8px;
        font-size: 0.95rem;
    }

    .data-table .auto-expand {
        min-height: 38px;
        padding: 6px 8px;
        font-size: 1.1rem !important;
    }
}


/* Transición suave para la calculadora */
.calculator-container {
    transition: all 0.3s ease-in-out;
    opacity: 1;
    max-height: 500px;
}

.calculator-container.hidden {
    display: none;
    opacity: 0;
    max-height: 0;
}

/* Asegurar que el contenedor cliente se ajuste correctamente */
.client-container {
    transition: flex 0.3s ease-in-out;
}

/* ==========================================================================
   ESTADOS DE VALIDACIÓN VISUAL DE ENTRADAS (VÁLIDA, INCOMPLETA, VACÍA)
   ========================================================================== */

.data-table tr.entry-header.row-incomplete td:first-child,
.data-table tr.entry-value.row-incomplete td:first-child {
    border-left: 4px solid #f59e0b !important;
    background-color: rgba(245, 158, 11, 0.035);
}

.data-table tr.entry-header.row-incomplete td.entry-summary-col {
    border-right: 3px solid #f59e0b !important;
    background-color: #fdfbf7;
}

/* Fila seleccionada: fondo uniforme en toda la fila (incluyendo la celda de resumen) */
.data-table tr.selected-entry,
.data-table tr.selected-entry:hover,
.data-table tr.selected-entry td,
.data-table tr.selected-entry td:first-child,
.data-table tr.selected-entry td.entry-summary-col,
.data-table tr.entry-header.selected-entry td.entry-summary-col,
.data-table tr.entry-value.selected-entry td.entry-summary-col {
    background-color: #fff3cd !important;
}

.data-table tr.selected-entry td.entry-summary-col input {
    background-color: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.data-table tr.selected-entry input:focus,
.data-table tr.selected-entry textarea:focus,
.data-table tr.selected-entry .auto-expand:focus {
    background-color: #fff3cd !important;
    border: 1.5px solid #d4a017 !important;
    outline: none !important;
    box-shadow: none !important;
}

.data-table tr.selected-entry td.entry-summary-col input:focus {
    background-color: transparent !important;
    border: 1px solid transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.data-table tr.selected-entry input[data-type="precio"] {
    background-color: transparent !important;
}

.data-table tr.entry-header.row-valid td:first-child,
.data-table tr.entry-value.row-valid td:first-child {
    border-left: 3px solid #10b981 !important;
}

.entry-summary-cell-content {
    min-height: 75px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.2s ease;
}

.entry-summary-fields {
    display: flex;
    flex-direction: column;
    gap: 5px;
    animation: fadeInFast 0.2s ease-in-out;
}

.entry-row-status {
    width: 100%;
    animation: fadeInFast 0.2s ease-in-out;
}

@keyframes fadeInFast {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.entry-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
    line-height: 1.25;
    cursor: default;
    user-select: none;
    transition: all 0.2s ease;
}

.entry-status-badge.badge-expanded {
    font-size: 0.82rem;
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    letter-spacing: 0.2px;
    cursor: pointer;
}

.entry-status-badge.badge-multiline {
    flex-direction: column;
    gap: 1px;
    padding: 5px 10px;
    line-height: 1.15;
    text-align: center;
}

.entry-status-badge .badge-sub {
    font-size: 0.73rem;
    font-weight: 500;
    opacity: 0.88;
}

.data-table tr.entry-header,
.data-table tr.entry-value {
    cursor: pointer;
}

.entry-status-badge.badge-incomplete {
    background-color: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
    box-shadow: 0 1px 2px rgba(180, 83, 9, 0.05);
}

.entry-status-badge.badge-guide {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    box-shadow: 0 1px 2px rgba(29, 78, 216, 0.06);
}

.entry-status-badge.badge-empty {
    background-color: #f3f4f6;
    color: #9ca3af;
    border: 1px solid #e5e7eb;
}

/* ==========================================================================
   POPOVER INFORMATIVO DIDÁCTICO PARA CHIPS DE RESUMEN
   ========================================================================== */

.chip-help-popover {
    position: fixed;
    z-index: 1050;
    width: 290px;
    max-width: calc(100vw - 24px);
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.18), 0 4px 10px -2px rgba(0, 0, 0, 0.08);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: inherit;
    box-sizing: border-box;
    animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chip-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 6px;
}

.chip-popover-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.chip-popover-close {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s;
}

.chip-popover-close:hover {
    color: #0f172a;
    background-color: #f1f5f9;
}

.chip-popover-body {
    padding: 2px 0;
}

.chip-popover-desc {
    margin: 0;
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.45;
}

.chip-popover-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 2px;
    padding-top: 6px;
    border-top: 1px solid #f8fafc;
}

.chip-popover-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    color: #64748b;
    cursor: pointer;
    user-select: none;
}

.chip-popover-checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
    accent-color: var(--color-primary, #680d03);
}

.chip-popover-action-btn {
    background-color: var(--color-primary, #680d03);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.18s, transform 0.1s;
}

.chip-popover-action-btn:hover {
    background-color: var(--color-primary-hover, #831608);
}

.chip-popover-action-btn:active {
    transform: scale(0.98);
}