:root {
    --primary-color: #D92027;
    --text-color: #2D3436;
    --border-color: #E5E7EB;
    --background-color: #F9FAFB;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--background-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-color);
}

/* Download Button */
.download-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--primary-color);
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 16px;
    border: none;
    transition: all 0.3s ease;
    z-index: 1000;
}

.download-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: #c41e24;
}

.download-button i {
    font-size: 18px;
}

/* A4 Container */
.container {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
    position: relative;
}

.invoice {
    padding: 25mm 20mm;
}

.title {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-color);
}

.header-box {
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
    border-radius: 4px;
}

.logo-box {
    display: flex;
    align-items: flex-start;
    padding: 15px;
}

.logo-container {
    background: #ce182a;
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    margin-right: 15px;
}

.logo-container img {
    width: 70px;
    height: 70px;
    object-fit: contain;
}

.company-info h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
}

.company-info p {
    font-size: 14px;
    color: #64748B;
    line-height: 1.5;
}

.billing-info {
    border: 1px solid var(--border-color);
    display: flex;
    margin-bottom: 15px;
    border-radius: 4px;
}

.bill-to {
    flex: 1;
    padding: 15px;
    border-right: 1px solid var(--border-color);
    font-weight: 500;
}

.invoice-details {
    width: 200px;
    padding: 15px;
}

.billed-period {
    margin: -5px 0 15px;
    padding-left: 15px;
    color: #64748B;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

th, td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: left;
    font-size: 14px;
}

th {
    background: var(--background-color);
    font-weight: 600;
}

.totals {
    margin: 20px 0;
}

.total-line {
    display: flex;
    margin-bottom: 8px;
    font-weight: 500;
}

.total-line span:first-child {
    width: 150px;
}

.total-line span:nth-child(2) {
    width: 20px;
}

.payment-info {
    position: relative;
    margin: 30px 0;
}

.payment-details {
    margin-bottom: 20px;
}

.payment-line {
    display: flex;
    margin-bottom: 8px;
}

.payment-line span:first-child {
    width: 150px;
}

.payment-line span:nth-child(2) {
    width: 20px;
}

.paid-stamp {
    position: absolute;
    right: 30px;
    top: -20px;
    transform: rotate(-15deg);
}

.paid-stamp img {
    width: 150px;
    height: auto;
    opacity: 0.9;
}

.terms {
    background: var(--background-color);
    padding: 20px;
    margin: 30px 0;
    border-radius: 4px;
}

.terms-header {
    font-weight: 600;
    margin-bottom: 10px;
}

.signature-section {
    margin-top: 40px;
    display: flex;
    justify-content: flex-end;
}

.signature-box {
    width: 100%;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
}

.signature-header {
    padding: 8px;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    color: var(--text-color);
    font-size: 15px;
}

.signature-content {
    padding: 20px;
    position: relative;
    min-height: 120px;
}

.left-content {
    position: absolute;
    left: 20px;
    top: 20px;
    text-align: left;
}

.signatory-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-color);
    margin-bottom: 5px;
}

.signatory-title {
    font-size: 15px;
    color: var(--text-color);
}

.right-content {
    position: absolute;
    right: 40px;
    bottom: 0;
    z-index: 2;
}

.right-content img {
    width: 130px;
    height: auto;
    opacity: 0.9;
}

.authorized-text {
    position: absolute;
    bottom: 15px;
   right: 42px;
    font-size: 14px;
    color: var(--text-color);
    z-index: 1;
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        background: none;
        padding: 0;
        margin: 0;
    }

    .container {
        width: 210mm;
        min-height: 297mm;
        padding: 0;
        margin: 0;
        box-shadow: none;
        page-break-after: always;
    }

    .invoice {
        padding: 25mm 20mm;
    }

    .download-button {
        display: none !important;
    }
}
