body {
    font-family: Arial, sans-serif;
    margin: 20px;
    background-color: #f5f5f5;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    padding: 20px;
    border: 1px solid #ddd;
}

.controls {
    background: #f9f9f9;
    padding: 15px;
    border: 1px solid #ddd;
    margin-bottom: 20px;
}

.control-row {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.template-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.template-btn {
    padding: 8px 16px;
    border: 1px solid #333;
    background: white;
    cursor: pointer;
    font-size: 14px;
}

.template-btn.active {
    background: #333;
    color: white;
}

input[type="number"] {
    padding: 5px;
    border: 1px solid #ccc;
    width: 80px;
}

button {
    padding: 8px 16px;
    border: 1px solid #333;
    background: white;
    cursor: pointer;
    margin-right: 10px;
    margin-bottom: 5px;
}

button:hover {
    background: #f0f0f0;
}

button:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.auto-calc-btn {
    background: #4CAF50;
    color: white;
    border: 1px solid #45a049;
}

.auto-calc-btn:hover {
    background: #45a049;
}

.document {
    background: white;
    border: 2px solid #333;
    font-family: Arial, sans-serif;
}

.company-header {
    background: #333;
    color: white;
    text-align: center;
    padding: 10px;
    font-weight: bold;
}

.company-details {
    text-align: center;
    padding: 10px;
    font-size: 12px;
    border-bottom: 1px solid #333;
}

.document-title {
    text-align: center;
    padding: 15px;
    border-bottom: 1px solid #333;
    background: white;
}

.document-title h3 {
    margin: 0;
    font-weight: bold;
    font-size: 16px;
}

.document-title p {
    margin: 5px 0 0 0;
    font-size: 14px;
}

.document-info {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #333;
    font-size: 12px;
}

.info-section input {
    border: none;
    background: transparent;
    font-size: 12px;
    margin-left: 5px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    table-layout: fixed;
}

.data-table th {
    background: white;
    border: 1px solid #333;
    padding: 8px 4px;
    text-align: center;
    font-weight: bold;
    font-size: 12px;
    word-wrap: break-word;
}

.data-table td {
    border: 1px solid #333;
    padding: 4px;
    text-align: center;
    font-size: 11px;
    vertical-align: top;
    word-wrap: break-word;
    position: relative;
}

.cell-input {
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 11px;
    padding: 2px;
    resize: none;
    overflow: hidden;
    word-wrap: break-word;
    white-space: pre-wrap;
    min-height: 16px;
    line-height: 1.2;
}

.cell-input:focus {
    outline: 1px solid #333;
    background: #f9f9f9;
}

.description-cell {
    min-width: 200px;
    max-width: 300px;
}

.description-input {
    text-align: left !important;
    padding: 4px !important;
    line-height: 1.3;
    word-break: break-word;
}

.col-sno { width: 6%; }
.col-invoice { width: 12%; }
.col-date { width: 10%; }
.col-description { width: 25%; }
.col-amount { width: 12%; }
.col-usd { width: 12%; }
.col-qty { width: 8%; }
.col-rate { width: 10%; }
.col-remarks { width: 15%; }
.col-generic { width: 10%; }

.hidden {
    display: none;
}

.totals-section {
    padding: 10px;
    border-top: 2px solid #333;
    background: #f9f9f9;
    text-align: right;
    font-weight: bold;
}

.totals-section input {
    border: 1px solid #ccc;
    background: white;
    font-weight: bold;
    text-align: right;
    margin-left: 5px;
    padding: 2px 5px;
    border-radius: 3px;
}

.totals-section input:focus {
    outline: 2px solid #4CAF50;
    background: #f9f9f9;
}

.manual-edit-hint {
    font-size: 10px;
    color: #666;
    font-weight: normal;
    font-style: italic;
    margin-top: 5px;
}

.header-input {
    width: 100%;
    border: none;
    background: transparent;
    font-weight: bold;
    text-align: center;
    font-size: 12px;
    padding: 2px;
    resize: none;
    overflow: hidden;
    word-wrap: break-word;
    white-space: pre-wrap;
    min-height: 16px;
    line-height: 1.2;
}

.header-input:focus {
    outline: 1px solid #333;
    background: #f9f9f9;
}

.totals-table {
    width: 100%;
    margin-top: 15px;
    border-collapse: collapse;
}

.totals-table td {
    padding: 4px 8px;
    border: 1px solid #333;
}

.amount-in-words {
    margin-top: 10px;
    font-size: 12px;
    text-transform: uppercase;
}

.bank-details {
    margin-top: 15px;
    font-size: 12px;
}

@media print {
    body {
        margin: 0;
        background: white;
        font-size: 12px;
    }
    
    .controls {
        display: none !important;
    }
    
    .container {
        max-width: none;
        margin: 0;
        padding: 0;
        border: none;
        background: white;
    }
    
    .document {
        border: 2px solid #000;
        page-break-inside: avoid;
    }
    
    .data-table {
        page-break-inside: auto;
    }
    
    .data-table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    .data-table thead {
        display: table-header-group;
    }
    
    .data-table tfoot {
        display: table-footer-group;
    }
    
    .company-header {
        background: #333 !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
    }
    
    .totals-section {
        background: #f9f9f9 !important;
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
    }
    
    .totals-section input {
        border: none !important;
        background: transparent !important;
    }
    
    .cell-input {
        font-size: 10px !important;
    }
    
    .manual-edit-hint {
        display: none !important;
    }

    .header-input {
        font-size: 10px !important;
    }

    .totals-table td input {
        border: none !important;
        background: transparent !important;
    }
    
    .amount-in-words, .bank-details {
        font-size: 11px !important;
    }
}
