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

body {
    font-family: 'Poppins', sans-serif;
    background: #f5f5f5;
    padding: 5px;
}

.main-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    max-height: 700px;
    overflow-y: auto;
}

.left-panel,
.right-panel {
    padding: 5px;
}

.left-panel {
    border-right: 2px solid #f0f0f0;
    background: #fafafa;
}

.right-panel {
    background: white;
}

h2 {
    color: #148bd0;
    margin-bottom: 10px;
    font-size: 24px;
}

.form-group {
    margin-bottom: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-row .form-group {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    transition: border-color 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #148bd0;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.items-section {
    margin: 25px 0;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 10px;
    margin-bottom: 15px;
    align-items: end;
}

.item-actions {
    display: flex;
    gap: 5px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-add {
    background: #148bd0;
    color: white;
}

.btn-add:hover {
    background: #0f6fa8;
}

.btn-remove {
    background: #ff4757;
    color: white;
}

.btn-remove:hover {
    background: #d63447;
}

.preview-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.preview-items {
    margin-bottom: 15px;
}

.preview-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.preview-totals {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #3c73b8;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 15px;
}

.total-row.grand-total {
    font-size: 18px;
    font-weight: 700;
    color: #148bd0;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px solid #148bd0;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary {
    background: #148bd0;
    color: white;
}

.btn-primary:hover {
    background: #0f6fa8;
}

.btn-success {
    background: #2ecc71;
    color: white;
}

.btn-success:hover {
    background: #27ae60;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow-y: auto;
    padding: 40px 20px;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.modal-content {
    background: white;
    max-width: 900px;
    width: 100%;
    margin: auto;
}

.modal-header {
    padding: 20px 30px;
    background: #148bd0;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    line-height: 1;
}

/* A4 Invoice Styles */
:root {
    --a4-width: 210mm;
    --a4-height: 297mm;
    --a4-width-px: 794px;
    --a4-height-px: 1123px;
}

.invoice-a4 {
    width: var(--a4-width);
    min-height: var(--a4-height);
    padding: 20mm;
    background: white;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.invoice-a4::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40%;
    height: 40%;
    background: url('logobg.png') no-repeat center center;
    background-size: contain;
    opacity: 0.05;
    pointer-events: none;
}

.invoice-a4>* {
    position: relative;
    z-index: 1;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}

.company-info h1 {
    font-family: 'Funnel Display', sans-serif;
    color: #148bd0;
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
}

.company-info .tagline {
    font-size: 12px;
    color: #666;
    margin-bottom: 15px;
}

.company-info .address {
    font-size: 11px;
    color: #333;
    line-height: 1.6;
}

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

.logo-img {
    width: 150px;
    height: auto;
    margin-bottom: 15px;
}

.invoice-box {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.invoice-box p {
    margin: 5px 0;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.customer-section {
    margin: 30px 0;
}

.customer-section h3 {
    font-size: 27px;
    color: #333;
    margin-bottom: 10px;
}

.customer-section p {
    font-size: 16px;
    color: #666;
    line-height: 1.6;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
}

.invoice-table thead {
    background: #3c73b8;
    color: white;
}

.invoice-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.invoice-table td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.invoice-table tr:last-child td {
    border-bottom: none;
}

.invoice-totals {
    margin-left: auto;
    width: 300px;
    margin-top: 20px;
}

.invoice-totals .total-line {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 16px;
}

.invoice-totals .total-line.final {
    border-top: 2px solid #333;
    font-weight: 700;
    font-size: 20px;
    color: #148bd0;
    margin-top: 10px;
    padding-top: 15px;
}

.invoice-footer {
    margin-top: 50px;
    text-align: center;
}

.thank-you {
    font-family: 'Dancing Script', cursive;
    font-size: 32px;
    color: #148bd0;
    margin-bottom: 20px;
}

.footer-text {
    font-size: 11px;
    color: #666;
    line-height: 1.8;
}

/* Mobile Responsive */
@media (max-width: 768px) {

    .content-wrapper {
        grid-template-columns: 1fr;
        max-height: none;
    }

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

    .left-panel {
        border-right: none;
        border-bottom: 2px solid #f0f0f0;
    }

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

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

    .invoice-a4 {
        width: 2480px;
        min-height: auto;
        padding: 15px;
    }

    .company-info h1 {
        font-size: 24px;
    }

    .invoice-header {
        flex-direction: column;
    }

    .invoice-meta {
        text-align: left;
        margin-top: 20px;
    }

    .invoice-a4 {
        width: 100%;
        min-height: auto;
    }
}

@media print {
    body * {
        visibility: hidden;
    }

    .invoice-a4,
    .invoice-a4 * {
        visibility: visible;
    }

    .invoice-a4 {
        position: absolute;
        left: 0;
        top: 0;
        width: var(--a4-width);
        min-height: var(--a4-height);
    }
}