* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
}

.page-loading {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #666;
}

.loader {
    width: 34px;
    height: 34px;
    border: 4px solid #ddd;
    border-top-color: #111827;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.page {
    max-width: 860px;
    margin: 0 auto;
    padding: 28px 16px 60px;
}

.document-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.document-header {
    padding: 28px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.company-title {
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 6px;
}

.company-subtitle {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

.document-title {
    text-align: right;
}

.document-title h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.1;
}

.document-number {
    color: #6b7280;
    font-size: 14px;
    margin-top: 6px;
}

.status-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.document-body {
    padding: 28px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 26px;
}

.info-box {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px;
}

.info-box h3 {
    margin: 0 0 10px;
    font-size: 14px;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.04em;
}

.info-line {
    margin: 4px 0;
    font-size: 14px;
}

.message-box {
    background: #f9fafb;
    border-left: 4px solid #111827;
    padding: 14px 16px;
    margin-bottom: 24px;
    border-radius: 10px;
    white-space: pre-wrap;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.items-table th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 8px;
}

.items-table td {
    padding: 14px 8px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: top;
    font-size: 14px;
}

.item-name {
    font-weight: 700;
}

.item-description {
    color: #6b7280;
    font-size: 13px;
    margin-top: 4px;
    white-space: pre-wrap;
}

.text-right {
    text-align: right;
}

.totals {
    max-width: 320px;
    margin-left: auto;
    margin-bottom: 24px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.total-row.grand {
    border-top: 2px solid #111827;
    margin-top: 8px;
    padding-top: 12px;
    font-size: 20px;
    font-weight: 800;
}

.terms-box {
    border-top: 1px solid #e5e7eb;
    padding-top: 20px;
    color: #4b5563;
    font-size: 14px;
    white-space: pre-wrap;
}

.actions {
    padding: 22px 28px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary {
    background: #111827;
    color: #fff;
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.error-card {
    background: #fff;
    border-radius: 18px;
    padding: 28px;
    max-width: 480px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.error-card h1 {
    margin-top: 0;
}

.success-box {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 14px 16px;
    border-radius: 12px;
    margin-top: 16px;
}

@media (max-width: 700px) {
    .document-header {
        flex-direction: column;
    }

    .document-title {
        text-align: left;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .items-table th:nth-child(2),
    .items-table td:nth-child(2) {
        display: none;
    }

    .page {
        padding: 12px 8px 40px;
    }

    .document-body,
    .document-header,
    .actions {
        padding: 20px;
    }
}