/* Шапка-счёт над отчётом — реквизиты, сумма, QR ST00012. */

.invoice-header {
    /* По умолчанию шапка-счёт скрыта на экране — нужна только при печати
       (in-app print-mode или браузерный Cmd+P). При печати правила ниже
       перекрывают display:none. */
    display: none;
    grid-template-columns: 1fr auto;
    gap: 24px;
    align-items: stretch;
    padding: 16px 20px;
    margin: 0 0 16px 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Показ при печати: in-app .print-mode и нативный @media print. */
body.print-mode .invoice-header {
    display: grid !important;
}

.invoice-header-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.invoice-header-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 8px;
}

.invoice-serial {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    letter-spacing: 0.02em;
}

.invoice-period {
    font-size: 13px;
    color: #6b7280;
    text-transform: lowercase;
}

.invoice-header-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.invoice-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.invoice-col-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    margin-bottom: 2px;
}

.invoice-col-value {
    font-size: 13px;
    color: #1f2937;
    line-height: 1.3;
}

.invoice-col-value b {
    font-weight: 600;
}

.invoice-col-meta {
    font-size: 11px;
    color: #475569;
    line-height: 1.4;
}

.invoice-col-meta b {
    color: #1f2937;
    font-weight: 600;
}

.invoice-amount-block {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.invoice-amount-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
}

.invoice-amount-value {
    font-size: 24px;
    font-weight: 800;
    color: #1f2937;
    letter-spacing: -0.02em;
    line-height: 1;
}

.invoice-amount-breakdown {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
    margin-top: 2px;
}

.invoice-breakdown-base {
    color: #1f2937;
    font-weight: 600;
}

.invoice-breakdown-extra {
    color: #1565c0;
    font-weight: 600;
}

.invoice-discount {
    font-size: 11px;
    color: #2e7d32;
    font-weight: 600;
}

.invoice-paid {
    margin-top: 4px;
    display: inline-block;
    padding: 4px 10px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    align-self: flex-start;
}

/* === Предупреждение об источнике платежа === */
.invoice-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    background: #fff7ed;
    border-left: 3px solid #f97316;
    border-radius: 4px;
    color: #9a3412;
    font-size: 11px;
    line-height: 1.4;
}

.invoice-warning-icon {
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    color: #ea580c;
}

.invoice-warning-text {
    flex: 1;
}

.invoice-warning-text b {
    color: #7c2d12;
    font-weight: 700;
}

/* === QR-блок справа === */
.invoice-header-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    min-width: 200px;
}

.invoice-qr-wrapper {
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.invoice-qr-wrapper svg {
    width: 100%;
    height: 100%;
    display: block;
}

.invoice-qr-hint {
    font-size: 10px;
    color: #6b7280;
    text-align: center;
    line-height: 1.4;
}

.invoice-qr-paid {
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #2e7d32;
    font-weight: 600;
    font-size: 13px;
    background: #e8f5e9;
    border-radius: 6px;
    padding: 12px;
}

/* === Адаптация === */
@media (max-width: 700px) {
    .invoice-header {
        grid-template-columns: 1fr;
    }

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

    .invoice-header-qr {
        align-self: center;
    }
}

/* === Печать (in-app + native) === */
@media print {
    .invoice-header {
        display: grid !important;
        box-shadow: none !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

body.print-mode .invoice-header {
    box-shadow: none !important;
    page-break-inside: avoid;
    break-inside: avoid;
}
