* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    max-width: 100%;
    overflow-x: hidden; /* candado: ningun elemento ancho (ej. la vista previa de 800px) genera scroll horizontal de pagina */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    line-height: 1.5;
}

.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: #1a1a1a;
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #333;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #ccc;
}

.sidebar nav {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-btn {
    background: none;
    border: none;
    color: #999;
    padding: 10px 14px;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: #2a2a2a;
    color: #fff;
}

.nav-btn.active {
    background: #2a2a2a;
    color: #fff;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.section-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
}

/* Buttons */
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #1a1a1a;
    color: #fff;
}

.btn-primary:hover {
    background: #333;
}

.btn-secondary {
    background: #e8e8e8;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-remove {
    background: #f0f0f0;
    border: 1px solid #ddd;
    color: #666;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    background: #e0e0e0;
    color: #c00;
}

/* Split View */
.split-view {
    display: flex;
    gap: 24px;
    height: calc(100vh - 140px);
}

.form-panel {
    flex: 3;
    min-width: 0;
    overflow-y: auto;
    padding-right: 8px;
}

.preview-panel {
    flex: 2;
    min-width: 0;
    max-width: 480px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100%;
}

.preview-label {
    padding: 8px 12px;
    font-size: 12px;
    color: #888;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-zoom {
    background: #fff;
    border: 1px solid #d0d0d0;
    color: #555;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}

.btn-zoom:hover { background: #f0f0f0; }

.document-preview {
    flex: 1;
    padding: 0;
    overflow: hidden;
    overflow-y: auto;
    background: #f0f0f0;
}

/* La vista previa muestra SIEMPRE el documento a su ancho real (800px) y lo
   escala con JS para que quepa en el panel. Es una replica exacta del PDF.
   El documento del PDF se renderiza en otro div (fuera de pantalla) que NO
   coincide con estos selectores, por lo que la vista previa no lo afecta. */
#document-preview .doc-preview,
#cot-document-preview .doc-preview {
    width: 800px;
    background: #fff;
    padding: 20px 30px;
    transform-origin: top left;
}

/* Forms */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
    background: #fff;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #666;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 16px 0;
}

h3 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

/* Partidas */
.partida-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.partida-desc {
    flex: 3;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 13px;
}

.partida-cant {
    flex: 0 0 48px;
    padding: 8px 8px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

.partida-precio {
    flex: 0 0 72px;
    padding: 8px 8px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 13px;
    text-align: right;
}

.totales-form {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 2px solid #333;
}

.totales-form .form-row {
    justify-content: flex-end;
    margin-bottom: 4px;
    gap: 100px;
}

.totales-form .form-row label {
    font-size: 13px;
    color: #555;
}

.totales-form .form-row span {
    font-size: 14px;
    font-weight: 500;
    min-width: 100px;
    text-align: right;
}

.totales-form .total {
    font-size: 16px;
    font-weight: 700;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid #d0d0d0;
}

/* =========== DOCUMENT PREVIEW (PDF simulation) =========== */
.doc-preview {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: #1a1a1a;
    font-size: 12px;
    line-height: 1.5;
}

.doc-preview .doc-header {
    display: flex;
    flex-direction: column;
    padding-bottom: 14px;
    margin-bottom: 24px;
    border-bottom: 2px solid #1a1a1a;
}

.doc-preview .doc-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 90px;
}

