* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', Arial, sans-serif; background-color: #f3f4f6; color: #111827; }

.app-container { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar Form */
.sidebar { width: 400px; background: white; padding: 20px; overflow-y: auto; border-right: 1px solid #e5e7eb; box-shadow: 2px 0 5px rgba(0,0,0,0.05); z-index: 10; }
.sidebar h2 { font-size: 16px; margin-top: 20px; margin-bottom: 10px; color: #374151; border-bottom: 1px solid #e5e7eb; padding-bottom: 5px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #4b5563; margin-bottom: 4px; }
.form-group input, .form-group textarea { width: 100%; padding: 8px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 14px; font-family: inherit; }
.form-group textarea { resize: vertical; min-height: 60px; }

.item-row { background: #f9fafb; padding: 10px; border: 1px solid #e5e7eb; border-radius: 6px; margin-bottom: 10px; position: relative; }
.item-row .remove-btn { position: absolute; top: 10px; right: 10px; background: #ef4444; color: white; border: none; border-radius: 4px; padding: 2px 6px; cursor: pointer; font-size: 10px; }
.item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn { width: 100%; padding: 10px; border-radius: 6px; font-weight: 600; cursor: pointer; border: none; transition: background 0.2s; font-size: 14px; }
.btn.primary { background: #2563eb; color: white; }
.btn.primary:hover { background: #1d4ed8; }
.btn.outline { background: transparent; border: 1px solid #2563eb; color: #2563eb; }
.btn.outline:hover { background: #eff6ff; }
.mt-2 { margin-top: 20px; }

/* Main Preview Area */
.main-preview { flex: 1; padding: 40px; overflow-y: auto; display: flex; justify-content: center; background-color: #e5e7eb; }

/* Bill Print Styling - Matches Image Exactly */
#bill-preview { width: 794px; margin: 0 auto; }
.bill-page-wrapper { background: white; width: 794px; height: 1000px; padding: 15px 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); margin-bottom: 30px; box-sizing: border-box; page-break-inside: avoid; break-inside: avoid; overflow: hidden; }
.rendering-pdf .bill-page-wrapper { margin: 0 !important; box-shadow: none !important; }
.page-break { page-break-after: always; break-after: page; }
.tax-invoice-container { width: 100%; font-family: Arial, sans-serif; color: #000; border: 1px solid #000; }
.main-table { width: 100%; border-collapse: collapse; }
.main-table td, .main-table th { border: 1px solid #000; padding: 4px 6px; }

.header-td { padding: 6px; text-align: center; border-bottom: 2px solid #000; }
.header-flex { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 5px; text-align: left; }
.text-right { text-align: right; }
.tax-invoice-title { font-weight: bold; font-size: 15px; text-decoration: underline; }

.logo-container { text-align: center; margin-top: 5px; }
.logo-img { height: 60px; width: auto; object-fit: contain; margin-bottom: 2px; }
.logo-container h2 { font-size: 24px; letter-spacing: 2px; margin: 0 0 2px 0; color: #1e3a8a; }
.logo-container p { font-size: 11px; margin: 1px 0; }

.client-info-td { padding: 6px; vertical-align: top; border-right: 2px solid #000; border-bottom: 2px solid #000; }
.company-name { font-weight: bold; font-size: 13px; margin-bottom: 3px; }
.client-address { font-size: 11px; margin-bottom: 5px; white-space: pre-wrap; line-height: 1.3; }
.client-detail { font-size: 11px; margin-top: 1px; }

.invoice-info-td { padding: 6px; vertical-align: top; border-bottom: 2px solid #000; }
.invoice-detail { font-size: 11px; margin-bottom: 3px; }

.items-header th { font-size: 11px; font-weight: bold; text-align: center; border-bottom: 2px solid #000; padding: 5px 4px; background: #fdfdfd; }
.item-row-td td { font-size: 11px; text-align: center; padding: 4px; border-bottom: 1px solid #000; }
.item-row-td td:nth-child(2), .item-row-td td:nth-child(4), .item-row-td td:nth-child(5) { text-align: left; }
.item-row-td td:last-child { font-weight: bold; }

.filler-row td { border-bottom: none; border-top: none; }

.amount-words-td { padding: 6px; font-size: 11px; border-top: 2px solid #000; border-right: 2px solid #000; }
.total-label { font-size: 11px; font-weight: bold; padding: 5px 6px; border-right: 1px solid #000; }
.total-value { font-size: 11px; font-weight: bold; padding: 5px 6px; text-align: center; }
.strong-total { font-size: 13px; border-top: 1px solid #000; }

.bank-details-td { padding: 6px; font-size: 10.5px; vertical-align: top; line-height: 1.4; border-right: 2px solid #000; }
.underline { text-decoration: underline; font-weight: bold; font-size: 11px; margin-bottom: 2px; display: inline-block; }

.remarks-td { padding: 6px; border-top: 2px solid #000; border-bottom: 2px solid #000; font-size: 11px; }
.remarks-text { white-space: pre-wrap; margin-top: 2px; font-size: 11px; }

.footer-td { padding: 6px; }
.footer-flex { display: flex; justify-content: space-between; font-size: 10.5px; }
.terms-container ul { list-style: none; padding: 0; margin: 2px 0 0 0; line-height: 1.3; }
.signatory-container { text-align: center; margin-top: 5px; display: flex; flex-direction: column; justify-content: space-between; min-width: 150px; }
.signatory-container .spacer { height: 35px; }

@media print {
    body { background: white; }
    .no-print { display: none !important; }
    .main-preview { padding: 0; background: white; display: block; }
    .bill-wrapper { padding: 0; width: 100%; height: auto; box-shadow: none; border: none; }
}
