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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.4;
}

.container {
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
}

.page-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.page-header h1 {
    color: #2c3e50;
    font-size: 28px;
    font-weight: 300;
    margin: 0;
    letter-spacing: 1px;
}

.invoice {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 40px;
    margin-bottom: 20px;
}

/* Invoice Header */
.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
    border-bottom: 1px solid #eee;
    padding-bottom: 30px;
}

.logo-section {
    flex: 1;
}

.logo-placeholder {
    width: 200px;
    height: 120px;
    border: 2px dashed #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.logo-placeholder:hover {
    border-color: #007bff;
    color: #007bff;
}

.logo-placeholder img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.invoice-title {
    text-align: right;
    flex: 1;
}

.invoice-title h1 {
    font-size: 48px;
    font-weight: 300;
    color: #333;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

.invoice-number {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.invoice-number label {
    font-size: 18px;
    color: #666;
}

.invoice-number input {
    border: 1px solid #ddd;
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 4px;
    width: 100px;
}

/* Invoice Details */
.invoice-details {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
}

.from-section {
    flex: 2;
}

.from-section textarea {
    width: 100%;
    height: 80px;
    border: 1px solid #ddd;
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    border-radius: 4px;
    resize: vertical;
}

.invoice-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-row label {
    font-weight: 500;
    color: #666;
    font-size: 14px;
}

.info-row input {
    border: 1px solid #ddd;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 4px;
}

/* Billing Section */
.billing-section {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
}

.bill-to, .ship-to {
    flex: 1;
}

.bill-to label, .ship-to label {
    display: block;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    font-size: 16px;
}

.bill-to textarea, .ship-to textarea {
    width: 100%;
    height: 100px;
    border: 1px solid #ddd;
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    border-radius: 4px;
    resize: vertical;
}

/* Items Section */
.items-section {
    margin-bottom: 30px;
}

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

.items-table thead {
    background-color: #2c3e50;
    color: white;
}

.items-table th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 500;
    font-size: 14px;
}

.items-table th:last-child {
    text-align: center;
    width: 80px;
}

.items-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.items-table input {
    width: 100%;
    border: none;
    padding: 8px;
    font-size: 14px;
    background: transparent;
}

.items-table input:focus {
    outline: 1px solid #007bff;
    background: #f8f9fa;
}

.item-amount {
    text-align: right;
    font-weight: 500;
    min-width: 100px;
}

.remove-item {
    background: #dc3545;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-item:hover {
    background: #c82333;
}

.add-line-item {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.add-line-item:hover {
    background: #218838;
}

/* Notes and Totals */
.notes-section {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
}

.notes {
    flex: 2;
}

.notes label {
    display: block;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    font-size: 16px;
}

.notes textarea {
    width: 100%;
    height: 120px;
    border: 1px solid #ddd;
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    border-radius: 4px;
    resize: vertical;
}

.totals {
    flex: 1;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 4px;
    border: 1px solid #eee;
}

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

.total-row.tax-row .tax-input {
    display: flex;
    align-items: center;
    gap: 5px;
}

.tax-input input {
    width: 50px;
    border: 1px solid #ddd;
    padding: 4px 6px;
    text-align: center;
    border-radius: 4px;
    font-size: 12px;
}

.discount-shipping {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.add-discount, .add-shipping {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.add-discount:hover, .add-shipping:hover {
    background: #138496;
}

.discount-row .discount-input {
    display: flex;
    align-items: center;
    gap: 5px;
}

.discount-row input, .shipping-row input {
    border: 1px solid #ddd;
    padding: 4px 8px;
    border-radius: 4px;
    width: 60px;
    text-align: right;
}

.discount-row select {
    border: 1px solid #ddd;
    padding: 4px;
    border-radius: 4px;
    background: white;
    font-size: 12px;
}

.discount-display, .shipping-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
    font-style: italic;
    color: #666;
}

.total-final {
    border-top: 2px solid #333;
    border-bottom: 2px solid #333;
    font-weight: bold;
    font-size: 16px;
    margin: 10px 0;
}

.amount-paid {
    display: flex;
    align-items: center;
    gap: 5px;
}

.amount-paid input {
    border: 1px solid #ddd;
    padding: 4px 8px;
    border-radius: 4px;
    width: 80px;
    text-align: right;
}

.balance-due {
    font-weight: bold;
    font-size: 16px;
    color: #dc3545;
}

/* Terms Section */
.terms-section {
    margin-bottom: 20px;
}

.terms-section label {
    display: block;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    font-size: 16px;
}

.terms-section textarea {
    width: 100%;
    height: 80px;
    border: 1px solid #ddd;
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    border-radius: 4px;
    resize: vertical;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.generate-pdf, .preview-invoice {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

.generate-pdf:hover, .preview-invoice:hover {
    background: #0056b3;
}

/* Print/PDF Styles */
@media print {
    body {
        background: white;
    }
    
    .container {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    .controls {
        display: none;
    }
    
    .page-header {
        display: none !important;
    }
    
    .invoice {
        box-shadow: none;
        border-radius: 0;
    }
    
    .discount-display, .shipping-display {
        font-style: normal !important;
        color: #333 !important;
        font-weight: normal !important;
    }
    
    .discount-row, .shipping-row {
        display: none !important;
    }
    
    input, textarea, select, button {
        border: none !important;
        background: transparent !important;
        font-style: normal !important;
        color: #333 !important;
    }
}