/* =========================
   FacturasPro / Facturas
   Hoja de estilos ordenada
   ========================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #eef2f7;
    color: #1d2733;
}

.app {
    min-height: 100vh;
    padding: 24px;
}

.panel {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .08);
}

.lead {
    margin: 0 0 24px;
    color: #556372;
}

.card {
    margin-bottom: 24px;
    padding: 18px;
    border: 1px solid #dde5ef;
    border-radius: 14px;
    background: #fbfcfe;
}

/* =========================
   Formularios
   ========================= */

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.field label,
.field span {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
}

.field input,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccd5df;
    border-radius: 10px;
    font-size: 14px;
}

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

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

.triple {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.inline-options {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding-top: 24px;
}

.inline-options label {
    margin: 0;
    font-weight: 500;
}

.inline-options input {
    width: auto;
}

.line-item {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 110px 1.8fr 180px 180px;
    gap: 12px;
}

.money-input-wrap {
    position: relative;
    display: block;
}

.money-input-wrap::before {
    content: attr(data-prefix);
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #555;
    font-size: 14px;
    z-index: 2;
}

.money-input-wrap input {
    padding-left: 42px;
}

/* =========================
   Acciones / botones
   ========================= */

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.actions button,
.small-btn,
.toolbar a {
    background: #243ca8;
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 12px 18px;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    display: inline-block;
}

.small-btn {
    padding: 8px 12px;
}

/* =========================
   Tablas / alertas
   ========================= */

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid #e2e7ef;
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

.warn-tag {
    color: #b53a1b;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 18px;
}

.alert.success {
    background: #eaf8ed;
    color: #1d6b2f;
}

.alert.error {
    background: #fdeaea;
    color: #9b1d1d;
}

.alert.warning {
    background: #fff6e7;
    color: #8c5b00;
}

.alert.info {
    background: #e8f1ff;
    color: #184f9c;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/* =========================
   Toolbar / hoja
   ========================= */

.toolbar {
    padding: 16px;
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    background: #f3f6fb;
    border-bottom: 1px solid #dbe4ef;
}

.sheet-area {
    padding: 24px 0 40px;
    display: flex;
    justify-content: center;
}

.print-sheet-area {
    padding: 0;
}

.sheet {
    position: relative;
    width: 216mm;
    max-width: 100%;
    min-height: 279.4mm;
    background: white;
}

.print-sheet {
    width: 216mm;
    min-height: 279.4mm;
    background: transparent;
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 216mm;
    height: 279.4mm;
}

/* =========================
   Texto impreso / marcas
   ========================= */

.text,
.mark {
    position: absolute;
    color: #111;
    font-size: 3.4mm;
    line-height: 1.1;
}

.date {
    top: 30.5mm;
    width: 16mm;
    text-align: center;
}

.dia {
    left: 8.5mm;
}

.mes {
    left: 25.2mm;
}

.anio {
    left: 39.9mm;
}

.contado {
    top: 30mm;
    left: 148.8mm;
}

.credito {
    top: 30mm;
    left: 173.8mm;
}

.dolares {
    top: 50.8mm;
    left: 183.2mm;
}

.cordobas {
    top: 42mm;
    left: 200mm;
}

.mark {
    font-size: 4.5mm;
    font-weight: 700;
    opacity: 0;
}

.mark.active {
    opacity: 1;
}

.cliente {
    top: 37.2mm;
    left: 30mm;
    width: 105mm;
}

.ruc-cliente {
    top: 37.2mm;
    left: 147mm;
    width: 56mm;
}

.direccion {
    top: 42.5mm;
    left: 30mm;
    width: 105mm;
}

.telefono {
    top: 42.5mm;
    left: 134mm;
    width: 45mm;
}

.item.cantidad {
    left: 7.5mm;
    width: 18mm;
    text-align: center;
}

.item.descripcion {
    left: 30mm;
    width: 120mm;
}

.item.precio {
    left: 151mm;
    width: 28mm;
    text-align: center;
}

.item.total {
    left: 178.5mm;
    width: 26mm;
    text-align: center;
}

.item.i1 {
    top: 61.5mm;
}

.item.i2 {
    top: 70mm;
}

.item.i3 {
    top: 78.5mm;
}

.item.i4 {
    top: 87mm;
}

.item.i5 {
    top: 95.5mm;
}

.item.i6 {
    top: 104mm;
}

.item.i7 {
    top: 112.5mm;
}

.item.i8 {
    top: 121mm;
}

.ultima-linea {
    left: 30mm;
    width: 120mm;
    text-align: center;
    font-size: 3.2mm;
}

.subtotal {
    top: 217.5mm;
    left: 176mm;
    width: 29mm;
    text-align: center;
}

.total-final {
    top: 223.7mm;
    left: 176mm;
    width: 29mm;
    text-align: center;
    font-weight: 700;
}

/* =========================
   Guía visual / notas
   ========================= */

.template-guide {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}

.base-image {
    position: absolute;
    top: -8mm;
    left: 1mm;
    width: 217.5mm;
    height: 285.4mm;
    max-width: none;
    display: block;
}

.calibration-note,
.print-mode-note {
    max-width: 1100px;
    margin: 16px auto 0;
    padding: 12px 16px;
    border-radius: 10px;
    background: #eef4ff;
    border: 1px solid #d4e1ff;
    color: #23395d;
}

/* =========================
   Vista en pantalla
   ========================= */

@media screen {
    .print-sheet {
        background: white;
    }
}

/* =========================
   Responsivo
   ========================= */

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

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

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

    .actions {
        flex-direction: column;
    }
}

/* =========================
   Impresión
   ========================= */

@media print {
    .template-guide,
    .base-image,
    .calibration-note,
    .print-mode-note {
        display: none !important;
        visibility: hidden !important;
    }

    @page {
        size: letter portrait;
        margin: 0;
    }

    html,
    body {
        width: 216mm !important;
        height: 279.4mm !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        overflow: hidden !important;
    }

    .no-print,
    .toolbar,
    .app,
    .panel,
    .lead {
        display: none !important;
        visibility: hidden !important;
    }

    .sheet-area,
    .print-sheet-area {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 216mm !important;
        height: 279.4mm !important;
    }

    .sheet,
    .print-sheet {
        position: relative !important;
        width: 216mm !important;
        min-height: 279.4mm !important;
        height: 279.4mm !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        overflow: hidden !important;
    }

    .overlay {
        position: absolute !important;
        inset: 0 !important;
        width: 216mm !important;
        height: 279.4mm !important;
        z-index: 10 !important;
    }
}