.doc-preview .doc-title-inline {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.doc-preview .doc-logo {
    max-width: 240px;
    max-height: 90px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.doc-preview .doc-empresa {
    text-align: right;
}

.doc-preview .doc-empresa .empresa-nombre {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.doc-preview .doc-empresa .empresa-datos {
    font-size: 11px;
    color: #555;
    line-height: 1.6;
}

.doc-preview .doc-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 14px 16px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
}

.doc-preview .doc-info p {
    margin-bottom: 2px;
    font-size: 11px;
    color: #555;
}

.doc-preview .doc-info strong {
    color: #1a1a1a;
    font-size: 12px;
}

.doc-preview table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.doc-preview table th {
    background: #1a1a1a;
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.doc-preview table td {
    padding: 8px 12px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 11px;
}

.doc-preview table .col-cant,
.doc-preview table .col-precio,
.doc-preview table .col-total {
    text-align: right;
    width: 90px;
}

.doc-preview table .col-desc {
    text-align: left;
}

.doc-preview .doc-totals {
    margin-left: auto;
    width: 300px;
}

.doc-preview .doc-totals .total-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    font-size: 12px;
}

.doc-preview .doc-totals .total-row.final {
    font-weight: 700;
    font-size: 15px;
    border-top: 2px solid #1a1a1a;
    padding-top: 8px;
    margin-top: 4px;
}

.doc-preview .doc-numero-texto {
    margin-top: 10px;
    font-size: 11px;
    color: #555;
    font-style: italic;
}

.doc-preview .doc-terminos {
    margin-top: 12px;
    padding: 8px 10px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 3px;
}

.doc-preview .doc-terminos strong {
    font-size: 9px;
}

.doc-preview .doc-terminos p {
    font-size: 8px;
    color: #777;
    margin-top: 2px;
    white-space: pre-line;
    line-height: 1.3;
}

.doc-preview .doc-footer {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
    font-size: 11px;
    color: #555;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.doc-preview .doc-footer .firma-img {
    max-height: 60px;
    display: block;
}

/* Config */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.config-group {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px;
}

.config-group h3 {
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
}

/* Logo Upload */
.logo-upload-area {
    border: 2px dashed #d0d0d0;
    border-radius: 6px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    margin-bottom: 8px;
}

.logo-upload-area:hover {
    border-color: #999;
}

.logo-preview {
    max-width: 200px;
    max-height: 80px;
}

.logo-placeholder p {
    color: #999;
    font-size: 13px;
}

.logo-placeholder .small {
    font-size: 11px;
    color: #bbb;
    margin-top: 4px;
}

/* Signature */
.signature-container {
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.signature-container canvas {
    width: 100%;
    height: 250px;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

.signature-actions {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
}

.firma-guardada {
    margin-top: 8px;
    padding: 8px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.firma-guardada p {
    font-size: 11px;
    color: #555;
    margin-bottom: 4px;
}

.firma-guardada img {
    max-height: 40px;
    display: block;
    margin-bottom: 4px;
}

/* Extras / Toggles */
.extra-item {
    margin-bottom: 10px;
    padding: 10px 12px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: #d0d0d0;
    border-radius: 10px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-label input:checked + .toggle-switch {
    background: #1a1a1a;
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(16px);
}

.extra-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e8e8e8;
}

.extra-controls label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.extra-controls input[type="text"],
.extra-controls input[type="number"] {
    padding: 6px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 13px;
    width: 120px;
}

.extra-controls input[type="number"] {
    width: 100px;
    text-align: right;
}

/* Color selector for document */
.color-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.color-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: #1a1a1a;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a1a1a;
}

.color-btn .check {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
}

.color-btn.active .check {
    display: block;
}

.color-btn.clr-negro { background: #1a1a1a; }
.color-btn.clr-verde { background: #1b5e20; }
.color-btn.clr-azul { background: #0d47a1; }
.color-btn.clr-rojo { background: #b71c1c; }

/* Terminos */
.terminos-textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    color: #333;
    resize: vertical;
}

.terminos-textarea:focus {
    outline: none;
    border-color: #666;
}

/* Responsive */
@media (max-width: 900px) {
    .split-view {
        flex-direction: column;
        height: auto;
        width: 100%;
        max-width: 100%;
    }
    .form-panel {
        width: 100%;
        max-width: 100%;
        padding-right: 0;
        overflow: visible;
    }
    .preview-panel {
        max-width: none;
        min-width: 0;
        width: 100%;
        position: static;
        height: auto;
    }
    /* La vista previa (documento de 800px) se recorta SIEMPRE al ancho del panel.
       El JS la escala para que se vea completa y proporcional dentro de este marco. */
    .document-preview {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    .config-grid {
        grid-template-columns: 1fr;
    }
}

/* Firma tabs */
.firma-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
}

.firma-tab {
    background: none;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.firma-tab:hover {
    color: #333;
}

.firma-tab.active {
    color: #1a1a1a;
    font-weight: 600;
    border-bottom-color: #1a1a1a;
}

/* Mini header PDF (páginas 2+) */
.doc-header-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 16px;
    border-bottom: 2px solid #1a1a1a;
    font-size: 11px;
    color: #555;
}

.doc-header-mini .mini-empresa {
    font-weight: 700;
    font-size: 14px;
    color: #1a1a1a;
}

.doc-header-mini .mini-folio {
    text-align: right;
    font-size: 12px;
    color: #555;
}


/* =========== MENU HAMBURGUESA (movil) =========== */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: #1a1a1a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.hamburger-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
}

.sidebar-overlay.visible {
    display: block;
}

/* =========== RESPONSIVE: TABLET / MOVIL GRANDE (<= 900px) =========== */
@media (max-width: 900px) {
    .hamburger-btn {
        display: flex;
    }

    .app {
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 160;
    }

    .sidebar.abierto {
        transform: translateX(0);
    }

    .main-content {
        padding: 16px;
        padding-top: 64px; /* deja espacio para el boton hamburguesa */
        overflow-y: visible;
    }

    .section-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .section-header h1 {
        font-size: 18px;
    }
}

/* =========== RESPONSIVE: MOVIL (<= 600px) =========== */
@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Folio y fecha SÍ deben ir a la par en movil */
    .section#seccion-nueva .form-row:has(#factura-folio),
    .section#seccion-cotizacion .form-row:has(#cot-folio) {
        flex-direction: row;
        gap: 8px;
    }

    /* Partidas mas compactas */
    .partida-row {
        flex-wrap: nowrap;
        gap: 4px;
        align-items: center;
    }
    .partida-desc { flex: 1 1 auto; min-width: 0; padding: 6px 8px; font-size: 12px; }
    .partida-cant { flex: 0 0 38px; padding: 6px 2px; font-size: 12px; width: 38px; min-width: 0; }
    .partida-precio { flex: 0 0 60px; padding: 6px 4px; font-size: 12px; width: 60px; min-width: 0; }
    .partida-row .btn-remove { flex: 0 0 26px; width: 26px; height: 26px; font-size: 10px; }

    /* Totales mas compactos: labels y valores visibles en la misma linea */
    .totales-form .form-row {
        gap: 4px;
        justify-content: space-between;
        flex-direction: row !important;
    }
    .totales-form .form-row label {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 0 1 auto;
    }
    .totales-form .form-row span {
        font-size: 12px;
        min-width: 50px;
        text-align: right;
        flex-shrink: 0;
        margin-right: 4px;
    }
    .totales-form .total span {
        font-size: 13px;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }

    /* Extras compactos */
    .extra-item { padding: 6px 8px; margin-bottom: 6px; }
    .extra-controls {
        flex-wrap: nowrap;
        gap: 4px;
        margin-top: 4px;
        padding-top: 4px;
    }
    .extra-controls label { font-size: 9px; }
    .extra-controls input[type="text"] { flex: 1 1 auto; min-width: 0; width: auto; padding: 5px 6px; font-size: 11px; }
    .extra-controls input[type="number"] {
        flex: 0 0 65px;
        width: 65px;
        max-width: 65px;
        padding: 5px 4px;
        font-size: 11px;
        text-align: right;
    }
    .signo-btn {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }

    /* Encabezado mas compacto: boton Enviar y Descargar no ocupan todo el ancho */
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .section-header h1 {
        font-size: 16px;
    }
    .header-actions {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 6px;
    }
    .header-actions .btn {
        width: 100%;
        padding: 8px 10px;
        font-size: 12px;
    }

    .section-header > .btn { width: 100%; }

    /* En movil ocultamos el panel de vista previa del PDF */
    .preview-panel {
        display: none;
    }
}

/* =========================================================================
   NUEVOS COMPONENTES
   ========================================================================= */

/* Header con varias acciones */
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Numeros compactos: el usuario maneja cantidades cortas (sin tantos ceros) */
.input-num {
    max-width: 120px;
}
.totales-form .form-row span {
    min-width: 70px;
}
.partida-cant { flex: 0 0 48px; }
.partida-precio { flex: 0 0 72px; }
.extra-controls input[type="number"] { width: 90px; max-width: 110px; }

/* Boton ± para descuentos (cambiar signo del monto) */
.signo-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: 1px solid #d0d0d0;
    background: #fff;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    color: #555;
    cursor: pointer;
}
.signo-btn:hover { background: #f0f0f0; }
.signo-btn.activo { background: #b71c1c; border-color: #b71c1c; color: #fff; }

/* ===== Cuenta en el sidebar ===== */
.sidebar-account {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid #333;
}
.btn-account {
    width: 100%;
    background: #fff;
    color: #1a1a1a;
    border: none;
    padding: 9px 12px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.btn-account.secondary {
    background: #2a2a2a;
    color: #ddd;
}
.btn-account:hover { opacity: 0.9; }
.mensaje-creadopor { font-size: 12px; color: #d4d3d3; margin-top: 6px; text-align: center; }
.account-hint { font-size: 11px; color: #777; margin-top: 6px; text-align: center; }
.account-email {
    font-size: 12px;
    color: #fff;
    word-break: break-all;
    margin-bottom: 4px;
    font-weight: 600;
}
.account-sync { font-size: 10px; color: #6abf69; margin-bottom: 8px; }

/* ===== Dashboard ===== */
.dash-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
.stat-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
}
.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #888;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.1;
}
.stat-sub { font-size: 12px; color: #999; margin-top: 4px; }

/* ===== Historial ===== */
.hist-filtros { display: flex; gap: 6px; }
.chip {
    background: #eee;
    border: 1px solid #e0e0e0;
    color: #666;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
}
.chip.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.hist-search { margin-bottom: 14px; }
.hist-search input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
}
.hist-list { display: flex; flex-direction: column; gap: 10px; }
.hist-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 16px;
}
.hist-main { flex: 1; min-width: 0; }
.hist-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.4px;
}
.badge-fac { background: #e3f2e3; color: #1b5e20; }
.badge-cot { background: #e3edfb; color: #0d47a1; }
.hist-folio { font-size: 12px; color: #999; font-weight: 600; }
.hist-cliente { font-size: 15px; font-weight: 600; color: #1a1a1a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-meta { font-size: 12px; color: #999; margin-top: 2px; }
.hist-total { font-size: 17px; font-weight: 700; color: #1a1a1a; white-space: nowrap; }
.hist-acciones { display: flex; gap: 6px; flex-shrink: 0; }
.mini-btn {
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
    color: #444;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
}
.mini-btn:hover { background: #e2e2e2; }
.mini-btn.danger { color: #b71c1c; }
.mini-btn.danger:hover { background: #fbe3e3; }
.hist-vacio, .hist-vacio-inline { color: #999; }
.hist-vacio { text-align: center; padding: 40px 20px; }
.hist-vacio .small { font-size: 12px; color: #bbb; margin-top: 6px; }
.hist-vacio-inline { font-size: 13px; padding: 16px; background: #fff; border: 1px dashed #ddd; border-radius: 8px; }
.hist-sin-resultados { color: #999; font-size: 13px; padding: 16px; }

/* ===== Modales ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
    position: relative;
    max-height: 92vh;
    overflow-y: auto;
}
.modal h2 { font-size: 19px; margin-bottom: 6px; }
.modal-sub { font-size: 13px; color: #888; margin-bottom: 18px; }
.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 26px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #666;
    margin: 14px 0 8px;
}
.btn-full { width: 100%; margin-top: 6px; }
.auth-error {
    background: #fbe3e3;
    color: #b71c1c;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}
.auth-switch { text-align: center; font-size: 13px; color: #777; margin-top: 14px; }
.auth-switch a { color: #0d47a1; text-decoration: none; font-weight: 600; }

/* Control segmentado (formato PDF/PNG) */
.seg-control {
    display: flex;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 3px;
}
.seg-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
}
.seg-btn.active { background: #fff; color: #1a1a1a; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Botones de envio */
.enviar-opciones { display: flex; flex-direction: column; gap: 8px; }
.enviar-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    color: #1a1a1a;
    cursor: pointer;
    text-align: left;
}
.enviar-btn:hover { background: #f7f7f7; border-color: #ccc; }
.enviar-ico {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.enviar-ico.wa { background: #25d366; }
.enviar-ico.mail { background: #d44638; }
.enviar-ico.share { background: #555; }
.enviar-estado { font-size: 13px; color: #1b5e20; margin-top: 12px; min-height: 18px; }
.enviar-nota { font-size: 11px; color: #aaa; margin-top: 10px; line-height: 1.4; }

/* ===== Zoom vista previa ===== */
#modal-zoom { overflow: auto; align-items: flex-start; }
.zoom-content {
    background: #fff;
    margin: 24px auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    overflow: hidden;
}
.zoom-close {
    position: fixed;
    top: 14px;
    right: 20px;
    color: #fff;
    font-size: 34px;
    z-index: 320;
}

/* ===== Plantillas ===== */
.plantillas-aviso {
    background: #fffbe6;
    border: 1px solid #e0c200;
    color: #7a6a00;
    font-size: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.plantillas-layout { display: flex; gap: 16px; align-items: flex-start; }
.plantillas-lista {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}
.plantilla-item {
    text-align: left;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    color: #444;
    cursor: pointer;
}
.plantilla-item:hover { background: #f5f5f5; }
.plantilla-item.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.plantillas-editor { flex: 1; min-width: 0; }
.plantillas-editor-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.plantillas-editor-bar > span { font-weight: 600; font-size: 14px; }
.plantilla-texto {
    width: 100%;
    min-height: 60vh;
    padding: 18px 20px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #222;
    resize: vertical;
    white-space: pre-wrap;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1a1a1a;
    color: #fff;
    padding: 12px 22px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 400;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    max-width: 90vw;
    text-align: center;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #1b5e20; }
.toast.error { background: #b71c1c; }

/* ===== Responsive de los nuevos componentes ===== */
@media (max-width: 900px) {
    .dash-stats { grid-template-columns: repeat(2, 1fr); }
    .plantillas-layout { flex-direction: column; }
    .plantillas-lista { flex: none; width: 100%; max-height: 220px; flex-direction: row; flex-wrap: wrap; }
    .plantilla-item { flex: 1 1 45%; }
}
@media (max-width: 600px) {
    .dash-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-value { font-size: 20px; }
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1; }
    .hist-card { flex-wrap: wrap; }
    .hist-main { flex: 1 1 60%; }
    .hist-total { flex: 0 0 auto; }
    .hist-acciones { flex: 1 1 100%; }
    .hist-acciones .mini-btn { flex: 1; }
    .plantilla-item { flex: 1 1 100%; }
}
/* ===== Contacto ===== */
.contacto-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 24px;
    max-width: 800px;
}

.contacto-logo {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: #666;
    margin-bottom: 16px;
}

.contacto-titulo {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.contacto-subtitulo {
    font-size: 14px;
    color: #888;
    margin-bottom: 24px;
}

.contacto-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.contacto-item {
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 14px;
}

.contacto-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #888;
    margin-bottom: 6px;
}

.contacto-value {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    word-break: break-word;
}

.contacto-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
    font-size: 13px;
    color: #777;
}

/* Responsive */
@media (max-width: 700px) {
    .contacto-grid {
        grid-template-columns: 1fr;
    }

    .contacto-card {
        padding: 18px;
    }

    .contacto-titulo {
        font-size: 20px;
    }
}
.contacto-item a {
    color: #1403ff;
    text-decoration: none;
    font-weight: 500;
}

.contacto-item-mercadopago {
      color: #a1a1a1;
    text-align: left;
    font-weight: 100; 
    font-size: small;
}
.btn-donar{
    display:inline-block;
    margin-top:1px;
    padding:5px 30px;
    background:linear-gradient(120deg,#e8f70e75,rgba(249, 253, 17, 0.575));
    color:#fff;
    text-decoration:none;
    font-size:14px;
    font-weight:600;
    border-radius:9px;
    transition:.3s;
}

.btn-donar:hover{
    transform:scale(1.15);
}
.contacto-item a:hover {
    text-decoration: underline;
}
.contacto-logo{
    width: 160px;   /* antes 120px o menos */
    height: auto;
    display: block;
    margin: 0 auto 20px;
     background: #ffffff;
}
.footer {
    background: #111;
    color: #fff;
    padding: 12px 20px;
    margin-top: 2px;
    font-family: Arial, sans-serif;
}

.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-left h3 {
    margin: 0;
    font-size: 10px;
    color: #00d4ff;
}

.footer-left p {
    margin: 5px 0 0;
    font-size: 11px;
    opacity: 0.8;
}

.footer-center {
    font-size: 12px;
    opacity: 0.8;
    text-align: center;
    flex: 1;
}


.footer-right a:hover {
    opacity: 1;
    color: #00d4ff;
}