<h1 class="h3 mb-4">Application Settings</h1>
<form method="post" action="<%= url('/settings') %>" enctype="multipart/form-data" class="card p-4">
  <div class="row g-3">
    <div class="col-md-4"><label class="form-label required">Business Name</label><input class="form-control" name="business_name" value="<%= settings.business_name || '' %>" required></div>
    <div class="col-md-4"><label class="form-label">Phone</label><input class="form-control" name="phone" value="<%= settings.phone || '' %>"></div>
    <div class="col-md-4"><label class="form-label">Email</label><input class="form-control" name="email" value="<%= settings.email || '' %>"></div>
    <div class="col-md-8"><label class="form-label">Address</label><textarea class="form-control" name="address" rows="3"><%= settings.address || '' %></textarea></div>
    <div class="col-md-4"><label class="form-label">GSTIN</label><input class="form-control" name="gstin" value="<%= settings.gstin || '' %>"><label class="form-label mt-2">State</label><div class="input-group"><input class="form-control" name="state_name" value="<%= settings.state_name || '' %>"><input class="form-control" name="state_code" value="<%= settings.state_code || '' %>" placeholder="Code"></div></div>
    <div class="col-md-3"><label class="form-label">CGST %</label><input type="number" step="0.01" class="form-control" name="cgst_percent" value="<%= settings.cgst_percent %>"></div>
    <div class="col-md-3"><label class="form-label">SGST %</label><input type="number" step="0.01" class="form-control" name="sgst_percent" value="<%= settings.sgst_percent %>"></div>
    <div class="col-md-3"><label class="form-label">IGST %</label><input type="number" step="0.01" class="form-control" name="igst_percent" value="<%= settings.igst_percent %>"></div>
    <div class="col-md-3"><label class="form-label">Default HSN/SAC</label><input class="form-control" name="default_hsn" value="<%= settings.default_hsn || '' %>"></div>
    <div class="col-md-3"><label class="form-label">Invoice Prefix</label><input class="form-control" name="invoice_prefix" value="<%= settings.invoice_prefix || '' %>"></div>
    <div class="col-md-3"><label class="form-label">Financial Year</label><input class="form-control" name="invoice_financial_year" value="<%= settings.invoice_financial_year || '' %>"></div>
    <div class="col-md-3"><label class="form-label">Padding</label><input type="number" class="form-control" name="invoice_padding" value="<%= settings.invoice_padding %>"></div>
    <div class="col-md-3"><label class="form-label">Next Number</label><input type="number" class="form-control" name="next_invoice_number" value="<%= settings.next_invoice_number %>"></div>
    <div class="col-md-4"><label class="form-label">Logo</label><input type="file" class="form-control" name="logo" accept="image/*"><% if(settings.logo_path){ %><img src="<%= url(settings.logo_path) %>" class="img-fluid mt-2" style="max-height:80px"><% } %></div>
    <div class="col-md-4"><label class="form-label">Signature Image</label><input type="file" class="form-control" name="signature" accept="image/*"><% if(settings.signature_path){ %><img src="<%= url(settings.signature_path) %>" class="img-fluid mt-2" style="max-height:80px"><% } %></div>
    <div class="col-md-4"><label class="form-label">Seal Image</label><input type="file" class="form-control" name="seal" accept="image/*"><% if(settings.seal_path){ %><img src="<%= url(settings.seal_path) %>" class="img-fluid mt-2" style="max-height:80px"><% } %></div>
    <div class="col-md-6"><label class="form-label">Declaration</label><textarea class="form-control" name="declaration_text" rows="3"><%= settings.declaration_text || '' %></textarea></div>
    <div class="col-md-6"><label class="form-label">Terms</label><textarea class="form-control" name="terms_text" rows="3"><%= settings.terms_text || '' %></textarea></div>
    <div class="col-12"><label class="form-label">Bank Details</label><textarea class="form-control" name="bank_details" rows="2"><%= settings.bank_details || '' %></textarea></div>
  </div>
  <div class="mt-4"><button class="btn btn-primary">Save Settings</button></div>
</form>
