{"id":1342,"date":"2026-06-19T00:03:51","date_gmt":"2026-06-19T00:03:51","guid":{"rendered":"https:\/\/360bizbrokers.com\/?page_id=1342"},"modified":"2026-06-19T02:23:21","modified_gmt":"2026-06-19T02:23:21","slug":"cim-generator-v-2","status":"publish","type":"page","link":"https:\/\/360bizbrokers.com\/pt\/cim-generator-v-2\/","title":{"rendered":"CIM Generator V.2"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1342\" class=\"elementor elementor-1342\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-203fc12 e-flex e-con-boxed e-con e-parent\" data-id=\"203fc12\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-bc5cb1b elementor-widget elementor-widget-html\" data-id=\"bc5cb1b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t\t<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>CIM Generator OpenAI v4 | 360 Biz Brokers<\/title>\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Anton&family=Lato:wght@300;400;700;900&family=Playfair+Display:wght@400;600;700&family=Montserrat:wght@300;400;600;700&display=swap\" rel=\"stylesheet\">\n<style>\n:root {\n  --gold:#C9A84C;--gold-dark:#B8960C;--gold-light:#E8D5A0;\n  --black:#111111;--white:#FFFFFF;\n  --g50:#F9F9F9;--g100:#F0F0F0;--g200:#E0E0E0;--g400:#9E9E9E;--g600:#666;--g800:#333;\n  --r:8px;--rl:12px;\n}\n*{box-sizing:border-box;margin:0;padding:0}\nbody{font-family:'Lato',sans-serif;background:var(--g50);color:var(--black);min-height:100vh}\n#app{display:flex;min-height:100vh}\n#sidebar{width:260px;min-width:260px;background:var(--black);display:flex;flex-direction:column;position:sticky;top:0;height:100vh;overflow-y:auto}\n.sidebar-logo{padding:24px 20px 16px;border-bottom:1px solid rgba(201,168,76,0.2)}\n.sidebar-logo .brand{font-family:'Anton',sans-serif;font-size:18px;color:var(--gold);letter-spacing:1px}\n.sidebar-logo .sub{font-size:11px;color:var(--g400);letter-spacing:2px;text-transform:uppercase;margin-top:2px}\n.sidebar-nav{padding:12px 0;flex:1}\n.ngl{font-size:10px;text-transform:uppercase;letter-spacing:2px;color:var(--g600);padding:12px 20px 6px}\n.nav-item{display:flex;align-items:center;gap:10px;padding:10px 20px;cursor:pointer;transition:all 0.15s;font-size:13px;color:var(--g400);border-left:3px solid transparent;user-select:none}\n.nav-item:hover{background:rgba(255,255,255,0.05);color:#fff}\n.nav-item.active{background:rgba(201,168,76,0.1);color:var(--gold);border-left-color:var(--gold)}\n.nav-item .ni{font-size:15px;width:18px;text-align:center}\n.nav-item .nn{margin-left:auto;font-size:10px;background:rgba(201,168,76,0.2);color:var(--gold);padding:2px 7px;border-radius:20px}\n.sidebar-footer{padding:16px 20px;border-top:1px solid rgba(255,255,255,0.06)}\n.tpl-badge{background:rgba(201,168,76,0.15);border:1px solid rgba(201,168,76,0.3);border-radius:6px;padding:8px 12px;font-size:11px;color:var(--gold);cursor:pointer;text-align:center}\n#main{flex:1;display:flex;flex-direction:column;min-width:0}\n.topbar{background:var(--white);border-bottom:1px solid var(--g200);padding:14px 32px;display:flex;align-items:center;gap:16px;position:sticky;top:0;z-index:100}\n.topbar-title{font-size:16px;font-weight:700;color:var(--black);flex:1}\n.topbar-title span{color:var(--gold)}\n.btn{display:inline-flex;align-items:center;gap:6px;padding:9px 18px;border-radius:var(--r);font-size:13px;font-weight:600;cursor:pointer;border:none;transition:all 0.15s;font-family:'Lato',sans-serif;white-space:nowrap}\n.btn-gold{background:var(--gold);color:var(--black)}.btn-gold:hover{background:var(--gold-dark)}\n.btn-outline{background:transparent;border:1.5px solid var(--g200);color:var(--g800)}.btn-outline:hover{border-color:var(--gold);color:var(--gold)}\n.btn-ghost{background:transparent;border:none;color:var(--g600);padding:6px 10px}.btn-ghost:hover{color:var(--gold)}\n.btn-sm{padding:6px 12px;font-size:12px}\n#content{flex:1;padding:28px 32px}\n.panel{display:none}.panel.active{display:block}\n.card{background:var(--white);border-radius:var(--rl);border:1px solid var(--g200);padding:24px;margin-bottom:20px}\n.card-title{font-size:14px;font-weight:700;color:var(--black);text-transform:uppercase;letter-spacing:0.5px;margin-bottom:16px;display:flex;align-items:center;gap:8px}\n.card-title::before{content:'';width:3px;height:16px;background:var(--gold);border-radius:2px;flex-shrink:0}\n.fr{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:16px}\n.fr3{grid-template-columns:1fr 1fr 1fr}\n.fr1{grid-template-columns:1fr}\n.fg{display:flex;flex-direction:column;gap:5px}\nlabel{font-size:12px;font-weight:700;color:var(--g600);text-transform:uppercase;letter-spacing:0.5px}\ninput[type=text],input[type=number],input[type=email],select,textarea{font-family:'Lato',sans-serif;font-size:14px;padding:10px 13px;border:1.5px solid var(--g200);border-radius:var(--r);background:var(--white);color:var(--black);transition:border-color 0.15s;width:100%}\ninput:focus,select:focus,textarea:focus{outline:none;border-color:var(--gold)}\ntextarea{resize:vertical;min-height:90px;line-height:1.6}\n.tla{min-height:140px}\n.ai-bar{display:flex;gap:6px;flex-wrap:wrap;margin-top:0;padding:8px;background:#f8f6f0;border-radius:0 0 var(--r) var(--r);border:1px solid #e8dfc0;border-top:none}\n.ai-btn{font-size:11px;padding:4px 10px;border-radius:20px;border:1px solid rgba(201,168,76,0.3);background:white;color:var(--g800);cursor:pointer;transition:all 0.15s;font-family:'Lato',sans-serif}\n.ai-btn:hover{background:var(--gold);color:var(--black);border-color:var(--gold)}\n.iuz{border:2px dashed var(--g200);border-radius:var(--r);padding:16px;text-align:center;cursor:pointer;transition:all 0.2s;background:var(--g50);position:relative;min-height:80px;display:flex;flex-direction:column;align-items:center;justify-content:center}\n.iuz:hover{border-color:var(--gold);background:#faf7ee}\n.iuz input[type=file]{position:absolute;inset:0;opacity:0;cursor:pointer}\n.img-preview{max-width:100%;max-height:100px;border-radius:var(--r);object-fit:contain}\n.ul{font-size:11px;color:var(--g400);margin-top:6px}\n.ugrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:12px}\n.uitem{display:flex;flex-direction:column;gap:6px}\n.tgrid{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}\n.tcard{border:2px solid var(--g200);border-radius:var(--rl);overflow:hidden;cursor:pointer;transition:all 0.2s}\n.tcard:hover{border-color:var(--gold);transform:translateY(-2px);box-shadow:0 4px 24px rgba(0,0,0,0.12)}\n.tcard.selected{border-color:var(--gold);box-shadow:0 0 0 3px rgba(201,168,76,0.2)}\n.tpreview{height:120px;display:flex;flex-direction:column;padding:10px;gap:4px;position:relative;overflow:hidden}\n.tlabel{font-size:11px;font-weight:700;padding:8px 12px;text-align:center;border-top:1px solid var(--g100)}\n.pgbar{height:4px;background:var(--g200);border-radius:2px;margin-bottom:20px;overflow:hidden}\n.pgfill{height:100%;background:var(--gold);border-radius:2px;transition:width 0.4s ease}\n.dash-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px;margin-bottom:24px}\n.dc{background:white;border-radius:var(--rl);border:1px solid var(--g200);padding:20px;text-align:center}\n.dc .dn{font-size:32px;font-weight:900;color:var(--gold);font-family:'Anton',sans-serif}\n.dc .dl{font-size:12px;color:var(--g600);text-transform:uppercase;letter-spacing:1px;margin-top:4px}\n.qa-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}\n.qa-btn{background:white;border:1.5px solid var(--g200);border-radius:var(--rl);padding:16px;text-align:center;cursor:pointer;transition:all 0.2s}\n.qa-btn:hover{border-color:var(--gold);background:#faf7ee}\n.qa-icon{font-size:24px;margin-bottom:8px}\n.qa-label{font-size:12px;font-weight:700;color:var(--g800)}\n.qa-sub{font-size:11px;color:var(--g400);margin-top:2px}\n.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:1000;align-items:center;justify-content:center}\n.modal-overlay.open{display:flex}\n.modal{background:white;border-radius:var(--rl);padding:28px;max-width:560px;width:90%;max-height:85vh;overflow-y:auto;box-shadow:0 20px 60px rgba(0,0,0,0.3)}\n.modal-title{font-size:18px;font-weight:700;margin-bottom:16px;color:var(--black)}\n.modal-footer{margin-top:20px;display:flex;gap:10px;justify-content:flex-end}\n.smsg{font-size:12px;padding:8px 12px;border-radius:var(--r);margin-top:8px}\n.smsg.info{background:#eff6ff;color:#1d4ed8}\n.smsg.success{background:#f0fdf4;color:#16a34a}\n.smsg.error{background:#fef2f2;color:#dc2626}\n#preview-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.85);z-index:2000;overflow-y:auto;padding:20px}\n#preview-overlay.open{display:block}\n.preview-controls{position:sticky;top:0;background:rgba(0,0,0,0.9);padding:12px 20px;display:flex;gap:10px;align-items:center;justify-content:flex-end;z-index:10;border-radius:var(--r);margin-bottom:20px}\n#cim-doc{max-width:900px;margin:0 auto}\n@media print{\n  *{ -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }\n  html,body{margin:0!important;padding:0!important;background:#fff!important;overflow:visible!important}\n  #app,.topbar,#sidebar,#content,.preview-controls,.modal-overlay{display:none!important}\n  #preview-overlay{display:block!important;position:static!important;inset:auto!important;background:#fff!important;overflow:visible!important;padding:0!important}\n  #cim-doc{max-width:none!important;width:100%!important;margin:0!important;padding:0!important}\n  #cim-doc>div{max-width:none!important;width:100%!important;margin:0!important;box-shadow:none!important;border-radius:0!important}\n  .pgb{page-break-after:always;break-after:page}\n  @page{size:letter;margin:0}\n}\n<\/style>\n<\/head>\n<body>\n<div id=\"app\">\n<nav id=\"sidebar\">\n  <div class=\"sidebar-logo\">\n    <div class=\"brand\">360 BIZ BROKERS<\/div>\n    <div class=\"sub\">CIM Generator<\/div>\n  <\/div>\n  <div class=\"sidebar-nav\">\n    <div class=\"ngl\">Setup<\/div>\n    <div class=\"nav-item active\" data-panel=\"dashboard\"><span class=\"ni\">\u229e<\/span> Dashboard<\/div>\n    <div class=\"nav-item\" data-panel=\"template\"><span class=\"ni\">\u25c8<\/span> Template &amp; Design<\/div>\n    <div class=\"ngl\">CIM Sections<\/div>\n    <div class=\"nav-item\" data-panel=\"s-cover\"><span class=\"ni\">\u2460<\/span> Cover Page<\/div>\n    <div class=\"nav-item\" data-panel=\"s-broker\"><span class=\"ni\">\u2461<\/span> Broker Bio<\/div>\n    <div class=\"nav-item\" data-panel=\"s-exec\"><span class=\"ni\">\u2462<\/span> Executive Summary<\/div>\n    <div class=\"nav-item\" data-panel=\"s-overview\"><span class=\"ni\">\u2463<\/span> Business Overview<\/div>\n    <div class=\"nav-item\" data-panel=\"s-highlights\"><span class=\"ni\">\u2464<\/span> Investment Highlights<\/div>\n    <div class=\"nav-item\" data-panel=\"s-location\"><span class=\"ni\">\u2465<\/span> Location &amp; Market<\/div>\n    <div class=\"nav-item\" data-panel=\"s-products\"><span class=\"ni\">\u2466<\/span> Products \/ Services<\/div>\n    <div class=\"nav-item\" data-panel=\"s-operations\"><span class=\"ni\">\u2467<\/span> Operations &amp; Staff<\/div>\n    <div class=\"nav-item\" data-panel=\"s-facilities\"><span class=\"ni\">\u2468<\/span> Facilities &amp; Lease<\/div>\n    <div class=\"nav-item\" data-panel=\"s-financials\"><span class=\"ni\">\u2469<\/span> Financials &amp; Recast<\/div>\n    <div class=\"nav-item\" data-panel=\"s-competition\"><span class=\"ni\">\u246a<\/span> Competition &amp; Industry<\/div>\n    <div class=\"nav-item\" data-panel=\"s-growth\"><span class=\"ni\">\u246b<\/span> Growth &amp; Transition<\/div>\n    <div class=\"nav-item\" data-panel=\"s-assets\"><span class=\"ni\">\u246c<\/span> Asset List<\/div>\n    <div class=\"nav-item\" data-panel=\"s-appendix\"><span class=\"ni\">\u246d<\/span> Appendix &amp; Disclaimer<\/div>\n    <div class=\"nav-item\" data-panel=\"s-photos\"><span class=\"ni\">\u246e<\/span> Photos &amp; Uploads<\/div>\n  <\/div>\n  <div class=\"sidebar-footer\">\n    <div class=\"tpl-badge\" id=\"sidebar-tpl-btn\">\u25c8 Template: Gold &amp; Black<\/div>\n  <\/div>\n<\/nav>\n<div id=\"main\">\n  <div class=\"topbar\">\n    <div class=\"topbar-title\">CIM Generator \u2014 <span id=\"topbar-biz\">New CIM<\/span><\/div>\n    <button class=\"btn btn-outline btn-sm\" onclick=\"saveData()\">\ud83d\udcbe Save<\/button>\n    <button class=\"btn btn-outline btn-sm\" onclick=\"showPreview()\">\ud83d\udc41 Preview<\/button>\n    <button class=\"btn btn-gold\" onclick=\"printCIM()\">\u2b07 Export PDF<\/button>\n  <\/div>\n  <div id=\"content\">\n<!-- DASHBOARD -->\n<div class=\"panel active\" id=\"panel-dashboard\">\n  <div class=\"dash-grid\">\n    <div class=\"dc\"><div class=\"dn\" id=\"d-filled\">0<\/div><div class=\"dl\">Sections Filled<\/div><\/div>\n    <div class=\"dc\"><div class=\"dn\" id=\"d-total\">16<\/div><div class=\"dl\">Total Fields<\/div><\/div>\n    <div class=\"dc\"><div class=\"dn\" id=\"d-pct\">0%<\/div><div class=\"dl\">Completeness<\/div><\/div>\n  <\/div>\n  <div class=\"pgbar\"><div class=\"pgfill\" id=\"dash-pg\" style=\"width:0%\"><\/div><\/div>\n  <div class=\"card\">\n    <div class=\"card-title\">Quick Start<\/div>\n    <div class=\"qa-grid\">\n      <div class=\"qa-btn\" onclick=\"gotoPanel('s-cover')\"><div class=\"qa-icon\">\ud83d\udcc4<\/div><div class=\"qa-label\">Cover Info<\/div><div class=\"qa-sub\">Name, price, key metrics<\/div><\/div>\n      <div class=\"qa-btn\" onclick=\"gotoPanel('s-exec')\"><div class=\"qa-icon\">\u270d\ufe0f<\/div><div class=\"qa-label\">Executive Summary<\/div><div class=\"qa-sub\">AI can write this for you<\/div><\/div>\n      <div class=\"qa-btn\" onclick=\"gotoPanel('s-financials')\"><div class=\"qa-icon\">\ud83d\udcb0<\/div><div class=\"qa-label\">Financials<\/div><div class=\"qa-sub\">Revenue, SDE, EBITDA<\/div><\/div>\n      <div class=\"qa-btn\" onclick=\"gotoPanel('s-photos')\"><div class=\"qa-icon\">\ud83d\udcf8<\/div><div class=\"qa-label\">Upload Photos<\/div><div class=\"qa-sub\">Logos &amp; business photos<\/div><\/div>\n    <\/div>\n  <\/div>\n  <!-- AI routed through WordPress proxy \u2014 no user config needed -->\n  <input type=\"hidden\" id=\"api-key\" value=\"\" \/>\n  <input type=\"hidden\" id=\"proxy-url\" value=\"https:\/\/360bizbrokers.com\/wp-json\/bbf\/v1\/openai-ai\" \/>\n\n  <!-- AI CONNECTION SETTINGS -->\n  <div class=\"card\" style=\"border:1px solid #e8dfc0;background:#fffdf4\">\n    <div class=\"card-title\" style=\"color:var(--gold-dark)\">\ud83e\udd16 AI Connection<\/div>\n    <p style=\"font-size:13px;color:var(--g600);margin-bottom:12px;line-height:1.6\">The upload and AI writing tools require a working WordPress REST proxy endpoint. If your site returns 404, paste the current proxy URL below and click Save.<\/p>\n    <div class=\"fr\" style=\"align-items:end;margin-bottom:0\">\n      <div class=\"fg\"><label>AI Proxy URL<\/label><input type=\"text\" id=\"ai-proxy-input\" placeholder=\"https:\/\/yourdomain.com\/wp-json\/...\/ai\" \/><\/div>\n      <div style=\"display:flex;gap:8px;flex-wrap:wrap\"><button class=\"btn btn-outline btn-sm\" onclick=\"saveAiProxyUrl()\">\ud83d\udcbe Save Proxy URL<\/button><button class=\"btn btn-gold btn-sm\" onclick=\"testAIProxy()\">Test AI Connection<\/button><\/div>\n    <\/div>\n    <div id=\"ai-proxy-status\" style=\"display:none;margin-top:10px\"><\/div>\n  <\/div>\n\n  <!-- DOWNLOAD INTAKE FORM CARD -->\n  <div class=\"card\" style=\"border:2px solid #111;background:linear-gradient(135deg,#111,#1e1e1e);color:white\">\n    <div class=\"card-title\" style=\"color:var(--gold)\">\ud83d\udce5 Step 1 \u2014 Download &amp; Send Intake Form to Seller<\/div>\n    <p style=\"font-size:14px;color:rgba(255,255,255,0.65);margin-bottom:16px;line-height:1.6\">Download the 360 Biz Brokers Listing Intake Form. Send it to your seller to complete. Once returned, upload it in Step 2 below and AI will auto-populate all CIM fields.<\/p>\n    <div style=\"display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:16px\">\n      <div style=\"background:rgba(255,255,255,0.05);border:1px solid rgba(201,168,76,0.25);border-radius:var(--r);padding:14px\">\n        <div style=\"font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--gold);margin-bottom:6px\">English Version<\/div>\n        <div style=\"font-size:12px;color:rgba(255,255,255,0.5);margin-bottom:10px\">Full listing intake \u2022 4 pages \u2022 All CIM sections<\/div>\n        <button class=\"btn btn-gold btn-sm\" onclick=\"downloadIntakeForm('en')\" style=\"width:100%\">\u2b07 Download (English)<\/button>\n      <\/div>\n      <div style=\"background:rgba(255,255,255,0.05);border:1px solid rgba(201,168,76,0.25);border-radius:var(--r);padding:14px\">\n        <div style=\"font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--gold);margin-bottom:6px\">Spanish Version \/ Versi\u00f3n en Espa\u00f1ol<\/div>\n        <div style=\"font-size:12px;color:rgba(255,255,255,0.5);margin-bottom:10px\">Formulario completo \u2022 4 p\u00e1ginas \u2022 Todas las secciones<\/div>\n        <button class=\"btn btn-gold btn-sm\" onclick=\"downloadIntakeForm('es')\" style=\"width:100%\">\u2b07 Descargar (Espa\u00f1ol)<\/button>\n      <\/div>\n    <\/div>\n    <div style=\"font-size:11px;color:rgba(255,255,255,0.35);display:flex;align-items:center;gap:6px\">\n      <span>\ud83d\udca1<\/span> Tip: Save as PDF from your browser's Print dialog (File \u2192 Print \u2192 Save as PDF) before emailing to the seller.\n    <\/div>\n  <\/div>\n\n  <div class=\"card\" style=\"border:2px solid var(--gold);background:linear-gradient(135deg,#fffdf4,#fff)\">\n    <div class=\"card-title\" style=\"color:var(--gold-dark)\">\u26a1 Step 2 \u2014 Upload Completed Intake &amp; Auto-Fill CIM<\/div>\n    <p style=\"font-size:14px;color:var(--g600);margin-bottom:16px;line-height:1.6\">Upload a listing intake form, seller questionnaire, or any business document. AI will read it and automatically populate all CIM fields.<\/p>\n    <div id=\"intake-drop-zone\" style=\"border:2px dashed var(--gold-light);border-radius:var(--rl);padding:32px;text-align:center;cursor:pointer;transition:all 0.2s;background:rgba(201,168,76,0.04);position:relative\" onclick=\"document.getElementById('intake-file-input').click()\">\n      <input type=\"file\" id=\"intake-file-input\" accept=\".pdf,.doc,.docx,image\/*,.txt,.csv\" style=\"position:absolute;inset:0;opacity:0;cursor:pointer\" onchange=\"handleIntakeUpload(this)\" \/>\n      <div style=\"font-size:36px;margin-bottom:10px\">\ud83d\udccb<\/div>\n      <div style=\"font-size:15px;font-weight:700;color:var(--black);margin-bottom:6px\">Drop your listing intake form here<\/div>\n      <div style=\"font-size:12px;color:var(--g400)\">Supports PDF, Word (.docx), JPG, PNG \u2014 seller questionnaires, intake sheets, listing agreements<\/div>\n      <div style=\"margin-top:16px\"><span class=\"btn btn-gold btn-sm\">Browse Files<\/span><\/div>\n    <\/div>\n    <div id=\"intake-status\" style=\"display:none;margin-top:12px\"><\/div>\n    <div id=\"intake-preview-bar\" style=\"display:none;margin-top:12px;padding:12px 16px;background:#f8f6f0;border-radius:var(--r);border:1px solid #e8dfc0;display:flex;align-items:center;gap:12px\">\n      <span style=\"font-size:20px\">\ud83d\udcc4<\/span>\n      <div style=\"flex:1\">\n        <div id=\"intake-filename\" style=\"font-size:13px;font-weight:700;color:var(--black)\">filename.pdf<\/div>\n        <div id=\"intake-filesize\" style=\"font-size:11px;color:var(--g400)\">\u2014<\/div>\n      <\/div>\n      <button class=\"btn btn-gold btn-sm\" onclick=\"runIntakeExtraction()\">\u2728 Extract &amp; Auto-Fill<\/button>\n      <button class=\"btn btn-ghost btn-sm\" onclick=\"clearIntake()\">\u2715<\/button>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- TEMPLATE -->\n<div class=\"panel\" id=\"panel-template\">\n  <div class=\"card\">\n    <div class=\"card-title\">Choose CIM Template<\/div>\n    <div class=\"tgrid\">\n      <div class=\"tcard selected\" data-tpl=\"1\" onclick=\"selectTemplate(1)\">\n        <div class=\"tpreview\" style=\"background:#111\">\n          <div style=\"color:#C9A84C;font-size:6px;letter-spacing:1px;text-transform:uppercase\">CONFIDENTIAL<\/div>\n          <div style=\"color:white;font-size:9px;font-weight:700;margin:4px 0\">Business Name<\/div>\n          <div style=\"width:20px;height:1px;background:#C9A84C;margin:4px 0\"><\/div>\n          <div style=\"color:rgba(255,255,255,0.4);font-size:6px\">Presented by 360 Biz Brokers<\/div>\n          <div style=\"margin-top:auto;display:flex;gap:4px\"><div style=\"flex:1;background:#C9A84C;height:20px;border-radius:2px\"><\/div><div style=\"flex:1;background:#333;height:20px;border-radius:2px\"><\/div><div style=\"flex:1;background:#333;height:20px;border-radius:2px\"><\/div><\/div>\n        <\/div>\n        <div class=\"tlabel\">Gold &amp; Black \u2605<\/div>\n      <\/div>\n      <div class=\"tcard\" data-tpl=\"2\" onclick=\"selectTemplate(2)\">\n        <div class=\"tpreview\" style=\"background:#1a2744\">\n          <div style=\"color:#7eb3e8;font-size:6px;letter-spacing:1px;text-transform:uppercase\">CONFIDENTIAL<\/div>\n          <div style=\"color:white;font-size:9px;font-weight:700;margin:4px 0;font-style:italic\">Business Name<\/div>\n          <div style=\"width:20px;height:2px;background:#4a90d9;margin:4px 0\"><\/div>\n          <div style=\"color:rgba(255,255,255,0.4);font-size:6px\">Investment Overview<\/div>\n          <div style=\"margin-top:auto;display:flex;gap:4px\"><div style=\"flex:1;background:#4a90d9;height:20px;border-radius:2px\"><\/div><div style=\"flex:1;background:#2a3f6f;height:20px;border-radius:2px\"><\/div><div style=\"flex:1;background:#2a3f6f;height:20px;border-radius:2px\"><\/div><\/div>\n        <\/div>\n        <div class=\"tlabel\">Navy Professional<\/div>\n      <\/div>\n      <div class=\"tcard\" data-tpl=\"3\" onclick=\"selectTemplate(3)\">\n        <div class=\"tpreview\" style=\"background:#1b3a2d\">\n          <div style=\"color:#7ec898;font-size:6px;letter-spacing:1px;text-transform:uppercase\">CONFIDENTIAL<\/div>\n          <div style=\"color:white;font-size:9px;font-weight:700;margin:4px 0\">Business Name<\/div>\n          <div style=\"width:20px;height:2px;background:#5cb87a;margin:4px 0\"><\/div>\n          <div style=\"color:rgba(255,255,255,0.4);font-size:6px\">Presented by Broker<\/div>\n          <div style=\"margin-top:auto;display:flex;gap:4px\"><div style=\"flex:1;background:#5cb87a;height:20px;border-radius:2px\"><\/div><div style=\"flex:1;background:#2a5040;height:20px;border-radius:2px\"><\/div><div style=\"flex:1;background:#2a5040;height:20px;border-radius:2px\"><\/div><\/div>\n        <\/div>\n        <div class=\"tlabel\">Forest Green<\/div>\n      <\/div>\n      <div class=\"tcard\" data-tpl=\"4\" onclick=\"selectTemplate(4)\">\n        <div class=\"tpreview\" style=\"background:#2d0a1e\">\n          <div style=\"color:#d4a0b5;font-size:6px;letter-spacing:1px;text-transform:uppercase\">CONFIDENTIAL<\/div>\n          <div style=\"color:white;font-size:9px;font-weight:700;margin:4px 0;font-style:italic\">Business Name<\/div>\n          <div style=\"width:20px;height:2px;background:#b8436e;margin:4px 0\"><\/div>\n          <div style=\"color:rgba(255,255,255,0.4);font-size:6px\">Luxury Brief<\/div>\n          <div style=\"margin-top:auto;display:flex;gap:4px\"><div style=\"flex:1;background:#b8436e;height:20px;border-radius:2px\"><\/div><div style=\"flex:1;background:#4a1030;height:20px;border-radius:2px\"><\/div><div style=\"flex:1;background:#4a1030;height:20px;border-radius:2px\"><\/div><\/div>\n        <\/div>\n        <div class=\"tlabel\">Burgundy Luxury<\/div>\n      <\/div>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- COVER -->\n<div class=\"panel\" id=\"panel-s-cover\">\n  <div class=\"card\">\n    <div class=\"card-title\">Cover Page Information<\/div>\n    <div class=\"fr\">\n      <div class=\"fg\"><label>Business Name *<\/label><input type=\"text\" id=\"f-biz-name\" placeholder=\"e.g. Sunshine Bakery &amp; Caf\u00e9\" oninput=\"updateTopbar()\" \/><\/div>\n      <div class=\"fg\"><label>Business Type \/ Industry<\/label><input type=\"text\" id=\"f-biz-type\" placeholder=\"e.g. Full-Service Restaurant\" \/><\/div>\n    <\/div>\n    <div class=\"fr fr3\">\n      <div class=\"fg\"><label>Asking Price<\/label><input type=\"text\" id=\"f-asking-price\" placeholder=\"$1,200,000\" \/><\/div>\n      <div class=\"fg\"><label>Annual Revenue<\/label><input type=\"text\" id=\"f-revenue\" placeholder=\"$850,000\" \/><\/div>\n      <div class=\"fg\"><label>SDE \/ EBITDA<\/label><input type=\"text\" id=\"f-sde\" placeholder=\"$280,000\" \/><\/div>\n    <\/div>\n    <div class=\"fr\">\n      <div class=\"fg\"><label>City, State<\/label><input type=\"text\" id=\"f-location\" placeholder=\"Miami, FL\" \/><\/div>\n      <div class=\"fg\"><label>Years in Business<\/label><input type=\"text\" id=\"f-years\" placeholder=\"12\" \/><\/div>\n    <\/div>\n    <div class=\"fr\">\n      <div class=\"fg\"><label>Brokerage Name<\/label><input type=\"text\" id=\"f-brokerage\" placeholder=\"360 Biz Brokers\" value=\"360 Biz Brokers\" \/><\/div>\n      <div class=\"fg\"><label>Listing Broker Name<\/label><input type=\"text\" id=\"f-broker-name\" placeholder=\"Valquiria Pidgeon, MBA\" \/><\/div>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- BROKER BIO -->\n<div class=\"panel\" id=\"panel-s-broker\">\n  <div class=\"card\">\n    <div class=\"card-title\">Know the Listing Broker<\/div>\n    <div class=\"fr\">\n      <div class=\"fg\"><label>Broker Full Name<\/label><input type=\"text\" id=\"f-broker-fullname\" placeholder=\"Valquiria Pidgeon, MBA\" \/><\/div>\n      <div class=\"fg\"><label>Title \/ Designation<\/label><input type=\"text\" id=\"f-broker-title\" placeholder=\"Principal Broker | IBBA Outstanding Performance Award\" \/><\/div>\n    <\/div>\n    <div class=\"fr fr3\">\n      <div class=\"fg\"><label>Phone<\/label><input type=\"text\" id=\"f-broker-phone\" placeholder=\"(954) 325-2625\" \/><\/div>\n      <div class=\"fg\"><label>Email<\/label><input type=\"email\" id=\"f-broker-email\" placeholder=\"val@360bizbrokers.com\" \/><\/div>\n      <div class=\"fg\"><label>Website<\/label><input type=\"text\" id=\"f-broker-website\" placeholder=\"360bizbrokers.com\" \/><\/div>\n    <\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Broker Biography<\/label>\n    <textarea id=\"f-broker-bio\" class=\"tla\" placeholder=\"Write broker bio here...\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <span style=\"font-size:11px;color:#888;margin-right:4px\">\u2728 AI:<\/span>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-broker-bio','improve')\">Improve Wording<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-broker-bio','professional')\">Make More Professional<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-broker-bio','expand')\">Expand<\/button>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- EXECUTIVE SUMMARY -->\n<div class=\"panel\" id=\"panel-s-exec\">\n  <div class=\"card\">\n    <div class=\"card-title\">Executive Summary<\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Executive Summary<\/label>\n    <textarea id=\"f-exec\" class=\"tla\" placeholder=\"Provide a compelling overview of this business opportunity...\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <span style=\"font-size:11px;color:#888;margin-right:4px\">\u2728 AI:<\/span>\n      <button class=\"ai-btn\" onclick=\"aiGen('f-exec','executive_summary')\">\ud83e\ude84 Generate from All Data<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-exec','improve')\">Improve<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-exec','buyer')\">Rewrite for Buyers<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-exec','professional')\">Make Professional<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-exec','summarize')\">Summarize<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-exec','expand')\">Expand<\/button>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- BUSINESS OVERVIEW -->\n<div class=\"panel\" id=\"panel-s-overview\">\n  <div class=\"card\">\n    <div class=\"card-title\">Business Overview<\/div>\n    <div class=\"fr\">\n      <div class=\"fg\"><label>Business Description<\/label><textarea id=\"f-biz-desc\" placeholder=\"Describe the business in detail...\"><\/textarea><\/div>\n      <div class=\"fg\"><label>History &amp; Background<\/label><textarea id=\"f-biz-history\" placeholder=\"When founded, ownership history, milestones...\"><\/textarea><\/div>\n    <\/div>\n    <div class=\"fr fr3\">\n      <div class=\"fg\"><label>Legal Structure<\/label>\n        <select id=\"f-legal\"><option value=\"\">Select...<\/option><option>LLC<\/option><option>S-Corp<\/option><option>C-Corp<\/option><option>Sole Proprietorship<\/option><option>Partnership<\/option><\/select>\n      <\/div>\n      <div class=\"fg\"><label>Ownership Type<\/label>\n        <select id=\"f-ownership\"><option value=\"\">Select...<\/option><option>Single Owner<\/option><option>Partnership<\/option><option>Family-Owned<\/option><option>Absentee-Owned<\/option><\/select>\n      <\/div>\n      <div class=\"fg\"><label>Hours of Operation<\/label><input type=\"text\" id=\"f-hours\" placeholder=\"Mon\u2013Fri 9am\u20136pm\" \/><\/div>\n    <\/div>\n    <div class=\"fr\">\n      <div class=\"fg\"><label>Customer Demographics<\/label><textarea id=\"f-customers\" placeholder=\"Who are the primary customers?\"><\/textarea><\/div>\n      <div class=\"fg\"><label>Competitive Advantages<\/label><textarea id=\"f-advantages\" placeholder=\"What makes this business stand out?\"><\/textarea><\/div>\n    <\/div>\n    <div class=\"ai-bar\" style=\"margin-top:8px\">\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-biz-desc','improve')\">Improve Description<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-biz-desc','buyer')\">Rewrite for Buyers<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-advantages','expand')\">Expand Advantages<\/button>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- INVESTMENT HIGHLIGHTS -->\n<div class=\"panel\" id=\"panel-s-highlights\">\n  <div class=\"card\">\n    <div class=\"card-title\">Investment Highlights<\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Investment Highlights (one per line)<\/label>\n    <textarea id=\"f-highlights\" class=\"tla\" placeholder=\"Established 12-year track record with loyal customer base&#10;Prime high-traffic location with below-market lease&#10;Turnkey operations with trained staff in place&#10;Consistent revenue growth of 15% YoY&#10;Multiple expansion opportunities identified\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiGen('f-highlights','investment_highlights')\">\ud83e\ude84 Generate from Data<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-highlights','improve')\">Improve<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-highlights','expand')\">Add More<\/button>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- LOCATION -->\n<div class=\"panel\" id=\"panel-s-location\">\n  <div class=\"card\">\n    <div class=\"card-title\">Location &amp; Market Overview<\/div>\n    <div class=\"fr\">\n      <div class=\"fg\"><label>Street Address<\/label><input type=\"text\" id=\"f-address\" placeholder=\"123 Main St, Miami, FL 33101\" \/><\/div>\n      <div class=\"fg\"><label>Neighborhood \/ Area Type<\/label><input type=\"text\" id=\"f-neighborhood\" placeholder=\"Downtown business district...\" \/><\/div>\n    <\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Location Description &amp; Demographics<\/label>\n    <textarea id=\"f-loc-desc\" class=\"tla\" placeholder=\"Describe the location, area, traffic counts, demographics...\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiResearch('f-loc-desc','location')\">\ud83c\udf10 Research Location &amp; Demographics<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-loc-desc','improve')\">Improve<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-loc-desc','expand')\">Expand<\/button>\n    <\/div>\n    <div class=\"fg\" style=\"margin-top:14px\"><label>Nearby Demand Drivers \/ Attractions<\/label>\n    <textarea id=\"f-demand\" placeholder=\"Nearby businesses, attractions, traffic generators...\"><\/textarea><\/div>\n  <\/div>\n<\/div>\n\n<!-- PRODUCTS -->\n<div class=\"panel\" id=\"panel-s-products\">\n  <div class=\"card\">\n    <div class=\"card-title\">Products &amp; Services<\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Products &amp; Services<\/label>\n    <textarea id=\"f-products\" class=\"tla\" placeholder=\"Describe all products and\/or services offered...\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-products','improve')\">Improve<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-products','buyer')\">Rewrite for Buyers<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-products','expand')\">Expand<\/button>\n    <\/div>\n    <div class=\"fg\" style=\"margin-top:14px\"><label>Revenue Mix \/ Top Revenue Sources<\/label>\n    <textarea id=\"f-rev-mix\" placeholder=\"e.g. 60% dine-in, 25% catering, 15% online orders...\"><\/textarea><\/div>\n  <\/div>\n<\/div>\n\n<!-- OPERATIONS -->\n<div class=\"panel\" id=\"panel-s-operations\">\n  <div class=\"card\">\n    <div class=\"card-title\">Operations &amp; Staff<\/div>\n    <div class=\"fr fr3\">\n      <div class=\"fg\"><label>Total Employees<\/label><input type=\"text\" id=\"f-employees\" placeholder=\"15 FT, 8 PT\" \/><\/div>\n      <div class=\"fg\"><label>Owner Role \/ Hours\/Week<\/label><input type=\"text\" id=\"f-owner-role\" placeholder=\"Semi-absentee, 20 hrs\/wk\" \/><\/div>\n      <div class=\"fg\"><label>Key Management Staying?<\/label>\n        <select id=\"f-mgmt\"><option value=\"\">Select...<\/option><option>Yes, all key staff staying<\/option><option>Most key staff staying<\/option><option>Varies<\/option><option>Unknown<\/option><\/select>\n      <\/div>\n    <\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Operations Overview<\/label>\n    <textarea id=\"f-ops\" class=\"tla\" placeholder=\"Day-to-day operations, systems, technology, vendors, suppliers...\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-ops','improve')\">Improve<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-ops','professional')\">Make Professional<\/button>\n    <\/div>\n    <div class=\"fg\" style=\"margin-top:14px\"><label>Staff &amp; Org Notes<\/label>\n    <textarea id=\"f-staff\" placeholder=\"Key roles, organizational structure, unique arrangements...\"><\/textarea><\/div>\n  <\/div>\n<\/div>\n\n<!-- FACILITIES -->\n<div class=\"panel\" id=\"panel-s-facilities\">\n  <div class=\"card\">\n    <div class=\"card-title\">Facilities &amp; Lease<\/div>\n    <div class=\"fr fr3\">\n      <div class=\"fg\"><label>Square Footage<\/label><input type=\"text\" id=\"f-sqft\" placeholder=\"2,400 sq ft\" \/><\/div>\n      <div class=\"fg\"><label>Monthly Rent<\/label><input type=\"text\" id=\"f-rent\" placeholder=\"$4,800\/month\" \/><\/div>\n      <div class=\"fg\"><label>Lease Expiration<\/label><input type=\"text\" id=\"f-lease-exp\" placeholder=\"Dec 2027 + 5yr option\" \/><\/div>\n    <\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Facility &amp; Lease Description<\/label>\n    <textarea id=\"f-facilities\" class=\"tla\" placeholder=\"Physical space, condition, layout, parking, lease terms, landlord relationship...\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-facilities','improve')\">Improve<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-facilities','professional')\">Make Professional<\/button>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- FINANCIALS -->\n<div class=\"panel\" id=\"panel-s-financials\">\n  <div class=\"card\">\n    <div class=\"card-title\">Financial Summary &amp; Recasted Earnings<\/div>\n    <div style=\"overflow-x:auto\">\n      <table style=\"width:100%;border-collapse:collapse;margin-bottom:16px\">\n        <thead>\n          <tr style=\"background:#111\">\n            <th style=\"padding:10px 14px;text-align:left;color:#C9A84C;font-size:11px;text-transform:uppercase;letter-spacing:1px\">Financial Metric<\/th>\n            <th style=\"padding:10px 14px;text-align:right;color:#C9A84C;font-size:11px\">Year 1<\/th>\n            <th style=\"padding:10px 14px;text-align:right;color:#C9A84C;font-size:11px\">Year 2<\/th>\n            <th style=\"padding:10px 14px;text-align:right;color:#C9A84C;font-size:11px\">Year 3 (Latest)<\/th>\n          <\/tr>\n        <\/thead>\n        <tbody>\n          <tr><td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;font-weight:700\">Gross Revenue<\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-rev1\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-rev2\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-rev3\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n          <\/tr>\n          <tr><td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;font-weight:700\">Cost of Goods Sold<\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-cogs1\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-cogs2\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-cogs3\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n          <\/tr>\n          <tr><td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;font-weight:700\">Gross Profit<\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-gp1\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-gp2\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-gp3\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n          <\/tr>\n          <tr><td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;font-weight:700\">Total Operating Expenses<\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-opex1\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-opex2\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right\"><input type=\"text\" id=\"f-opex3\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:14px\" placeholder=\"$0\" \/><\/td>\n          <\/tr>\n          <tr style=\"background:#f8f6f0\">\n            <td style=\"padding:9px 14px;border-top:2px solid #C9A84C;font-weight:900;font-size:15px\">Net SDE \/ Owner Benefit<\/td>\n            <td style=\"padding:9px 14px;border-top:2px solid #C9A84C;text-align:right;font-weight:900\"><input type=\"text\" id=\"f-sde1\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:15px;font-weight:900\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-top:2px solid #C9A84C;text-align:right;font-weight:900\"><input type=\"text\" id=\"f-sde2\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:15px;font-weight:900\" placeholder=\"$0\" \/><\/td>\n            <td style=\"padding:9px 14px;border-top:2px solid #C9A84C;text-align:right;font-weight:900\"><input type=\"text\" id=\"f-sde3\" style=\"width:100%;text-align:right;border:none;background:transparent;font-size:15px;font-weight:900\" placeholder=\"$0\" \/><\/td>\n          <\/tr>\n        <\/tbody>\n      <\/table>\n    <\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Recasted Earnings Notes &amp; Add-Backs<\/label>\n    <textarea id=\"f-recast\" class=\"tla\" placeholder=\"Describe recasting adjustments, add-backs, non-recurring expenses removed...\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-recast','improve')\">Improve<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-recast','professional')\">Make Professional<\/button>\n    <\/div>\n    <div class=\"fr\" style=\"margin-top:14px\">\n      <div class=\"fg\"><label>Valuation \/ Multiple<\/label><input type=\"text\" id=\"f-valuation\" placeholder=\"3.2x SDE | Comps support $1.1M\u2013$1.4M range\" \/><\/div>\n      <div class=\"fg\"><label>Deal Structure<\/label><input type=\"text\" id=\"f-deal\" placeholder=\"All cash, SBA eligible, partial seller financing considered\" \/><\/div>\n    <\/div>\n  <\/div>\n\n  <!-- FINANCIAL DOCUMENTS UPLOAD -->\n  <div class=\"card\" style=\"border:2px solid #e8dfc0;background:linear-gradient(135deg,#fffdf4,#fff)\">\n    <div class=\"card-title\" style=\"color:var(--gold-dark)\">\ud83d\udcca Financial Documents \u2014 AI Auto-Extract<\/div>\n    <p style=\"font-size:14px;color:var(--g600);margin-bottom:16px;line-height:1.6\">Upload tax returns, P&amp;Ls, or spreadsheets. AI will read the numbers and auto-populate the financial table above. You can upload up to 3 documents (one per year).<\/p>\n\n    <div style=\"display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-bottom:16px\">\n      <!-- Year 1 -->\n      <div>\n        <div style=\"font-size:11px;font-weight:700;color:var(--g600);text-transform:uppercase;letter-spacing:0.5px;margin-bottom:6px\">Year 1 Document<\/div>\n        <div class=\"fin-doc-zone\" id=\"fin-zone-1\" onclick=\"document.getElementById('fin-file-1').click()\" style=\"border:2px dashed var(--g200);border-radius:var(--r);padding:16px;text-align:center;cursor:pointer;transition:all 0.2s;background:var(--g50);position:relative;min-height:90px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px\">\n          <input type=\"file\" id=\"fin-file-1\" accept=\".pdf,.doc,.docx,.csv,.xls,.xlsx,image\/*\" style=\"position:absolute;inset:0;opacity:0;cursor:pointer\" onchange=\"handleFinDoc(this,1)\" \/>\n          <div style=\"font-size:22px\" id=\"fin-icon-1\">\ud83d\udcc2<\/div>\n          <div style=\"font-size:11px;color:var(--g400)\" id=\"fin-label-1\">Tax Return \/ P&L<br\/>Year 1<\/div>\n        <\/div>\n        <div id=\"fin-doc-name-1\" style=\"font-size:11px;color:var(--g600);margin-top:4px;text-align:center;display:none\"><\/div>\n      <\/div>\n\n      <!-- Year 2 -->\n      <div>\n        <div style=\"font-size:11px;font-weight:700;color:var(--g600);text-transform:uppercase;letter-spacing:0.5px;margin-bottom:6px\">Year 2 Document<\/div>\n        <div class=\"fin-doc-zone\" id=\"fin-zone-2\" onclick=\"document.getElementById('fin-file-2').click()\" style=\"border:2px dashed var(--g200);border-radius:var(--r);padding:16px;text-align:center;cursor:pointer;transition:all 0.2s;background:var(--g50);position:relative;min-height:90px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px\">\n          <input type=\"file\" id=\"fin-file-2\" accept=\".pdf,.doc,.docx,.csv,.xls,.xlsx,image\/*\" style=\"position:absolute;inset:0;opacity:0;cursor:pointer\" onchange=\"handleFinDoc(this,2)\" \/>\n          <div style=\"font-size:22px\" id=\"fin-icon-2\">\ud83d\udcc2<\/div>\n          <div style=\"font-size:11px;color:var(--g400)\" id=\"fin-label-2\">Tax Return \/ P&L<br\/>Year 2<\/div>\n        <\/div>\n        <div id=\"fin-doc-name-2\" style=\"font-size:11px;color:var(--g600);margin-top:4px;text-align:center;display:none\"><\/div>\n      <\/div>\n\n      <!-- Year 3 -->\n      <div>\n        <div style=\"font-size:11px;font-weight:700;color:var(--g600);text-transform:uppercase;letter-spacing:0.5px;margin-bottom:6px\">Year 3 (Latest)<\/div>\n        <div class=\"fin-doc-zone\" id=\"fin-zone-3\" onclick=\"document.getElementById('fin-file-3').click()\" style=\"border:2px dashed var(--g200);border-radius:var(--r);padding:16px;text-align:center;cursor:pointer;transition:all 0.2s;background:var(--g50);position:relative;min-height:90px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px\">\n          <input type=\"file\" id=\"fin-file-3\" accept=\".pdf,.doc,.docx,.csv,.xls,.xlsx,image\/*\" style=\"position:absolute;inset:0;opacity:0;cursor:pointer\" onchange=\"handleFinDoc(this,3)\" \/>\n          <div style=\"font-size:22px\" id=\"fin-icon-3\">\ud83d\udcc2<\/div>\n          <div style=\"font-size:11px;color:var(--g400)\" id=\"fin-label-3\">Tax Return \/ P&L<br\/>Year 3 \/ Latest<\/div>\n        <\/div>\n        <div id=\"fin-doc-name-3\" style=\"font-size:11px;color:var(--g600);margin-top:4px;text-align:center;display:none\"><\/div>\n      <\/div>\n    <\/div>\n\n    <div style=\"display:flex;align-items:center;gap:10px;flex-wrap:wrap\">\n      <button class=\"btn btn-gold btn-sm\" onclick=\"runFinExtraction()\">\u2728 Extract Financials from Documents<\/button>\n      <button class=\"btn btn-outline btn-sm\" onclick=\"clearFinDocs()\">\u2715 Clear All<\/button>\n      <span style=\"font-size:11px;color:var(--g400)\">Supports PDF, Word, Excel\/CSV, JPG\/PNG \u00b7 Tax returns, P&amp;Ls, QuickBooks exports<\/span>\n    <\/div>\n    <div id=\"fin-extract-status\" style=\"display:none;margin-top:12px\"><\/div>\n\n    <!-- Uploaded document image previews -->\n    <div id=\"fin-img-previews\" style=\"display:none;margin-top:16px;border-top:1px solid var(--g100);padding-top:14px\">\n      <div style=\"font-size:12px;font-weight:700;color:var(--g600);text-transform:uppercase;letter-spacing:0.5px;margin-bottom:10px\">Uploaded Documents Preview<\/div>\n      <div style=\"display:grid;grid-template-columns:repeat(3,1fr);gap:10px\" id=\"fin-img-grid\"><\/div>\n      <p style=\"font-size:11px;color:var(--g400);margin-top:8px\">These document thumbnails will appear in the printed CIM appendix as source document references.<\/p>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- COMPETITION -->\n<div class=\"panel\" id=\"panel-s-competition\">\n  <div class=\"card\">\n    <div class=\"card-title\">Competition &amp; Industry Analysis<\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Competitive Landscape<\/label>\n    <textarea id=\"f-competition\" class=\"tla\" placeholder=\"Who are the main competitors? How does this business compare?\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiResearch('f-competition','competition')\">\ud83c\udf10 Research Competitors<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-competition','improve')\">Improve<\/button>\n    <\/div>\n    <div class=\"fg\" style=\"margin-top:14px;margin-bottom:0\"><label>Industry Analysis &amp; Trends<\/label>\n    <textarea id=\"f-industry\" class=\"tla\" placeholder=\"Industry overview, market size, growth trends, tailwinds...\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiResearch('f-industry','industry')\">\ud83c\udf10 Research Industry<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-industry','improve')\">Improve<\/button>\n    <\/div>\n    <div class=\"fg\" style=\"margin-top:14px;margin-bottom:0\"><label>Public Reviews Summary<\/label>\n    <textarea id=\"f-reviews\" placeholder=\"Google\/Yelp ratings, review themes, online reputation...\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiResearch('f-reviews','reviews')\">\ud83c\udf10 Research Public Reviews<\/button>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- GROWTH -->\n<div class=\"panel\" id=\"panel-s-growth\">\n  <div class=\"card\">\n    <div class=\"card-title\">Growth Opportunities<\/div>\n    <div class=\"fg\" style=\"margin-bottom:0\"><label>Growth Opportunities (one per line)<\/label>\n    <textarea id=\"f-growth\" class=\"tla\" placeholder=\"Expand to second location&#10;Add online ordering \/ delivery&#10;Launch corporate catering program&#10;Extend operating hours\"><\/textarea><\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiGen('f-growth','growth_opportunities')\">\ud83e\ude84 Generate from Data<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-growth','improve')\">Improve<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-growth','expand')\">Add More<\/button>\n    <\/div>\n  <\/div>\n  <div class=\"card\">\n    <div class=\"card-title\">Reason for Sale &amp; Transition Support<\/div>\n    <div class=\"fr\">\n      <div class=\"fg\"><label>Reason for Sale<\/label><textarea id=\"f-reason\" placeholder=\"Owner is retiring after 12 years...\"><\/textarea><\/div>\n      <div class=\"fg\"><label>Transition Support Offered<\/label><textarea id=\"f-transition\" placeholder=\"Seller will provide 4 weeks full-time training...\"><\/textarea><\/div>\n    <\/div>\n    <div class=\"ai-bar\">\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-reason','professional')\">Improve Reason<\/button>\n      <button class=\"ai-btn\" onclick=\"aiAssist('f-transition','professional')\">Improve Transition<\/button>\n    <\/div>\n  <\/div>\n<\/div>\n\n<!-- ASSETS -->\n<div class=\"panel\" id=\"panel-s-assets\">\n  <div class=\"card\">\n    <div class=\"card-title\">Asset List (Included in Sale)<\/div>\n    <div style=\"display:grid;grid-template-columns:2fr 1fr 1fr 80px;gap:8px;margin-bottom:8px;align-items:center\">\n      <span style=\"font-size:11px;font-weight:700;color:var(--g600)\">ITEM DESCRIPTION<\/span>\n      <span style=\"font-size:11px;font-weight:700;color:var(--g600)\">QTY<\/span>\n      <span style=\"font-size:11px;font-weight:700;color:var(--g600)\">FAIR MKT VALUE<\/span>\n      <span><\/span>\n    <\/div>\n    <div id=\"asset-rows\"><\/div>\n    <button class=\"btn btn-outline btn-sm\" style=\"margin-top:8px\" onclick=\"addAssetRow()\">+ Add Asset<\/button>\n    <div class=\"fg\" style=\"margin-top:16px\"><label>Asset List Notes<\/label>\n    <textarea id=\"f-asset-notes\" placeholder=\"Note any FF&amp;E, real estate, IP, vehicles included in the sale...\"><\/textarea><\/div>\n  <\/div>\n<\/div>\n\n<!-- APPENDIX -->\n<div class=\"panel\" id=\"panel-s-appendix\">\n  <div class=\"card\">\n    <div class=\"card-title\">Confidentiality Disclaimer<\/div>\n    <div class=\"fg\" style=\"margin-bottom:14px\"><label>Disclaimer Text<\/label>\n    <textarea id=\"f-disclaimer\" class=\"tla\">This Confidential Information Memorandum (\"CIM\") has been prepared by 360 Biz Brokers on behalf of the Seller for informational purposes only. The information contained herein is believed to be accurate and reliable, but neither the Seller nor 360 Biz Brokers makes any representation or warranty, express or implied, as to the accuracy or completeness of the information.\n\nThis document is strictly confidential and is intended solely for the use of the prospective buyer to whom it is addressed. By accepting this CIM, the recipient agrees to maintain the confidentiality of the information and not to disclose it to any third party without prior written consent.\n\nThis CIM does not constitute an offer to sell or a solicitation of an offer to buy. Any prospective buyer should conduct their own independent due diligence and seek independent professional advice before making any investment decision.\n\nAll financial projections and forward-looking statements are based on assumptions believed to be reasonable but are subject to significant uncertainties. Past performance is not indicative of future results.<\/textarea><\/div>\n    <div class=\"fg\"><label>Additional Appendix Notes<\/label>\n    <textarea id=\"f-appendix\" placeholder=\"Documents provided in appendix, due diligence requirements, additional disclosures...\"><\/textarea><\/div>\n  <\/div>\n<\/div>\n\n<!-- PHOTOS -->\n<div class=\"panel\" id=\"panel-s-photos\">\n  <div class=\"card\">\n    <div class=\"card-title\">Logos &amp; Key Images<\/div>\n    <div class=\"ugrid\">\n      <div class=\"uitem\"><label>Broker Logo<\/label>\n        <div class=\"iuz\" onclick=\"trig('up-broker-logo')\"><input type=\"file\" id=\"up-broker-logo\" accept=\"image\/*\" onchange=\"handleImg(this,'broker-logo')\" \/><img id=\"img-broker-logo\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-broker-logo\">\ud83d\udcce<br\/><span class=\"ul\">Broker Logo<\/span><\/div><\/div>\n      <\/div>\n      <div class=\"uitem\"><label>Broker Badge<\/label>\n        <div class=\"iuz\" onclick=\"trig('up-broker-badge')\"><input type=\"file\" id=\"up-broker-badge\" accept=\"image\/*\" onchange=\"handleImg(this,'broker-badge')\" \/><img id=\"img-broker-badge\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-broker-badge\">\ud83d\udcce<br\/><span class=\"ul\">Badge \/ Award<\/span><\/div><\/div>\n      <\/div>\n      <div class=\"uitem\"><label>Business Logo<\/label>\n        <div class=\"iuz\" onclick=\"trig('up-biz-logo')\"><input type=\"file\" id=\"up-biz-logo\" accept=\"image\/*\" onchange=\"handleImg(this,'biz-logo')\" \/><img id=\"img-biz-logo\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-biz-logo\">\ud83d\udcce<br\/><span class=\"ul\">Biz Logo<\/span><\/div><\/div>\n      <\/div>\n      <div class=\"uitem\"><label>Broker Photo<\/label>\n        <div class=\"iuz\" onclick=\"trig('up-broker-photo')\"><input type=\"file\" id=\"up-broker-photo\" accept=\"image\/*\" onchange=\"handleImg(this,'broker-photo')\" \/><img id=\"img-broker-photo\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-broker-photo\">\ud83d\udcce<br\/><span class=\"ul\">Broker Photo<\/span><\/div><\/div>\n      <\/div>\n    <\/div>\n  <\/div>\n  <div class=\"card\">\n    <div class=\"card-title\">Business Photos<\/div>\n    <div class=\"ugrid\">\n      <div class=\"uitem\"><label>Cover \/ Hero Photo<\/label>\n        <div class=\"iuz\" style=\"height:90px\" onclick=\"trig('up-cover')\"><input type=\"file\" id=\"up-cover\" accept=\"image\/*\" onchange=\"handleImg(this,'cover-photo')\" \/><img id=\"img-cover-photo\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-cover-photo\">\ud83d\udcce<br\/><span class=\"ul\">Cover Photo<\/span><\/div><\/div>\n      <\/div>\n      <div class=\"uitem\"><label>Photo 2<\/label>\n        <div class=\"iuz\" style=\"height:90px\" onclick=\"trig('up-p2')\"><input type=\"file\" id=\"up-p2\" accept=\"image\/*\" onchange=\"handleImg(this,'p2')\" \/><img id=\"img-p2\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-p2\">\ud83d\udcce<br\/><span class=\"ul\">Photo 2<\/span><\/div><\/div>\n      <\/div>\n      <div class=\"uitem\"><label>Photo 3<\/label>\n        <div class=\"iuz\" style=\"height:90px\" onclick=\"trig('up-p3')\"><input type=\"file\" id=\"up-p3\" accept=\"image\/*\" onchange=\"handleImg(this,'p3')\" \/><img id=\"img-p3\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-p3\">\ud83d\udcce<br\/><span class=\"ul\">Photo 3<\/span><\/div><\/div>\n      <\/div>\n      <div class=\"uitem\"><label>Photo 4<\/label>\n        <div class=\"iuz\" style=\"height:90px\" onclick=\"trig('up-p4')\"><input type=\"file\" id=\"up-p4\" accept=\"image\/*\" onchange=\"handleImg(this,'p4')\" \/><img id=\"img-p4\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-p4\">\ud83d\udcce<br\/><span class=\"ul\">Photo 4<\/span><\/div><\/div>\n      <\/div>\n      <div class=\"uitem\"><label>Photo 5<\/label>\n        <div class=\"iuz\" style=\"height:90px\" onclick=\"trig('up-p5')\"><input type=\"file\" id=\"up-p5\" accept=\"image\/*\" onchange=\"handleImg(this,'p5')\" \/><img id=\"img-p5\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-p5\">\ud83d\udcce<br\/><span class=\"ul\">Photo 5<\/span><\/div><\/div>\n      <\/div>\n      <div class=\"uitem\"><label>Photo 6<\/label>\n        <div class=\"iuz\" style=\"height:90px\" onclick=\"trig('up-p6')\"><input type=\"file\" id=\"up-p6\" accept=\"image\/*\" onchange=\"handleImg(this,'p6')\" \/><img id=\"img-p6\" class=\"img-preview\" style=\"display:none\" \/><div id=\"ph-p6\">\ud83d\udcce<br\/><span class=\"ul\">Photo 6<\/span><\/div><\/div>\n      <\/div>\n    <\/div>\n  <\/div>\n<\/div>\n\n  <\/div><!-- \/content -->\n<\/div><!-- \/main -->\n<\/div><!-- \/app -->\n<!-- PREVIEW OVERLAY -->\n<div id=\"preview-overlay\">\n  <div class=\"preview-controls\">\n    <span style=\"color:#aaa;font-size:13px;margin-right:auto\">CIM Preview \u2014 use Print to save as PDF<\/span>\n    <button class=\"btn btn-outline\" onclick=\"printCIM()\" style=\"background:rgba(255,255,255,0.1);border-color:rgba(255,255,255,0.3);color:white\">\ud83d\udda8 Print \/ Save PDF<\/button>\n    <button class=\"btn btn-ghost\" onclick=\"closePreview()\" style=\"color:#aaa\">\u2715 Close<\/button>\n  <\/div>\n  <div id=\"cim-doc\"><\/div>\n<\/div>\n\n<!-- AI MODAL -->\n<div class=\"modal-overlay\" id=\"ai-modal\">\n  <div class=\"modal\">\n    <div class=\"modal-title\">\u2728 AI Writing Assistant<\/div>\n    <div id=\"ai-status\" class=\"smsg info\">Processing...<\/div>\n    <div id=\"ai-result\" style=\"margin-top:16px;font-size:14px;line-height:1.7;white-space:pre-wrap;min-height:80px;padding:12px;background:#f9f9f9;border-radius:8px;border:1px solid #eee;display:none\"><\/div>\n    <div class=\"modal-footer\">\n      <button class=\"btn btn-outline\" onclick=\"closeAiModal()\">Cancel<\/button>\n      <button class=\"btn btn-gold\" id=\"ai-apply-btn\" style=\"display:none\" onclick=\"applyAi()\">Apply to Field<\/button>\n    <\/div>\n  <\/div>\n<\/div>\n\n<script>\nconst ST = { tpl:1, imgs:{}, aiResult:'', aiField:'' };\n\n\/\/ NAV\ndocument.querySelectorAll('.nav-item').forEach(n => n.addEventListener('click', () => { const p=n.dataset.panel; if(p) gotoPanel(p); }));\nfunction gotoPanel(id) {\n  document.querySelectorAll('.panel').forEach(p => p.classList.remove('active'));\n  document.querySelectorAll('.nav-item').forEach(n => n.classList.remove('active'));\n  const p=document.getElementById('panel-'+id); if(p) p.classList.add('active');\n  const n=document.querySelector(`[data-panel=\"${id}\"]`); if(n) n.classList.add('active');\n  updateProgress();\n}\ndocument.getElementById('sidebar-tpl-btn').addEventListener('click', ()=>gotoPanel('template'));\n\nfunction updateTopbar() {\n  document.getElementById('topbar-biz').textContent = g('f-biz-name')||'New CIM';\n}\n\n\/\/ TEMPLATE\nfunction selectTemplate(n) {\n  ST.tpl=n;\n  document.querySelectorAll('.tcard').forEach(c=>c.classList.remove('selected'));\n  document.querySelector(`[data-tpl=\"${n}\"]`).classList.add('selected');\n  const nm={1:'Gold & Black',2:'Navy Professional',3:'Forest Green',4:'Burgundy Luxury'};\n  document.getElementById('sidebar-tpl-btn').textContent='\u25c8 Template: '+nm[n];\n}\n\n\/\/ IMAGE UPLOAD\nfunction trig(id) { document.getElementById(id).click(); }\nfunction handleImg(input, key) {\n  const file=input.files[0]; if(!file) return;\n  const rd=new FileReader();\n  rd.onload=(e)=>{\n    ST.imgs[key]=e.target.result;\n    const img=document.getElementById('img-'+key);\n    const ph=document.getElementById('ph-'+key);\n    if(img){img.src=e.target.result;img.style.display='block';}\n    if(ph)ph.style.display='none';\n  };\n  rd.readAsDataURL(file);\n}\n\n\/\/ ASSETS\nfunction addAssetRow() {\n  const c=document.getElementById('asset-rows');\n  const r=document.createElement('div');\n  r.style.cssText='display:grid;grid-template-columns:2fr 1fr 1fr 80px;gap:8px;margin-bottom:6px;align-items:center';\n  r.innerHTML=`<input type=\"text\" placeholder=\"e.g. Commercial Espresso Machine\" style=\"font-size:13px\" \/><input type=\"text\" placeholder=\"1\" style=\"font-size:13px\" \/><input type=\"text\" placeholder=\"$4,500\" style=\"font-size:13px\" \/><button class=\"btn btn-ghost btn-sm\" onclick=\"this.parentElement.remove()\" style=\"color:#dc2626\">\u2715<\/button>`;\n  c.appendChild(r);\n}\nfor(let i=0;i<3;i++) addAssetRow();\n\n\/\/ PROGRESS\nfunction updateProgress() {\n  const fids=['f-biz-name','f-exec','f-broker-bio','f-biz-desc','f-highlights','f-loc-desc','f-products','f-ops','f-facilities','f-rev3','f-sde3','f-competition','f-industry','f-growth','f-reason','f-disclaimer'];\n  const filled=fids.filter(id=>{ const el=document.getElementById(id); return el&&el.value.trim().length>5; }).length;\n  const pct=Math.round(filled\/fids.length*100);\n  document.getElementById('d-filled').textContent=filled;\n  document.getElementById('d-total').textContent=fids.length;\n  document.getElementById('d-pct').textContent=pct+'%';\n  document.getElementById('dash-pg').style.width=pct+'%';\n}\n\n\/\/ SAVE\/LOAD\nfunction saveData() {\n  const data={};\n  document.querySelectorAll('input[type=text],input[type=email],textarea,select').forEach(el=>{ if(el.id) data[el.id]=el.value; });\n  data._tpl=ST.tpl; data._imgs=ST.imgs;\n  try { localStorage.setItem('cim360',JSON.stringify(data)); toast('Progress saved \u2713'); } catch(e) { toast('Save failed \u2014 too large','err'); }\n}\nfunction loadData() {\n  try {\n    const raw=localStorage.getItem('cim360'); if(!raw) return;\n    const data=JSON.parse(raw);\n    Object.keys(data).forEach(k=>{\n      if(k==='_tpl'){selectTemplate(data[k]);return;}\n      if(k==='_imgs'){\n        ST.imgs=data[k];\n        Object.keys(data[k]).forEach(ik=>{ const img=document.getElementById('img-'+ik); const ph=document.getElementById('ph-'+ik); if(img){img.src=data[k][ik];img.style.display='block';} if(ph)ph.style.display='none'; });\n        return;\n      }\n      const el=document.getElementById(k); if(el) el.value=data[k];\n    });\n    updateTopbar(); updateProgress();\n  } catch(e) {}\n}\nfunction toast(msg,type) {\n  const t=document.createElement('div');\n  t.textContent=msg;\n  t.style.cssText=`position:fixed;bottom:24px;right:24px;background:${type==='err'?'#dc2626':'#111'};color:${type==='err'?'white':'#C9A84C'};padding:12px 20px;border-radius:8px;font-size:13px;font-weight:700;z-index:9999;box-shadow:0 4px 20px rgba(0,0,0,0.3)`;\n  document.body.appendChild(t); setTimeout(()=>t.remove(),3000);\n}\n\n\/\/ HELPERS\nfunction g(id) { const el=document.getElementById(id); return el?el.value.trim():''; }\nfunction im(k) { return ST.imgs[k]||null; }\n\n\/\/ AI CALLS\nconst DEFAULT_PROXY_URL = (document.getElementById('proxy-url')?.value || 'https:\/\/360bizbrokers.com\/wp-json\/bbf\/v1\/openai-ai').trim();\nconst AI_MODEL = 'gpt-4.1';\n\nfunction getProxyUrl() {\n  return (localStorage.getItem('cim360_openai_proxy_url') || document.getElementById('ai-proxy-input')?.value || DEFAULT_PROXY_URL).trim();\n}\n\nfunction initAiProxySettings() {\n  const inp = document.getElementById('ai-proxy-input');\n  if (inp) inp.value = getProxyUrl();\n}\n\nfunction saveAiProxyUrl() {\n  const inp = document.getElementById('ai-proxy-input');\n  const url = (inp?.value || '').trim();\n  const status = document.getElementById('ai-proxy-status');\n  if (!url || !\/^https?:\\\/\\\/\/i.test(url)) {\n    if (status) { status.style.display='block'; status.innerHTML='<div class=\"smsg error\">Please enter a full URL beginning with https:\/\/<\/div>'; }\n    return;\n  }\n  localStorage.setItem('cim360_openai_proxy_url', url);\n  if (status) { status.style.display='block'; status.innerHTML='<div class=\"smsg success\">AI proxy URL saved.<\/div>'; }\n}\n\nasync function testAIProxy() {\n  saveAiProxyUrl();\n  const status = document.getElementById('ai-proxy-status');\n  if (status) { status.style.display='block'; status.innerHTML='<div class=\"smsg info\">Testing AI proxy...<\/div>'; }\n  try {\n    const text = await callAI('Reply with exactly: OK', 'Connection test');\n    if (status) status.innerHTML='<div class=\"smsg success\">\u2705 AI proxy responded successfully: ' + escapeHtml(text.substring(0,80)) + '<\/div>';\n  } catch (e) {\n    if (status) status.innerHTML='<div class=\"smsg error\">\u274c ' + escapeHtml(e.message) + '<\/div>';\n  }\n}\n\nfunction escapeHtml(str) {\n  return String(str || '').replace(\/[&<>\"']\/g, ch => ({'&':'&amp;','<':'&lt;','>':'&gt;','\"':'&quot;',\"'\":'&#39;'}[ch]));\n}\n\nasync function callProxyAI(payload) {\n  const url = getProxyUrl();\n  let resp;\n  try {\n    resp = await fetch(url, { method:'POST', headers:{'Content-Type':'application\/json'}, body:JSON.stringify(payload) });\n  } catch (err) {\n    throw new Error('Could not reach AI proxy. Check the proxy URL and CORS settings. Details: ' + err.message);\n  }\n  const bodyText = await resp.text();\n  if (!resp.ok) {\n    let extra = bodyText ? ' \u2014 ' + bodyText.substring(0, 240) : '';\n    if (resp.status === 404) {\n      throw new Error('AI proxy route not found (404). The WordPress REST endpoint in AI Connection is missing or incorrect: ' + url + extra);\n    }\n    throw new Error('AI proxy error ' + resp.status + ': ' + resp.statusText + extra);\n  }\n  let data;\n  try { data = JSON.parse(bodyText); } catch (e) { throw new Error('AI proxy returned non-JSON response: ' + bodyText.substring(0, 240)); }\n  if (data && data.error) throw new Error(data.error.message || data.error || 'API error');\n  return data;\n}\n\nfunction extractJsonObject(rawText) {\n  \/\/ OpenAI may occasionally return valid JSON followed by notes or a second object.\n  \/\/ This parser finds the first complete top-level JSON object and ignores anything after it.\n  const clean = String(rawText || '').replace(\/```json|```\/gi,'').trim();\n  try { return JSON.parse(clean); } catch (_) {}\n\n  const start = clean.indexOf('{');\n  if (start < 0) {\n    throw new Error('AI response did not contain a JSON object. Response started: ' + clean.substring(0, 180));\n  }\n\n  let depth = 0;\n  let inString = false;\n  let escapeNext = false;\n\n  for (let i = start; i < clean.length; i++) {\n    const ch = clean[i];\n\n    if (escapeNext) { escapeNext = false; continue; }\n    if (ch === '\\\\' && inString) { escapeNext = true; continue; }\n    if (ch === '\"') { inString = !inString; continue; }\n    if (inString) continue;\n\n    if (ch === '{') depth++;\n    if (ch === '}') {\n      depth--;\n      if (depth === 0) {\n        const candidate = clean.slice(start, i + 1);\n        try { return JSON.parse(candidate); }\n        catch (err) {\n          throw new Error('AI returned malformed JSON. Parser detail: ' + err.message + '. Response started: ' + clean.substring(0, 180));\n        }\n      }\n    }\n  }\n\n  throw new Error('AI response contained an incomplete JSON object. Response started: ' + clean.substring(0, 180));\n}\n\n\/\/ Normalise whatever shape the WP proxy returns into a plain text string\nfunction parseProxyResponse(data) {\n  \/\/ Shape 1: standard Anthropic API  { content: [{type:'text', text:'...'}] }\n  if (data && Array.isArray(data.content)) {\n    return data.content.map(b => b.text || '').join('');\n  }\n  \/\/ Shape 2: proxy already extracted text  { text: '...' }\n  if (data && typeof data.text === 'string') return data.text;\n  \/\/ Shape 3: proxy returns  { response: '...' }\n  if (data && typeof data.response === 'string') return data.response;\n  \/\/ Shape 4: proxy returns  { result: '...' }\n  if (data && typeof data.result === 'string') return data.result;\n  \/\/ Shape 5: proxy returns  { message: '...' }\n  if (data && typeof data.message === 'string' && !data.error) return data.message;\n  \/\/ Shape 6: proxy wraps in  { data: { content:[...] } }\n  if (data && data.data && Array.isArray(data.data.content)) {\n    return data.data.content.map(b => b.text || '').join('');\n  }\n  \/\/ Shape 7: proxy returns  { choices: [{message:{content:'...'}}] }  (OpenAI-compat)\n  if (data && Array.isArray(data.choices) && data.choices[0]) {\n    return data.choices[0].message?.content || data.choices[0].text || '';\n  }\n  \/\/ Nothing matched \u2014 throw with the raw payload so we can debug\n  throw new Error('Unexpected proxy response format: ' + JSON.stringify(data).substring(0, 200));\n}\n\nasync function callAI(system, user) {\n  const payload={ model:AI_MODEL, max_tokens:1000, system, messages:[{role:'user',content:user}] };\n  const data = await callProxyAI(payload);\n  return parseProxyResponse(data);\n}\n\nfunction ctx() {\n  const fs={\n    'Business Name':'f-biz-name','Type':'f-biz-type','Asking Price':'f-asking-price',\n    'Revenue':'f-revenue','SDE':'f-sde','Location':'f-location','Years':'f-years',\n    'Description':'f-biz-desc','Advantages':'f-advantages','Products':'f-products',\n    'Operations':'f-ops','Employees':'f-employees','Facilities':'f-facilities',\n    'Revenue Yr3':'f-rev3','SDE Yr3':'f-sde3','Growth':'f-growth','Reason for Sale':'f-reason'\n  };\n  return Object.entries(fs).map(([k,v])=>{ const el=document.getElementById(v); return el&&el.value?`${k}: ${el.value}`:null; }).filter(Boolean).join('\\n');\n}\n\nfunction openAiModal(fieldId) {\n  ST.aiField=fieldId;\n  document.getElementById('ai-modal').classList.add('open');\n  document.getElementById('ai-status').className='smsg info';\n  document.getElementById('ai-status').textContent='\u23f3 AI is processing...';\n  document.getElementById('ai-result').style.display='none';\n  document.getElementById('ai-apply-btn').style.display='none';\n  ST.aiResult='';\n}\nfunction closeAiModal() { document.getElementById('ai-modal').classList.remove('open'); }\nfunction applyAi() {\n  if(ST.aiField&&ST.aiResult) { const el=document.getElementById(ST.aiField); if(el) el.value=ST.aiResult; closeAiModal(); toast('AI content applied \u2713'); updateProgress(); }\n}\n\nasync function aiAssist(fieldId, action) {\n  const txt=g(fieldId);\n  const map={\n    improve:'Improve the wording, clarity, and flow while preserving all key facts.',\n    professional:'Rewrite in a highly professional, investment-grade business tone.',\n    summarize:'Summarize concisely while keeping the most important points.',\n    expand:'Expand with more detail, professional language, and depth. Keep it factual.',\n    buyer:'Rewrite from what a sophisticated buyer\/investor wants to hear. Focus on opportunity, ROI, and value.',\n  };\n  openAiModal(fieldId);\n  try {\n    const sys=`You are an expert business broker and M&A advisor writing professional CIMs. ${map[action]||'Improve this text.'} Return ONLY the improved text.`;\n    ST.aiResult=await callAI(sys,txt||'Write placeholder professional content for this CIM section.');\n    document.getElementById('ai-status').textContent='\u2705 Review the result:';\n    document.getElementById('ai-result').textContent=ST.aiResult;\n    document.getElementById('ai-result').style.display='block';\n    document.getElementById('ai-apply-btn').style.display='inline-flex';\n  } catch(e) {\n    document.getElementById('ai-status').className='smsg error';\n    document.getElementById('ai-status').textContent='\u274c '+e.message;\n  }\n}\n\nasync function aiGen(fieldId, type) {\n  openAiModal(fieldId);\n  const c=ctx();\n  const prompts={\n    executive_summary:`Write a compelling 3-5 paragraph executive summary for this business CIM. Professional, written for sophisticated buyers\/investors. Highlight the opportunity, financial performance, and investment thesis.\\n\\nBusiness Data:\\n${c}`,\n    investment_highlights:`Generate 6-8 compelling investment highlights as bullet points. Each should be concise and impactful. One per line.\\n\\nBusiness Data:\\n${c}`,\n    growth_opportunities:`Generate 6-8 realistic growth opportunities. Each concise and actionable. One per line.\\n\\nBusiness Data:\\n${c}`,\n  };\n  try {\n    ST.aiResult=await callAI('You are an expert M&A advisor writing investment-grade CIMs. Return ONLY the content, no preamble.',prompts[type]);\n    document.getElementById('ai-status').textContent='\u2705 Review the result:';\n    document.getElementById('ai-result').textContent=ST.aiResult;\n    document.getElementById('ai-result').style.display='block';\n    document.getElementById('ai-apply-btn').style.display='inline-flex';\n  } catch(e) {\n    document.getElementById('ai-status').className='smsg error';\n    document.getElementById('ai-status').textContent='\u274c '+e.message;\n  }\n}\n\nasync function aiResearch(fieldId, type) {\n  openAiModal(fieldId);\n  const bizName=g('f-biz-name')||'this business';\n  const loc=g('f-location');\n  const bizType=g('f-biz-type');\n  const prompts={\n    location:`Write a professional location and market overview for a ${bizType} called \"${bizName}\" in ${loc}. Include area demographics, traffic patterns, demand drivers, and why this is a favorable location. Label content as [AI Research \u2014 verify with local data]. Write 2-3 paragraphs.`,\n    competition:`Write a professional competitive landscape overview for a ${bizType} in ${loc}. Describe competitive environment, types of competitors, differentiation strategies. Label as [AI Research \u2014 verify with local knowledge]. Write 2-3 paragraphs.`,\n    industry:`Write a professional industry analysis for the ${bizType} sector. Include market size, growth trends, key drivers, headwinds, and outlook. Label as [AI Research \u2014 verify with current data]. Write 3-4 paragraphs.`,\n    reviews:`For a ${bizType} called \"${bizName}\" in ${loc}, write a professional online reputation summary. What strong reviews look like for this type of business and what buyers should expect. Label as [AI Research \u2014 verify actual ratings directly]. Write 1-2 paragraphs.`,\n  };\n  try {\n    ST.aiResult=await callAI('You are an expert M&A research analyst writing content for a business CIM. Always indicate AI-researched content clearly. Return ONLY the research content.',prompts[type]);\n    document.getElementById('ai-status').textContent='\u2705 AI research complete. Verify key facts before publishing:';\n    document.getElementById('ai-result').textContent=ST.aiResult;\n    document.getElementById('ai-result').style.display='block';\n    document.getElementById('ai-apply-btn').style.display='inline-flex';\n  } catch(e) {\n    document.getElementById('ai-status').className='smsg error';\n    document.getElementById('ai-status').textContent='\u274c '+e.message;\n  }\n}\n\n\/\/ CIM PREVIEW + BUILD\nfunction showPreview() { updateProgress(); document.getElementById('cim-doc').innerHTML=buildCIM(); document.getElementById('preview-overlay').classList.add('open'); }\nfunction closePreview() { document.getElementById('preview-overlay').classList.remove('open'); }\nfunction printCIM() {\n  \/\/ Print from a clean, dedicated document so the app UI, overlay scrollbar,\n  \/\/ translation widgets, and browser preview chrome do not appear in the PDF.\n  const cimHtml = buildCIM();\n  const printWin = window.open('', '_blank');\n  if (!printWin) {\n    showPreview();\n    setTimeout(() => window.print(), 500);\n    return;\n  }\n\n  const printCss = `\n    @page { size: letter; margin: 0; }\n    * { box-sizing: border-box; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }\n    html, body { margin: 0 !important; padding: 0 !important; width: 100%; background: #fff !important; font-family: 'Lato', Arial, sans-serif; }\n    body { overflow: visible !important; }\n    img { max-width: 100%; }\n    .pgb { page-break-after: always; break-after: page; }\n    @media print {\n      html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }\n      #print-root { width: 100% !important; margin: 0 !important; padding: 0 !important; }\n      #print-root > div { width: 100% !important; max-width: none !important; margin: 0 !important; box-shadow: none !important; border-radius: 0 !important; }\n      .pgb { page-break-after: always; break-after: page; }\n    }\n  `;\n\n  printWin.document.open();\n  printWin.document.write(`<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<title>CIM Export<\/title>\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Anton&family=Lato:wght@300;400;700;900&family=Playfair+Display:wght@400;600;700&family=Montserrat:wght@300;400;600;700&display=swap\" rel=\"stylesheet\">\n<style>${printCss}<\/style>\n<\/head>\n<body><div id=\"print-root\">${cimHtml}<\/div><\/body>\n<\/html>`);\n  printWin.document.close();\n\n  printWin.onload = () => {\n    setTimeout(() => {\n      printWin.focus();\n      printWin.print();\n    }, 700);\n  };\n}\n\nfunction buildCIM() {\n  const t=ST.tpl;\n  const tc={\n    1:{bg:'#111111',ac:'#C9A84C',tx:'white',sb:'rgba(255,255,255,0.5)',tf:\"'Anton',sans-serif\"},\n    2:{bg:'#1a2744',ac:'#4a90d9',tx:'white',sb:'rgba(255,255,255,0.5)',tf:\"'Playfair Display',serif\"},\n    3:{bg:'#1b3a2d',ac:'#5cb87a',tx:'white',sb:'rgba(255,255,255,0.5)',tf:\"'Montserrat',sans-serif\"},\n    4:{bg:'#2d0a1e',ac:'#b8436e',tx:'white',sb:'rgba(255,255,255,0.5)',tf:\"'Playfair Display',serif\"},\n  }[t];\n\n  const bn=g('f-biz-name')||'Business Name';\n  const bt=g('f-biz-type');\n  const ap=g('f-asking-price');\n  const rv=g('f-revenue');\n  const sd=g('f-sde');\n  const lc=g('f-location');\n  const yr=g('f-years');\n  const bk=g('f-brokerage')||'360 Biz Brokers';\n  const brn=g('f-broker-name');\n\n  function tp(text) {\n    if(!text) return '';\n    return text.split('\\n').filter(l=>l.trim()).map(l=>`<p style=\"margin-bottom:12px\">${l.trim()}<\/p>`).join('');\n  }\n  function tb(text) {\n    if(!text) return '';\n    return `<ul style=\"list-style:none;padding:0;margin:0\">${text.split('\\n').filter(l=>l.trim()).map(l=>`<li style=\"padding:7px 0 7px 20px;position:relative;font-size:14px;border-bottom:1px solid #f5f5f5;line-height:1.6\"><span style=\"position:absolute;left:0;color:${tc.ac};font-size:12px;top:9px\">\u25b8<\/span>${l.trim().replace(\/^[-\u2022*\u25b8]\\s*\/,'')}<\/li>`).join('')}<\/ul>`;\n  }\n  function sec(label, title, body) {\n    if(!body||!body.trim()) return '';\n    return `<div style=\"padding:44px 60px;border-bottom:1px solid #f0f0f0;background:white\">\n      ${label?`<div style=\"font-size:10px;text-transform:uppercase;letter-spacing:3px;color:${tc.ac};margin-bottom:5px;font-weight:700\">${label}<\/div>`:''}\n      <div style=\"font-family:${tc.tf};font-size:26px;font-weight:700;color:#111;margin-bottom:20px;padding-bottom:10px;border-bottom:2px solid ${t===1?'#111':tc.ac}\">${title}<\/div>\n      <div style=\"font-size:14px;line-height:1.85;color:#333\">${body}<\/div>\n    <\/div>`;\n  }\n\n  \/\/ Cover meta\n  const metaItems=[['Industry',bt],['Asking Price',ap],['Annual Revenue',rv],['SDE \/ Owner Benefit',sd],['Location',lc],['Years Established',yr?(yr+' Years'):'']].filter(([,v])=>v);\n  const coverMeta=metaItems.length?`<div style=\"display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:36px\">${metaItems.map(([k,v])=>`<div><div style=\"font-size:10px;text-transform:uppercase;letter-spacing:2px;color:${tc.ac};margin-bottom:3px\">${k}<\/div><div style=\"font-size:15px;font-weight:700;color:${tc.tx}\">${v}<\/div><\/div>`).join('')}<\/div>`:'';\n\n  const brokerLogoHtml=im('broker-logo')?`<img decoding=\"async\" src=\"${im('broker-logo')}\" style=\"max-height:50px;max-width:120px;object-fit:contain\" \/>`:`<div style=\"font-family:${tc.tf};font-size:13px;color:${tc.ac};letter-spacing:1px\">${bk}<\/div>`;\n  const bizLogoHtml=im('biz-logo')?`<img decoding=\"async\" src=\"${im('biz-logo')}\" style=\"max-height:50px;max-width:120px;object-fit:contain\" \/>`:'';\n  const coverPhotoHtml=im('cover-photo')?`<div style=\"height:300px;overflow:hidden\"><img decoding=\"async\" src=\"${im('cover-photo')}\" style=\"width:100%;height:100%;object-fit:cover\" \/><\/div>`:'';\n  const badgeHtml=im('broker-badge')?`<img decoding=\"async\" src=\"${im('broker-badge')}\" style=\"max-height:45px;max-width:80px;object-fit:contain;margin-top:10px\" \/>`:'';\n  const brokerPhotoHtml=im('broker-photo')?`<img decoding=\"async\" src=\"${im('broker-photo')}\" style=\"width:90px;height:90px;border-radius:50%;object-fit:cover;border:3px solid ${tc.ac}\" \/>`:`<div style=\"width:90px;height:90px;border-radius:50%;background:rgba(255,255,255,0.1);border:2px solid ${tc.ac};display:flex;align-items:center;justify-content:center;font-size:28px\">\ud83d\udc64<\/div>`;\n\n  \/\/ KPI grid\n  const kpis=[[ap,'Asking Price'],[rv,'Annual Revenue'],[sd,'SDE \/ Owner Benefit'],[yr?yr+' Yrs':'','Years Established']].filter(([v])=>v);\n  const kpiHtml=kpis.length?`<div style=\"display:grid;grid-template-columns:repeat(${Math.min(kpis.length,4)},1fr);gap:14px;margin:24px 0\">${kpis.map(([v,l])=>`<div style=\"background:${tc.bg};padding:18px;border-radius:8px;text-align:center\"><div style=\"font-size:10px;text-transform:uppercase;letter-spacing:2px;color:${tc.ac};margin-bottom:6px\">${l}<\/div><div style=\"font-size:22px;font-weight:900;color:white;font-family:${tc.tf}\">${v}<\/div><\/div>`).join('')}<\/div>`:'';\n\n  \/\/ Financial table\n  const finRows=[['Gross Revenue','f-rev'],['Cost of Goods Sold','f-cogs'],['Gross Profit','f-gp'],['Total Operating Expenses','f-opex'],['Net SDE \/ Owner Benefit','f-sde']];\n  const hasFinData=['f-rev1','f-rev2','f-rev3','f-sde1','f-sde2','f-sde3'].some(id=>g(id));\n  const finTable=hasFinData?`<table style=\"width:100%;border-collapse:collapse;margin:20px 0;font-size:13px\"><thead><tr style=\"background:${tc.bg}\"><th style=\"padding:10px 14px;text-align:left;color:${tc.ac};font-size:11px;text-transform:uppercase;letter-spacing:1px\">Financial Metric<\/th><th style=\"padding:10px 14px;text-align:right;color:${tc.ac};font-size:11px\">Year 1<\/th><th style=\"padding:10px 14px;text-align:right;color:${tc.ac};font-size:11px\">Year 2<\/th><th style=\"padding:10px 14px;text-align:right;color:${tc.ac};font-size:11px\">Year 3 (Latest)<\/th><\/tr><\/thead><tbody>${finRows.map(([lbl,px],i)=>{const last=i===finRows.length-1;const r1=g(px+'1'),r2=g(px+'2'),r3=g(px+'3');return`<tr style=\"${last?'background:#f8f6f0':''}\"><td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;font-weight:${last?900:400};${last?'border-top:2px solid '+tc.ac+';':''}\">${lbl}<\/td><td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right;font-weight:${last?900:400};${last?'border-top:2px solid '+tc.ac+';':''}\">${r1||'\u2014'}<\/td><td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right;font-weight:${last?900:400};${last?'border-top:2px solid '+tc.ac+';':''}\">${r2||'\u2014'}<\/td><td style=\"padding:9px 14px;border-bottom:1px solid #f0f0f0;text-align:right;font-weight:${last?900:400};${last?'border-top:2px solid '+tc.ac+';':''}\">${r3||'\u2014'}<\/td><\/tr>`}).join('')}<\/tbody><\/table>`:'';\n\n  \/\/ Assets\n  const assetRows=Array.from(document.querySelectorAll('#asset-rows > div')).map(r=>{const inp=r.querySelectorAll('input');return inp.length>=3?[inp[0].value,inp[1].value,inp[2].value]:null;}).filter(r=>r&&r[0]);\n  const assetTable=assetRows.length?`<table style=\"width:100%;border-collapse:collapse;margin:16px 0;font-size:13px\"><thead><tr style=\"background:${tc.bg}\"><th style=\"padding:9px 14px;text-align:left;color:${tc.ac};font-size:11px;text-transform:uppercase\">Asset Description<\/th><th style=\"padding:9px 14px;text-align:center;color:${tc.ac};font-size:11px\">Qty<\/th><th style=\"padding:9px 14px;text-align:right;color:${tc.ac};font-size:11px\">FMV<\/th><\/tr><\/thead><tbody>${assetRows.map(([d,q,f])=>`<tr><td style=\"padding:8px 14px;border-bottom:1px solid #f0f0f0\">${d}<\/td><td style=\"padding:8px 14px;border-bottom:1px solid #f0f0f0;text-align:center\">${q||'1'}<\/td><td style=\"padding:8px 14px;border-bottom:1px solid #f0f0f0;text-align:right\">${f||'\u2014'}<\/td><\/tr>`).join('')}<\/tbody><\/table>`:'';\n\n  \/\/ Gallery\n  const gphotos=['p2','p3','p4','p5','p6'].map(k=>im(k)).filter(Boolean);\n  const gallery=gphotos.length?`<div style=\"padding:0 60px 36px;background:white\"><div style=\"display:grid;grid-template-columns:repeat(3,1fr);gap:10px\">${gphotos.slice(0,6).map(s=>`<img decoding=\"async\" src=\"${s}\" style=\"width:100%;height:150px;object-fit:cover;border-radius:6px\" \/>`).join('')}<\/div><\/div>`:'';\n\n  \/\/ Financial body\n  const finBody=[\n    kpiHtml,finTable,\n    g('f-recast')?`<div style=\"background:#f8f6f0;border-left:4px solid ${tc.ac};padding:16px 20px;border-radius:0 6px 6px 0;margin:16px 0;font-size:14px;line-height:1.7\">${tp(g('f-recast'))}<\/div>`:'',\n    [g('f-valuation')&&`<strong>Valuation:<\/strong> ${g('f-valuation')}`,g('f-deal')&&`<strong>Deal Structure:<\/strong> ${g('f-deal')}`].filter(Boolean).join('<br\/>'),\n  ].filter(Boolean).join('');\n\n  \/\/ Broker bio\n  const brokerBio=(g('f-broker-bio')||g('f-broker-fullname'))?`<div style=\"padding:44px 60px;border-bottom:1px solid #f0f0f0;background:white\">\n    <div style=\"font-size:10px;text-transform:uppercase;letter-spacing:3px;color:${tc.ac};margin-bottom:5px;font-weight:700\">Your Listing Broker<\/div>\n    <div style=\"font-family:${tc.tf};font-size:26px;font-weight:700;color:#111;margin-bottom:20px;padding-bottom:10px;border-bottom:2px solid ${t===1?'#111':tc.ac}\">Know Your Broker<\/div>\n    <div style=\"display:grid;grid-template-columns:130px 1fr;gap:24px;background:${tc.bg};border-radius:10px;padding:24px;align-items:start\">\n      ${brokerPhotoHtml}\n      <div>\n        <div style=\"font-size:18px;font-weight:700;color:white;margin-bottom:3px\">${g('f-broker-fullname')||brn}<\/div>\n        <div style=\"font-size:12px;color:${tc.ac};text-transform:uppercase;letter-spacing:1px;margin-bottom:10px\">${g('f-broker-title')||'Principal Broker'}<\/div>\n        ${g('f-broker-phone')?`<div style=\"font-size:13px;color:rgba(255,255,255,0.6);margin-bottom:3px\">\ud83d\udcde ${g('f-broker-phone')}<\/div>`:''}\n        ${g('f-broker-email')?`<div style=\"font-size:13px;color:rgba(255,255,255,0.6);margin-bottom:3px\">\u2709\ufe0f ${g('f-broker-email')}<\/div>`:''}\n        ${g('f-broker-website')?`<div style=\"font-size:13px;color:rgba(255,255,255,0.6);margin-bottom:12px\">\ud83c\udf10 ${g('f-broker-website')}<\/div>`:''}\n        ${g('f-broker-bio')?`<div style=\"font-size:13px;color:rgba(255,255,255,0.7);line-height:1.7\">${g('f-broker-bio')}<\/div>`:''}\n        ${badgeHtml}\n      <\/div>\n    <\/div>\n  <\/div>`:'';\n\n  \/\/ Info rows helper\n  function infoRow(items) {\n    const filled=items.filter(([,v])=>v);\n    if(!filled.length) return '';\n    return `<div style=\"background:#f8f6f0;padding:12px 16px;border-radius:6px;margin-bottom:14px;font-size:13px\">${filled.map(([k,v])=>`<strong>${k}:<\/strong> ${v}`).join(' &nbsp;\u00b7&nbsp; ')}<\/div>`;\n  }\n\n  return `<div style=\"font-family:'Lato',sans-serif;max-width:900px;margin:0 auto;background:white;box-shadow:0 0 40px rgba(0,0,0,0.2);border-radius:4px;overflow:hidden\">\n\n<!-- COVER -->\n<div class=\"pgb\" style=\"background:${tc.bg};min-height:1050px;display:flex;flex-direction:column;position:relative;overflow:hidden\">\n  <div style=\"position:absolute;top:0;left:0;right:0;height:5px;background:linear-gradient(90deg,${tc.ac},rgba(255,255,255,0.4),${tc.ac})\"><\/div>\n  <div style=\"flex:1;display:flex;flex-direction:column;justify-content:center;padding:70px 65px\">\n    <div style=\"display:flex;align-items:center;justify-content:space-between;margin-bottom:50px\">${brokerLogoHtml}${bizLogoHtml}<\/div>\n    <div style=\"font-size:10px;letter-spacing:3px;text-transform:uppercase;color:${tc.ac};border:1px solid rgba(201,168,76,0.3);padding:5px 14px;border-radius:3px;display:inline-block;margin-bottom:28px;width:fit-content\">Confidential Information Memorandum<\/div>\n    <div style=\"font-family:${tc.tf};font-size:50px;line-height:1.1;color:white;letter-spacing:1px;margin-bottom:14px\">${bn}<\/div>\n    ${bt?`<div style=\"font-size:17px;color:${tc.sb};margin-bottom:36px;font-weight:300\">${bt}<\/div>`:''}\n    <div style=\"width:60px;height:2px;background:${tc.ac};margin-bottom:28px\"><\/div>\n    ${coverMeta}\n    <div style=\"font-size:11px;color:${tc.sb}\">Presented exclusively by ${bk}${brn?' | '+brn:''}<\/div>\n  <\/div>\n  <div style=\"padding:24px 65px;border-top:1px solid rgba(255,255,255,0.1);display:flex;align-items:center;justify-content:space-between\">\n    <div style=\"font-size:10px;text-transform:uppercase;letter-spacing:2px;color:${tc.sb}\">Strictly Confidential<\/div>\n    <div style=\"font-size:10px;color:${tc.sb}\">\u00a9 ${new Date().getFullYear()} ${bk}<\/div>\n  <\/div>\n<\/div>\n\n${coverPhotoHtml}\n${brokerBio}\n${sec('','Executive Summary',tp(g('f-exec')))}\n${(g('f-biz-desc')||g('f-biz-history'))?sec('The Opportunity','Business Overview',[tp(g('f-biz-desc')),g('f-biz-history')?`<div style=\"margin-top:16px\">${tp(g('f-biz-history'))}<\/div>`:'',infoRow([['Legal',g('f-legal')],['Ownership',g('f-ownership')],['Hours',g('f-hours')]]),g('f-customers')?`<div style=\"margin-top:14px\"><strong>Customer Demographics:<\/strong><br\/>${g('f-customers')}<\/div>`:''  ].filter(Boolean).join('')):''}\n${g('f-highlights')?sec('Why Buy','Investment Highlights',tb(g('f-highlights'))):''}\n${gallery}\n${(g('f-loc-desc')||g('f-demand'))?sec('Market','Location & Market Overview',[lc?`<div style=\"font-size:13px;background:#f8f6f0;padding:10px 14px;border-radius:6px;margin-bottom:14px\"><strong>Area:<\/strong> ${lc}<\/div>`:'',tp(g('f-loc-desc')),g('f-demand')?`<div style=\"margin-top:14px\"><strong>Nearby Demand Drivers:<\/strong><br\/>${tp(g('f-demand'))}<\/div>`:''  ].filter(Boolean).join('')):''}\n${(g('f-products')||g('f-rev-mix'))?sec('Offerings','Products & Services',[tp(g('f-products')),g('f-rev-mix')?`<div style=\"margin-top:14px;background:#f8f6f0;border-left:4px solid ${tc.ac};padding:14px 18px;border-radius:0 6px 6px 0\"><strong>Revenue Mix:<\/strong> ${g('f-rev-mix')}<\/div>`:''  ].filter(Boolean).join('')):''}\n${(g('f-ops')||g('f-employees'))?sec('How It Runs','Operations & Staff',[infoRow([['Team',g('f-employees')],['Owner Role',g('f-owner-role')],['Key Staff',g('f-mgmt')]]),tp(g('f-ops')),g('f-staff')?`<div style=\"margin-top:14px\">${tp(g('f-staff'))}<\/div>`:''  ].filter(Boolean).join('')):''}\n${(g('f-facilities')||g('f-sqft')||g('f-rent'))?sec('The Space','Facilities & Lease',[infoRow([['Size',g('f-sqft')],['Monthly Rent',g('f-rent')],['Lease Exp.',g('f-lease-exp')]]),tp(g('f-facilities'))].filter(Boolean).join('')):''}\n${finBody?sec('Performance','Financial Summary & Recasted Earnings',finBody):''}\n${(g('f-competition')||g('f-industry')||g('f-reviews'))?sec('The Market','Competition & Industry Analysis',[g('f-competition')?`<h3 style=\"font-size:16px;font-weight:700;margin-bottom:10px;color:#111\">Competitive Landscape<\/h3>${tp(g('f-competition'))}`:'',g('f-industry')?`<h3 style=\"font-size:16px;font-weight:700;margin:20px 0 10px;color:#111\">Industry Analysis<\/h3>${tp(g('f-industry'))}`:'',g('f-reviews')?`<h3 style=\"font-size:16px;font-weight:700;margin:20px 0 10px;color:#111\">Public Reputation<\/h3>${tp(g('f-reviews'))}`:''].filter(Boolean).join('')):''}\n${g('f-growth')?sec('The Upside','Growth Opportunities',tb(g('f-growth'))):''}\n${(g('f-reason')||g('f-transition'))?sec('Next Steps','Reason for Sale & Transition',[g('f-reason')?`<div style=\"margin-bottom:16px\"><strong>Reason for Sale:<\/strong><br\/>${tp(g('f-reason'))}<\/div>`:'',g('f-transition')?`<div><strong>Transition Support:<\/strong><br\/>${tp(g('f-transition'))}<\/div>`:''  ].filter(Boolean).join('')):''}\n${(assetTable||g('f-asset-notes'))?sec('Included Assets','Asset List',[assetTable,g('f-asset-notes')?tp(g('f-asset-notes')):''  ].filter(Boolean).join('')):''}\n${g('f-disclaimer')?`<div style=\"padding:44px 60px;background:white\"><div style=\"font-family:${tc.tf};font-size:24px;font-weight:700;color:#111;margin-bottom:16px;padding-bottom:10px;border-bottom:2px solid ${t===1?'#111':tc.ac}\">Confidentiality Disclaimer<\/div><div style=\"background:#f8f6f0;border:1px solid #e8dfc0;border-radius:6px;padding:20px;font-size:11px;color:#555;line-height:1.8\">${tp(g('f-disclaimer'))}<\/div>${g('f-appendix')?`<div style=\"margin-top:14px;font-size:13px;color:#555\">${tp(g('f-appendix'))}<\/div>`:''}<\/div>`:''}\n\n<!-- DOC FOOTER -->\n<div style=\"background:${tc.bg};padding:20px 60px;display:flex;justify-content:space-between;align-items:center\">\n  <div style=\"font-size:10px;color:${tc.sb};text-transform:uppercase;letter-spacing:2px\">${bk} \u00b7 Strictly Confidential<\/div>\n  <div style=\"font-size:10px;color:${tc.sb}\">Generated ${new Date().toLocaleDateString('en-US',{month:'long',day:'numeric',year:'numeric'})}<\/div>\n<\/div>\n\n<\/div>`;\n}\n\n\n\/\/ \u2500\u2500 INTAKE FORM DOWNLOAD \u2500\u2500\nfunction downloadIntakeForm(lang) {\n  const isES = lang === 'es';\n  const L = {\n    title:        isES ? 'Formulario de Listado \u2014 Cuestionario del Vendedor' : 'Business Listing Intake Form \u2014 Seller Questionnaire',\n    confidential: isES ? 'CONFIDENCIAL' : 'CONFIDENTIAL',\n    tagline:      isES ? 'Complete este formulario y devu\u00e9lvalo a su corredor. Toda informaci\u00f3n ser\u00e1 mantenida estrictamente confidencial.' : 'Please complete this form and return it to your broker. All information will be kept strictly confidential.',\n    broker_label: isES ? 'Corredor Asignado' : 'Assigned Broker',\n    date_label:   isES ? 'Fecha' : 'Date',\n    s1: isES ? 'SECCI\u00d3N 1 \u2014 INFORMACI\u00d3N GENERAL DEL NEGOCIO' : 'SECTION 1 \u2014 GENERAL BUSINESS INFORMATION',\n    s2: isES ? 'SECCI\u00d3N 2 \u2014 FINANZAS' : 'SECTION 2 \u2014 FINANCIALS',\n    s3: isES ? 'SECCI\u00d3N 3 \u2014 OPERACIONES Y PERSONAL' : 'SECTION 3 \u2014 OPERATIONS & STAFF',\n    s4: isES ? 'SECCI\u00d3N 4 \u2014 INSTALACIONES Y ARRENDAMIENTO' : 'SECTION 4 \u2014 FACILITIES & LEASE',\n    s5: isES ? 'SECCI\u00d3N 5 \u2014 PRODUCTOS Y SERVICIOS' : 'SECTION 5 \u2014 PRODUCTS & SERVICES',\n    s6: isES ? 'SECCI\u00d3N 6 \u2014 ACTIVOS INCLUIDOS EN LA VENTA' : 'SECTION 6 \u2014 ASSETS INCLUDED IN SALE',\n    s7: isES ? 'SECCI\u00d3N 7 \u2014 RAZ\u00d3N DE VENTA Y TRANSICI\u00d3N' : 'SECTION 7 \u2014 REASON FOR SALE & TRANSITION',\n    s8: isES ? 'SECCI\u00d3N 8 \u2014 INFORMACI\u00d3N ADICIONAL' : 'SECTION 8 \u2014 ADDITIONAL INFORMATION',\n    disclaimer: isES\n      ? 'Este formulario es estrictamente confidencial y est\u00e1 destinado \u00fanicamente para uso interno de 360 Biz Brokers. La informaci\u00f3n proporcionada se utilizar\u00e1 exclusivamente para la preparaci\u00f3n del Memorando de Informaci\u00f3n Confidencial (CIM).'\n      : 'This form is strictly confidential and intended solely for internal use by 360 Biz Brokers. Information provided will be used exclusively for preparation of the Confidential Information Memorandum (CIM).',\n    fields: isES ? {\n      biz_name: 'Nombre Legal del Negocio', dba: 'Nombre Comercial (DBA)', biz_type: 'Tipo de Negocio \/ Industria',\n      founded: 'A\u00f1o de Fundaci\u00f3n', years: 'A\u00f1os en Operaci\u00f3n', address: 'Direcci\u00f3n Completa',\n      city_state: 'Ciudad, Estado, C\u00f3digo Postal', phone: 'Tel\u00e9fono del Negocio', website: 'Sitio Web',\n      legal_structure: 'Estructura Legal (LLC, Corp, etc.)', ein: 'EIN \/ N\u00famero de Identificaci\u00f3n Fiscal',\n      owner_name: 'Nombre del Propietario', owner_phone: 'Tel\u00e9fono del Propietario', owner_email: 'Correo del Propietario',\n      asking_price: 'Precio Pedido', price_rationale: 'Justificaci\u00f3n del Precio',\n      rev_yr1: 'Ingresos Brutos \u2014 A\u00f1o 1 ($)', rev_yr2: 'Ingresos Brutos \u2014 A\u00f1o 2 ($)', rev_yr3: 'Ingresos Brutos \u2014 A\u00f1o 3 \/ M\u00e1s Reciente ($)',\n      cogs_yr3: 'Costo de Ventas \u2014 A\u00f1o 3 ($)', opex_yr3: 'Gastos Operativos Totales \u2014 A\u00f1o 3 ($)',\n      owner_salary: 'Salario del Propietario Incluido en Gastos ($)', sde: 'SDE \/ Beneficio Neto del Propietario ($)',\n      addbacks: 'Gastos Adicionales (add-backs) y Gastos Personales', taxes_current: '\u00bfImpuestos al D\u00eda?',\n      employees_ft: 'Empleados de Tiempo Completo', employees_pt: 'Empleados de Tiempo Parcial',\n      owner_hours: 'Horas del Propietario por Semana', owner_role: 'Rol del Propietario en el Negocio',\n      key_staff: 'Personal Clave y Sus Roles', staff_staying: '\u00bfEl Personal Clave Continuar\u00e1?',\n      systems: 'Sistemas \/ Software \/ POS Utilizados', suppliers: 'Proveedores Principales',\n      sqft: 'Metros Cuadrados del Local', rent: 'Renta Mensual ($)', lease_exp: 'Vencimiento del Arrendamiento',\n      lease_options: 'Opciones de Renovaci\u00f3n del Arrendamiento', parking: 'Estacionamiento Disponible',\n      landlord: 'Relaci\u00f3n con el Arrendador', real_estate: '\u00bfSe Incluye Bienes Ra\u00edces?',\n      products_desc: 'Descripci\u00f3n de Productos y\/o Servicios', revenue_mix: 'Mezcla de Ingresos (% por l\u00ednea de producto\/servicio)',\n      customers: 'Perfil del Cliente Principal', contracts: 'Contratos o Clientes Recurrentes',\n      ffe_desc: 'Describa el FF&E Incluido (muebles, equipos, accesorios)',\n      inventory: 'Valor Estimado del Inventario ($)', vehicles: 'Veh\u00edculos Incluidos',\n      ip: 'Propiedad Intelectual (marcas, patentes, dominio web)',\n      reason: 'Raz\u00f3n para Vender', timeline: 'L\u00ednea de Tiempo Deseada para Cerrar',\n      training: 'Capacitaci\u00f3n \/ Soporte de Transici\u00f3n Ofrecido', seller_financing: '\u00bfConsidera Financiamiento del Vendedor?',\n      competition: 'Principales Competidores', advantages: 'Ventajas Competitivas',\n      growth: 'Oportunidades de Crecimiento', risks: 'Riesgos o Desaf\u00edos a Revelar',\n      pending_legal: 'Litigios Pendientes o Problemas Legales', licenses: 'Licencias y Permisos Requeridos',\n      other: 'Informaci\u00f3n Adicional que el Comprador Debe Conocer'\n    } : {\n      biz_name: 'Legal Business Name', dba: 'Trade Name \/ DBA', biz_type: 'Business Type \/ Industry',\n      founded: 'Year Founded', years: 'Years in Operation', address: 'Full Business Address',\n      city_state: 'City, State, Zip Code', phone: 'Business Phone', website: 'Website',\n      legal_structure: 'Legal Structure (LLC, Corp, etc.)', ein: 'EIN \/ Federal Tax ID',\n      owner_name: 'Owner Full Name', owner_phone: 'Owner Phone', owner_email: 'Owner Email',\n      asking_price: 'Asking Price', price_rationale: 'Basis for Asking Price',\n      rev_yr1: 'Gross Revenue \u2014 Year 1 ($)', rev_yr2: 'Gross Revenue \u2014 Year 2 ($)', rev_yr3: 'Gross Revenue \u2014 Year 3 \/ Most Recent ($)',\n      cogs_yr3: 'Cost of Goods Sold \u2014 Year 3 ($)', opex_yr3: 'Total Operating Expenses \u2014 Year 3 ($)',\n      owner_salary: 'Owner Salary Included in Expenses ($)', sde: 'SDE \/ Net Owner Benefit ($)',\n      addbacks: 'Add-Back Items & Personal Expenses Run Through Business', taxes_current: 'Are Business Taxes Current?',\n      employees_ft: 'Full-Time Employees', employees_pt: 'Part-Time Employees',\n      owner_hours: 'Owner Hours Per Week', owner_role: 'Owner\\'s Role in the Business',\n      key_staff: 'Key Staff Members & Their Roles', staff_staying: 'Will Key Staff Stay Post-Sale?',\n      systems: 'Systems \/ Software \/ POS Used', suppliers: 'Major Suppliers \/ Vendors',\n      sqft: 'Total Square Footage', rent: 'Monthly Rent ($)', lease_exp: 'Lease Expiration Date',\n      lease_options: 'Lease Renewal Options', parking: 'Parking Available',\n      landlord: 'Landlord Relationship', real_estate: 'Is Real Estate Included in Sale?',\n      products_desc: 'Description of Products and\/or Services Offered', revenue_mix: 'Revenue Mix (% breakdown by product\/service line)',\n      customers: 'Primary Customer Profile \/ Demographics', contracts: 'Recurring Contracts or Key Accounts',\n      ffe_desc: 'Describe FF&E Included (furniture, fixtures, equipment)',\n      inventory: 'Estimated Inventory Value at Time of Sale ($)', vehicles: 'Vehicles Included',\n      ip: 'Intellectual Property (trademarks, patents, website domain)',\n      reason: 'Reason for Selling', timeline: 'Desired Closing Timeline',\n      training: 'Training \/ Transition Support Offered', seller_financing: 'Open to Seller Financing?',\n      competition: 'Primary Competitors', advantages: 'Key Competitive Advantages',\n      growth: 'Untapped Growth Opportunities', risks: 'Known Risks or Challenges to Disclose',\n      pending_legal: 'Pending Litigation or Legal Issues', licenses: 'Licenses & Permits Required to Operate',\n      other: 'Any Other Information a Buyer Should Know'\n    }\n  };\n\n  const F = L.fields;\n\n  function row(label, lines=1, hint='') {\n    const h = lines === 1\n      ? `<div style=\"border-bottom:1.5px solid #222;margin-top:20px;min-height:22px\"><\/div>`\n      : `<div style=\"border:1.5px solid #222;margin-top:12px;min-height:${lines*26}px;border-radius:3px\"><\/div>`;\n    return `<div style=\"margin-bottom:${lines>1?'4':'0'}px\">\n      <div style=\"font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:0.5px;color:#444;margin-top:${lines>1?'16':'12'}px\">${label}${hint?`<span style=\"font-weight:400;color:#888;text-transform:none;letter-spacing:0\"> \u2014 ${hint}<\/span>`:''}<\/div>\n      ${h}\n    <\/div>`;\n  }\n\n  function section(num, title, body) {\n    return `<div style=\"page-break-inside:avoid;margin-bottom:28px\">\n      <div style=\"background:#111;color:#C9A84C;padding:8px 14px;font-size:11px;font-weight:700;letter-spacing:2px;text-transform:uppercase;border-radius:4px 4px 0 0;margin-bottom:0\">${title}<\/div>\n      <div style=\"border:1.5px solid #111;border-top:none;padding:14px 16px;border-radius:0 0 4px 4px\">${body}<\/div>\n    <\/div>`;\n  }\n\n  function twoCol(f1, f2, lines=1) {\n    return `<div style=\"display:grid;grid-template-columns:1fr 1fr;gap:16px\">${row(f1,lines)}${row(f2,lines)}<\/div>`;\n  }\n  function threeCol(f1, f2, f3) {\n    return `<div style=\"display:grid;grid-template-columns:1fr 1fr 1fr;gap:12px\">${row(f1)}${row(f2)}${row(f3)}<\/div>`;\n  }\n\n  const html = `<!DOCTYPE html>\n<html lang=\"${isES?'es':'en'}\">\n<head>\n<meta charset=\"UTF-8\">\n<title>${L.title} \u2014 360 Biz Brokers<\/title>\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Anton&family=Lato:wght@300;400;700;900&display=swap\" rel=\"stylesheet\">\n<style>\n  *{box-sizing:border-box;margin:0;padding:0}\n  body{font-family:'Lato',sans-serif;background:white;color:#111;font-size:13px;line-height:1.5;padding:0}\n  .page{max-width:800px;margin:0 auto;padding:36px 40px 40px}\n  @media print{\n    body{padding:0}\n    .page{max-width:100%;padding:24px 32px}\n    .no-print{display:none!important}\n    @page{margin:0.6in 0.6in 0.7in;size:letter}\n  }\n<\/style>\n<\/head>\n<body>\n<div class=\"page\">\n\n<!-- PRINT BUTTON -->\n<div class=\"no-print\" style=\"background:#111;padding:12px 20px;border-radius:8px;display:flex;align-items:center;justify-content:space-between;margin-bottom:24px\">\n  <span style=\"color:#C9A84C;font-size:13px;font-weight:700\">360 Biz Brokers \u2014 Listing Intake Form Preview<\/span>\n  <button onclick=\"window.print()\" style=\"background:#C9A84C;color:#111;border:none;padding:9px 20px;border-radius:6px;font-weight:700;font-size:13px;cursor:pointer\">\ud83d\udda8 Print \/ Save as PDF<\/button>\n<\/div>\n\n<!-- HEADER -->\n<div style=\"border-bottom:3px solid #111;padding-bottom:18px;margin-bottom:22px\">\n  <div style=\"display:flex;align-items:flex-start;justify-content:space-between\">\n    <div>\n      <div style=\"font-family:'Anton',sans-serif;font-size:22px;color:#111;letter-spacing:1px\">360 BIZ BROKERS<\/div>\n      <div style=\"font-size:10px;text-transform:uppercase;letter-spacing:3px;color:#888;margin-top:2px\">360bizbrokers.com \u00b7 (954) 325-2625 \u00b7 val@360bizbrokers.com<\/div>\n    <\/div>\n    <div style=\"text-align:right\">\n      <div style=\"font-size:9px;text-transform:uppercase;letter-spacing:2px;color:#C9A84C;border:1px solid #C9A84C;padding:3px 10px;border-radius:3px;display:inline-block\">${L.confidential}<\/div>\n    <\/div>\n  <\/div>\n  <div style=\"margin-top:14px\">\n    <div style=\"font-size:19px;font-weight:900;color:#111\">${L.title}<\/div>\n    <div style=\"font-size:12px;color:#555;margin-top:4px;max-width:600px\">${L.tagline}<\/div>\n  <\/div>\n  <div style=\"display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-top:16px\">\n    <div><div style=\"font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.5px;color:#888\">${L.broker_label}<\/div><div style=\"border-bottom:1.5px solid #111;min-height:22px;margin-top:6px\"><\/div><\/div>\n    <div><div style=\"font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.5px;color:#888\">${L.date_label}<\/div><div style=\"border-bottom:1.5px solid #111;min-height:22px;margin-top:6px\"><\/div><\/div>\n  <\/div>\n<\/div>\n\n${section(1, L.s1, `\n  ${twoCol(F.biz_name, F.dba)}\n  ${twoCol(F.biz_type, F.legal_structure)}\n  ${threeCol(F.founded, F.years, F.ein)}\n  ${row(F.address)}\n  ${twoCol(F.city_state, F.phone)}\n  ${twoCol(F.website, '')}\n  <div style=\"margin-top:16px;border-top:1px dashed #ddd;padding-top:12px\">\n  ${threeCol(F.owner_name, F.owner_phone, F.owner_email)}\n  ${twoCol(F.asking_price, F.price_rationale)}\n  <\/div>\n`)}\n\n${section(2, L.s2, `\n  ${threeCol(F.rev_yr1, F.rev_yr2, F.rev_yr3)}\n  ${threeCol(F.cogs_yr3, F.opex_yr3, F.owner_salary)}\n  ${twoCol(F.sde, F.taxes_current)}\n  ${row(F.addbacks, 3, isES?'Describa cada partida y monto':'Describe each item and amount')}\n`)}\n\n${section(3, L.s3, `\n  ${threeCol(F.employees_ft, F.employees_pt, F.owner_hours)}\n  ${row(F.owner_role, 2)}\n  ${row(F.key_staff, 3, isES?'Nombre, cargo, salario, a\u00f1os en la empresa':'Name, title, salary, years with company')}\n  ${twoCol(F.staff_staying, F.systems)}\n  ${row(F.suppliers, 2)}\n`)}\n\n${section(4, L.s4, `\n  ${threeCol(F.sqft, F.rent, F.lease_exp)}\n  ${twoCol(F.lease_options, F.parking)}\n  ${twoCol(F.landlord, F.real_estate)}\n`)}\n\n${section(5, L.s5, `\n  ${row(F.products_desc, 4)}\n  ${row(F.revenue_mix, 2, isES?'ej. 60% comidas, 25% catering':'e.g. 60% dine-in, 25% catering')}\n  ${row(F.customers, 2)}\n  ${row(F.contracts, 2)}\n`)}\n\n${section(6, L.s6, `\n  ${row(F.ffe_desc, 4, isES?'Liste los equipos m\u00e1s importantes y su estado':'List major equipment items and condition')}\n  ${threeCol(F.inventory, F.vehicles, F.ip)}\n`)}\n\n${section(7, L.s7, `\n  ${row(F.reason, 3)}\n  ${twoCol(F.timeline, F.seller_financing)}\n  ${row(F.training, 3)}\n`)}\n\n${section(8, L.s8, `\n  ${row(F.competition, 2)}\n  ${row(F.advantages, 2)}\n  ${row(F.growth, 3)}\n  ${row(F.risks, 2)}\n  ${twoCol(F.pending_legal, F.licenses)}\n  ${row(F.other, 3)}\n`)}\n\n<!-- SIGNATURE BLOCK -->\n<div style=\"margin-top:28px;border-top:2px solid #111;padding-top:18px;display:grid;grid-template-columns:1fr 1fr;gap:32px\">\n  <div>\n    <div style=\"font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.5px;color:#444;margin-bottom:8px\">${isES?'Firma del Propietario':'Owner Signature'}<\/div>\n    <div style=\"border-bottom:1.5px solid #111;min-height:40px;margin-bottom:6px\"><\/div>\n    <div style=\"border-bottom:1.5px solid #111;min-height:22px;margin-top:12px\"><\/div>\n    <div style=\"font-size:10px;color:#888;margin-top:3px\">${isES?'Nombre impreso y fecha':'Printed name and date'}<\/div>\n  <\/div>\n  <div>\n    <div style=\"font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.5px;color:#444;margin-bottom:8px\">${isES?'Firma del Corredor':'Broker Signature'}<\/div>\n    <div style=\"border-bottom:1.5px solid #111;min-height:40px;margin-bottom:6px\"><\/div>\n    <div style=\"border-bottom:1.5px solid #111;min-height:22px;margin-top:12px\"><\/div>\n    <div style=\"font-size:10px;color:#888;margin-top:3px\">${isES?'Nombre impreso y fecha':'Printed name and date'}<\/div>\n  <\/div>\n<\/div>\n\n<!-- FOOTER -->\n<div style=\"margin-top:20px;padding-top:14px;border-top:1px solid #eee;display:flex;justify-content:space-between;align-items:center\">\n  <div style=\"font-size:10px;color:#aaa\">360 Biz Brokers \u2014 A DBA of Florida 360 Realty, LLC \u00b7 ${isES?'Todos los derechos reservados':'All rights reserved'} \u00a9 ${new Date().getFullYear()}<\/div>\n  <div style=\"font-size:9px;color:#ccc;text-transform:uppercase;letter-spacing:1px\">${L.confidential}<\/div>\n<\/div>\n\n<div style=\"margin-top:12px;background:#f8f6f0;border:1px solid #e8dfc0;border-radius:5px;padding:10px 14px;font-size:10px;color:#555;line-height:1.7\">${L.disclaimer}<\/div>\n\n<\/div>\n<\/body>\n<\/html>`;\n\n  \/\/ Open in new window and trigger print\n  const win = window.open('', '_blank');\n  win.document.write(html);\n  win.document.close();\n  \/\/ Small delay so fonts load before print dialog\n  win.onload = () => setTimeout(() => win.focus(), 400);\n}\n\n\/\/ \u2500\u2500 INTAKE EXTRACTION \u2500\u2500\nlet intakeFileData = null;\nlet intakeFileType = null;\nlet intakeFileName = null;\n\nfunction handleIntakeUpload(input) {\n  const file = input.files[0];\n  if (!file) return;\n  intakeFileName = file.name;\n  const sizeMB = (file.size \/ 1024 \/ 1024).toFixed(1);\n\n  \/\/ Show preview bar\n  document.getElementById('intake-preview-bar').style.display = 'flex';\n  document.getElementById('intake-filename').textContent = file.name;\n  document.getElementById('intake-filesize').textContent = sizeMB + ' MB \u00b7 ' + (file.type || 'document');\n\n  \/\/ Detect file type\n  const ext = file.name.split('.').pop().toLowerCase();\n  const isImage = file.type.startsWith('image\/');\n  const mimeMap = {\n    pdf: 'application\/pdf',\n    docx: 'application\/vnd.openxmlformats-officedocument.wordprocessingml.document',\n    doc: 'application\/msword',\n    txt: 'text\/plain',\n    csv: 'text\/csv'\n  };\n  intakeFileType = isImage ? file.type : (file.type || mimeMap[ext] || 'application\/octet-stream');\n\n  const reader = new FileReader();\n  reader.onload = (e) => {\n    intakeFileData = e.target.result.split(',')[1];\n  };\n  reader.readAsDataURL(file);\n\n  \/\/ Style the drop zone\n  const dz = document.getElementById('intake-drop-zone');\n  dz.style.borderColor = 'var(--gold)';\n  dz.style.background = 'rgba(201,168,76,0.06)';\n}\n\nfunction clearIntake() {\n  intakeFileData = null; intakeFileType = null; intakeFileName = null;\n  document.getElementById('intake-file-input').value = '';\n  document.getElementById('intake-preview-bar').style.display = 'none';\n  document.getElementById('intake-status').style.display = 'none';\n  const dz = document.getElementById('intake-drop-zone');\n  dz.style.borderColor = 'var(--gold-light)';\n  dz.style.background = 'rgba(201,168,76,0.04)';\n}\n\nasync function runIntakeExtraction() {\n  if (!intakeFileData) { toast('No file loaded','err'); return; }\n  const statusEl = document.getElementById('intake-status');\n  statusEl.style.display = 'block';\n  statusEl.innerHTML = '<div class=\"smsg info\" style=\"display:flex;align-items:center;gap:10px\"><div style=\"width:14px;height:14px;border:2px solid #bbb;border-top-color:#1d4ed8;border-radius:50%;animation:spin 0.8s linear infinite;flex-shrink:0\"><\/div><span>AI is reading your intake document and extracting data\u2026 this may take 15\u201330 seconds.<\/span><\/div>';\n\n  const systemPrompt = `You are an expert business broker assistant. You will be given a listing intake form, seller questionnaire, or business document. Extract all available information and return it as a single valid JSON object with these exact keys (use empty string \"\" if not found):\n\n{\n  \"f-biz-name\": \"\",\n  \"f-biz-type\": \"\",\n  \"f-asking-price\": \"\",\n  \"f-revenue\": \"\",\n  \"f-sde\": \"\",\n  \"f-location\": \"\",\n  \"f-years\": \"\",\n  \"f-brokerage\": \"\",\n  \"f-broker-name\": \"\",\n  \"f-broker-fullname\": \"\",\n  \"f-broker-title\": \"\",\n  \"f-broker-phone\": \"\",\n  \"f-broker-email\": \"\",\n  \"f-broker-website\": \"\",\n  \"f-broker-bio\": \"\",\n  \"f-exec\": \"\",\n  \"f-biz-desc\": \"\",\n  \"f-biz-history\": \"\",\n  \"f-legal\": \"\",\n  \"f-ownership\": \"\",\n  \"f-hours\": \"\",\n  \"f-customers\": \"\",\n  \"f-advantages\": \"\",\n  \"f-address\": \"\",\n  \"f-neighborhood\": \"\",\n  \"f-loc-desc\": \"\",\n  \"f-demand\": \"\",\n  \"f-products\": \"\",\n  \"f-rev-mix\": \"\",\n  \"f-employees\": \"\",\n  \"f-owner-role\": \"\",\n  \"f-ops\": \"\",\n  \"f-staff\": \"\",\n  \"f-sqft\": \"\",\n  \"f-rent\": \"\",\n  \"f-lease-exp\": \"\",\n  \"f-facilities\": \"\",\n  \"f-rev1\": \"\",\n  \"f-rev2\": \"\",\n  \"f-rev3\": \"\",\n  \"f-cogs1\": \"\",\n  \"f-cogs2\": \"\",\n  \"f-cogs3\": \"\",\n  \"f-gp1\": \"\",\n  \"f-gp2\": \"\",\n  \"f-gp3\": \"\",\n  \"f-opex1\": \"\",\n  \"f-opex2\": \"\",\n  \"f-opex3\": \"\",\n  \"f-sde1\": \"\",\n  \"f-sde2\": \"\",\n  \"f-sde3\": \"\",\n  \"f-recast\": \"\",\n  \"f-valuation\": \"\",\n  \"f-deal\": \"\",\n  \"f-competition\": \"\",\n  \"f-industry\": \"\",\n  \"f-growth\": \"\",\n  \"f-reason\": \"\",\n  \"f-transition\": \"\",\n  \"f-asset-notes\": \"\",\n  \"f-highlights\": \"\",\n  \"f-appendix\": \"\"\n}\n\nRules:\n- Return ONLY the raw JSON object. No markdown, no backticks, no explanation.\n- For financial fields (f-rev1\/2\/3, f-sde1\/2\/3, etc.) use the most recently labeled years available.\n- For f-highlights and f-growth, format as one item per line.\n- For f-legal, use one of: LLC, S-Corp, C-Corp, Sole Proprietorship, Partnership \u2014 or leave blank.\n- For f-ownership, use one of: Single Owner, Partnership, Family-Owned, Absentee-Owned \u2014 or leave blank.\n- For f-mgmt, use one of: Yes all key staff staying, Most key staff staying, Varies, Unknown \u2014 or leave blank.\n- Be comprehensive \u2014 extract every piece of information available in the document.`;\n\n  try {\n    \/\/ Determine media type and build message content\n    let msgContent;\n    if (intakeFileType && intakeFileType.startsWith('image\/')) {\n      msgContent = [\n        { type: 'image', source: { type: 'base64', media_type: intakeFileType, data: intakeFileData } },\n        { type: 'text', text: 'Extract all business listing information from this intake form image and return as JSON.' }\n      ];\n    } else {\n      msgContent = [\n        { type: 'document', source: { type: 'base64', media_type: intakeFileType || 'application\/octet-stream', filename: intakeFileName || 'uploaded-document', data: intakeFileData } },\n        { type: 'text', text: 'Extract all business listing information from this uploaded document and return as JSON.' }\n      ];\n    }\n\n    const payload = {\n      model: AI_MODEL,\n      max_tokens: 2000,\n      system: systemPrompt,\n      messages: [{ role: 'user', content: msgContent }]\n    };\n\n    const data = await callProxyAI(payload);\n    const rawText = parseProxyResponse(data);\n    const extracted = extractJsonObject(rawText);\n\n    \/\/ Count fields populated\n    let filled = 0;\n    Object.entries(extracted).forEach(([k, v]) => {\n      if (v && v.toString().trim()) {\n        const el = document.getElementById(k);\n        if (el) { el.value = v; filled++; }\n      }\n    });\n\n    updateTopbar();\n    updateProgress();\n    saveData();\n\n    statusEl.innerHTML = `<div class=\"smsg success\">\u2705 Extraction complete \u2014 <strong>${filled} fields populated<\/strong> from \"${intakeFileName}\". Review each section and use AI Assist to refine any content.<\/div>`;\n    toast(`\u2705 ${filled} fields auto-filled from intake!`);\n\n    \/\/ Highlight the drop zone\n    const dz = document.getElementById('intake-drop-zone');\n    dz.style.borderColor = '#16a34a';\n    dz.style.background = 'rgba(34,197,94,0.04)';\n\n  } catch(err) {\n    console.error('Intake extraction error:', err);\n    statusEl.innerHTML = `<div class=\"smsg error\">\u274c Extraction failed: ${err.message}<\/div>`;\n  }\n}\n\n\n\/\/ \u2500\u2500 FINANCIAL DOCUMENT EXTRACTION \u2500\u2500\nconst finDocs = { 1: null, 2: null, 3: null };\nconst finDocTypes = { 1: null, 2: null, 3: null };\nconst finDocNames = { 1: null, 2: null, 3: null };\n\nconst FIN_ICONS = {\n  pdf: '\ud83d\udcc4', docx: '\ud83d\udcdd', doc: '\ud83d\udcdd',\n  xlsx: '\ud83d\udcca', xls: '\ud83d\udcca', csv: '\ud83d\udcca',\n  jpg: '\ud83d\uddbc\ufe0f', jpeg: '\ud83d\uddbc\ufe0f', png: '\ud83d\uddbc\ufe0f', tiff: '\ud83d\uddbc\ufe0f', tif: '\ud83d\uddbc\ufe0f'\n};\n\nfunction handleFinDoc(input, yearNum) {\n  const file = input.files[0];\n  if (!file) return;\n  const ext = file.name.split('.').pop().toLowerCase();\n  finDocNames[yearNum] = file.name;\n\n  const zone = document.getElementById('fin-zone-' + yearNum);\n  const iconEl = document.getElementById('fin-icon-' + yearNum);\n  const labelEl = document.getElementById('fin-label-' + yearNum);\n  const nameEl = document.getElementById('fin-doc-name-' + yearNum);\n\n  zone.style.borderColor = 'var(--gold)';\n  zone.style.background = 'rgba(201,168,76,0.06)';\n  iconEl.textContent = FIN_ICONS[ext] || '\ud83d\udcc4';\n  labelEl.innerHTML = '<span style=\"font-weight:700;color:var(--black)\">' + file.name.substring(0,22) + (file.name.length>22?'\u2026':'') + '<\/span>';\n  nameEl.textContent = (file.size\/1024).toFixed(0) + ' KB';\n  nameEl.style.display = 'block';\n\n  const isWord = ext === 'docx' || ext === 'doc';\n  const isImg = file.type.startsWith('image\/');\n  finDocTypes[yearNum] = isWord ? 'docx' : (ext === 'pdf' ? 'application\/pdf' : (isImg ? file.type : (ext === 'csv' || ext === 'xlsx' || ext === 'xls' ? 'spreadsheet' : 'application\/pdf')));\n\n  const reader = new FileReader();\n  if (isWord || ext === 'xlsx' || ext === 'xls' || ext === 'csv') {\n    reader.onload = (e) => {\n      const bytes = new Uint8Array(e.target.result);\n      let bin = '';\n      bytes.forEach(b => bin += String.fromCharCode(b));\n      finDocs[yearNum] = btoa(bin);\n      updateFinImgPreviews();\n    };\n    reader.readAsArrayBuffer(file);\n  } else {\n    reader.onload = (e) => {\n      finDocs[yearNum] = e.target.result.split(',')[1];\n      finDocTypes[yearNum] = isImg ? file.type : 'application\/pdf';\n      updateFinImgPreviews();\n    };\n    reader.readAsDataURL(file);\n  }\n}\n\nfunction updateFinImgPreviews() {\n  const previewSection = document.getElementById('fin-img-previews');\n  const grid = document.getElementById('fin-img-grid');\n  const hasAny = Object.values(finDocNames).some(n => n);\n  if (!hasAny) { previewSection.style.display = 'none'; return; }\n\n  previewSection.style.display = 'block';\n  grid.innerHTML = '';\n\n  [1, 2, 3].forEach(yr => {\n    if (!finDocNames[yr]) return;\n    const ext = finDocNames[yr].split('.').pop().toLowerCase();\n    const isImg = ['jpg','jpeg','png','tiff','tif','gif','webp'].includes(ext);\n    const cell = document.createElement('div');\n    cell.style.cssText = 'border:1px solid var(--g200);border-radius:var(--r);overflow:hidden;background:var(--g50)';\n\n    if (isImg && finDocs[yr]) {\n      \/\/ Show actual image preview\n      cell.innerHTML = '<img decoding=\"async\" src=\"data:' + (finDocTypes[yr]||'image\/jpeg') + ';base64,' + finDocs[yr] + '\" style=\"width:100%;height:130px;object-fit:cover;display:block\" \/>'\n        + '<div style=\"padding:6px 8px;font-size:10px;color:var(--g600);font-weight:700\">Year ' + yr + ' \u2014 ' + finDocNames[yr].substring(0,20) + '<\/div>';\n    } else {\n      \/\/ Show a styled doc tile\n      const icon = FIN_ICONS[ext] || '\ud83d\udcc4';\n      cell.innerHTML = '<div style=\"height:130px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;background:' + (yr===3?'rgba(201,168,76,0.08)':'#f8f8f8') + '\">'\n        + '<div style=\"font-size:36px\">' + icon + '<\/div>'\n        + '<div style=\"font-size:10px;font-weight:700;color:var(--g800);text-align:center;padding:0 8px\">' + finDocNames[yr].substring(0,22) + (finDocNames[yr].length>22?'\u2026':'') + '<\/div>'\n        + '<\/div>'\n        + '<div style=\"padding:6px 8px;font-size:10px;color:var(--g600);font-weight:700;background:' + (yr===3?'rgba(201,168,76,0.15)':'white') + ';border-top:1px solid var(--g100)\">Year ' + yr + (yr===3?' (Latest)':'') + '<\/div>';\n    }\n    grid.appendChild(cell);\n  });\n}\n\nfunction clearFinDocs() {\n  [1,2,3].forEach(yr => {\n    finDocs[yr]=null; finDocTypes[yr]=null; finDocNames[yr]=null;\n    const inp = document.getElementById('fin-file-'+yr);\n    if (inp) inp.value='';\n    const zone = document.getElementById('fin-zone-'+yr);\n    if (zone) { zone.style.borderColor='var(--g200)'; zone.style.background='var(--g50)'; }\n    const icon = document.getElementById('fin-icon-'+yr);\n    if (icon) icon.textContent='\ud83d\udcc2';\n    const lbl = document.getElementById('fin-label-'+yr);\n    if (lbl) lbl.innerHTML = 'Tax Return \/ P&L<br\/>Year ' + yr + (yr===3?' \/ Latest':'');\n    const nm = document.getElementById('fin-doc-name-'+yr);\n    if (nm) nm.style.display='none';\n  });\n  document.getElementById('fin-img-previews').style.display='none';\n  document.getElementById('fin-extract-status').style.display='none';\n}\n\nasync function runFinExtraction() {\n  const hasAny = Object.values(finDocs).some(d => d);\n  if (!hasAny) { toast('Upload at least one financial document first','err'); return; }\n\n  const statusEl = document.getElementById('fin-extract-status');\n  statusEl.style.display='block';\n  statusEl.innerHTML='<div class=\"smsg info\" style=\"display:flex;align-items:center;gap:10px\"><div style=\"width:14px;height:14px;border:2px solid #bbb;border-top-color:#1d4ed8;border-radius:50%;animation:spin 0.8s linear infinite;flex-shrink:0\"><\/div><span>AI is reading your financial documents and extracting numbers\u2026 this may take 20\u201340 seconds.<\/span><\/div>';\n\n  const finSysPrompt = `You are an expert business broker and CPA assistant. You will be given one or more financial documents (tax returns, P&Ls, income statements, spreadsheets). Extract the key financial figures for each year and return ONLY a valid JSON object with these exact keys. Use empty string \"\" if not found. Format all dollar amounts with $ and commas (e.g. \"$485,000\").\n\n{\n  \"f-rev1\": \"\",\n  \"f-rev2\": \"\",\n  \"f-rev3\": \"\",\n  \"f-cogs1\": \"\",\n  \"f-cogs2\": \"\",\n  \"f-cogs3\": \"\",\n  \"f-gp1\": \"\",\n  \"f-gp2\": \"\",\n  \"f-gp3\": \"\",\n  \"f-opex1\": \"\",\n  \"f-opex2\": \"\",\n  \"f-opex3\": \"\",\n  \"f-sde1\": \"\",\n  \"f-sde2\": \"\",\n  \"f-sde3\": \"\",\n  \"f-recast\": \"\",\n  \"f-valuation\": \"\",\n  \"year1_label\": \"\",\n  \"year2_label\": \"\",\n  \"year3_label\": \"\"\n}\n\nRules:\n- year1_label\/year2_label\/year3_label should be the actual year (e.g. \"2022\", \"2023\", \"2024\").\n- f-rev = Gross Revenue \/ Total Sales \/ Total Income\n- f-cogs = Cost of Goods Sold \/ Cost of Sales \/ Direct Costs\n- f-gp = Gross Profit (Revenue minus COGS)\n- f-opex = Total Operating Expenses (excluding COGS)\n- f-sde = Seller's Discretionary Earnings \/ Net Income + owner compensation + depreciation + amortization + other add-backs\n- f-recast = Summarize any add-back items found (owner salary, personal expenses, depreciation, one-time items)\n- For multiple documents assign year numbers based on the document's tax year or date\n- Return ONLY raw JSON, no markdown, no explanation`;\n\n  try {\n    \/\/ Build message content with all uploaded docs\n    const msgContent = [];\n    const yearLabels = ['first','second','third'];\n\n    [1,2,3].forEach((yr, i) => {\n      if (!finDocs[yr]) return;\n      const ft = finDocTypes[yr] || 'application\/pdf';\n      const isImg = ft.startsWith('image\/');\n\n      if (isImg) {\n        msgContent.push({ type:'image', source:{ type:'base64', media_type:ft, data:finDocs[yr] } });\n      } else {\n        msgContent.push({ type:'document', source:{ type:'base64', media_type:ft || 'application\/octet-stream', filename:finDocNames[yr] || ('financial-year-' + yr), data:finDocs[yr] } });\n      }\n      msgContent.push({ type:'text', text:'The ' + yearLabels[i] + ' document above corresponds to Year ' + yr + '.' });\n    });\n\n    msgContent.push({ type:'text', text:'Extract all financial figures from these documents and return as JSON.' });\n\n    const payload = {\n      model:AI_MODEL, max_tokens:1500,\n      system:finSysPrompt,\n      messages:[{ role:'user', content:msgContent }]\n    };\n\n    const data = await callProxyAI(payload);\n    const rawText = parseProxyResponse(data);\n    const extracted = extractJsonObject(rawText);\n\n    const finFields = ['f-rev1','f-rev2','f-rev3','f-cogs1','f-cogs2','f-cogs3','f-gp1','f-gp2','f-gp3','f-opex1','f-opex2','f-opex3','f-sde1','f-sde2','f-sde3','f-recast','f-valuation'];\n    let filled = 0;\n    finFields.forEach(k => {\n      if (extracted[k] && extracted[k].trim()) {\n        const el = document.getElementById(k);\n        if (el) { el.value = extracted[k]; filled++; }\n      }\n    });\n\n    \/\/ Update year column headers if we got labels\n    const headers = document.querySelectorAll('#panel-s-financials table thead th');\n    if (headers.length >= 4) {\n      if (extracted.year1_label) headers[1].textContent = extracted.year1_label;\n      if (extracted.year2_label) headers[2].textContent = extracted.year2_label;\n      if (extracted.year3_label) headers[3].textContent = extracted.year3_label + ' (Latest)';\n    }\n\n    updateProgress();\n    saveData();\n\n    statusEl.innerHTML='<div class=\"smsg success\">\u2705 Extracted <strong>' + filled + ' financial values<\/strong> from ' + Object.values(finDocNames).filter(Boolean).length + ' document(s). Review the table above and adjust any figures as needed.<\/div>';\n    toast('\u2705 ' + filled + ' financial fields populated!');\n\n  } catch(err) {\n    console.error(err);\n    statusEl.innerHTML='<div class=\"smsg error\">\u274c Extraction failed: ' + err.message + '<\/div>';\n  }\n}\n\n\/\/ Drag-and-drop support for intake zone\ndocument.addEventListener('DOMContentLoaded', () => {\n  const dz = document.getElementById('intake-drop-zone');\n  if (!dz) return;\n  dz.addEventListener('dragover', e => { e.preventDefault(); dz.style.borderColor='var(--gold)'; dz.style.background='rgba(201,168,76,0.1)'; });\n  dz.addEventListener('dragleave', () => { dz.style.borderColor='var(--gold-light)'; dz.style.background='rgba(201,168,76,0.04)'; });\n  dz.addEventListener('drop', e => {\n    e.preventDefault();\n    const file = e.dataTransfer.files[0];\n    if (file) {\n      const inp = document.getElementById('intake-file-input');\n      \/\/ Create a DataTransfer to assign file\n      const dt = new DataTransfer(); dt.items.add(file); inp.files = dt.files;\n      handleIntakeUpload(inp);\n    }\n  });\n});\n\n\/\/ Spin animation for intake loader\nconst spinStyle = document.createElement('style');\nspinStyle.textContent = '@keyframes spin{to{transform:rotate(360deg)}}';\ndocument.head.appendChild(spinStyle);\n\n\/\/ INIT\ninitAiProxySettings();\nloadData();\nupdateProgress();\nsetInterval(saveData,120000);\n<\/script>\n<\/body>\n<\/html>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>CIM Generator OpenAI v4 | 360 Biz Brokers 360 BIZ BROKERS CIM Generator Setup \u229e Dashboard \u25c8 Template &amp; Design CIM Sections \u2460 Cover Page&#8230;<\/p>","protected":false},"author":3,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1342","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.5 (Yoast SEO v26.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CIM Generator V.2 - 360 Biz Brokers<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/360bizbrokers.com\/pt\/cim-generator-v-2\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CIM Generator V.2\" \/>\n<meta property=\"og:description\" content=\"CIM Generator OpenAI v4 | 360 Biz Brokers 360 BIZ BROKERS CIM Generator Setup \u229e Dashboard \u25c8 Template &amp; Design CIM Sections \u2460 Cover Page...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/360bizbrokers.com\/pt\/cim-generator-v-2\/\" \/>\n<meta property=\"og:site_name\" content=\"360 Biz Brokers\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-19T02:23:21+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. tempo de leitura\" \/>\n\t<meta name=\"twitter:data1\" content=\"27 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/360bizbrokers.com\/cim-generator-v-2\/\",\"url\":\"https:\/\/360bizbrokers.com\/cim-generator-v-2\/\",\"name\":\"CIM Generator V.2 - 360 Biz Brokers\",\"isPartOf\":{\"@id\":\"https:\/\/360bizbrokers.com\/#website\"},\"datePublished\":\"2026-06-19T00:03:51+00:00\",\"dateModified\":\"2026-06-19T02:23:21+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/360bizbrokers.com\/cim-generator-v-2\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/360bizbrokers.com\/cim-generator-v-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/360bizbrokers.com\/cim-generator-v-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/360bizbrokers.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CIM Generator V.2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/360bizbrokers.com\/#website\",\"url\":\"https:\/\/360bizbrokers.com\/\",\"name\":\"Florida 360 Business Brokers\",\"description\":\"Buy &amp; Sell Businesses Advisory\",\"publisher\":{\"@id\":\"https:\/\/360bizbrokers.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/360bizbrokers.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/360bizbrokers.com\/#organization\",\"name\":\"Florida 360 Business Brokers\",\"url\":\"https:\/\/360bizbrokers.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/360bizbrokers.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/360bizbrokers.com\/wp-content\/uploads\/2025\/12\/LOGO-FLORIDA-360-BUSINESS-BROKERS.jpg\",\"contentUrl\":\"https:\/\/360bizbrokers.com\/wp-content\/uploads\/2025\/12\/LOGO-FLORIDA-360-BUSINESS-BROKERS.jpg\",\"width\":1080,\"height\":1080,\"caption\":\"Florida 360 Business Brokers\"},\"image\":{\"@id\":\"https:\/\/360bizbrokers.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"CIM Generator V.2 - 360 Biz Brokers","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/360bizbrokers.com\/pt\/cim-generator-v-2\/","og_locale":"pt_BR","og_type":"article","og_title":"CIM Generator V.2","og_description":"CIM Generator OpenAI v4 | 360 Biz Brokers 360 BIZ BROKERS CIM Generator Setup \u229e Dashboard \u25c8 Template &amp; Design CIM Sections \u2460 Cover Page...","og_url":"https:\/\/360bizbrokers.com\/pt\/cim-generator-v-2\/","og_site_name":"360 Biz Brokers","article_modified_time":"2026-06-19T02:23:21+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. tempo de leitura":"27 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/360bizbrokers.com\/cim-generator-v-2\/","url":"https:\/\/360bizbrokers.com\/cim-generator-v-2\/","name":"CIM Generator V.2 - 360 Biz Brokers","isPartOf":{"@id":"https:\/\/360bizbrokers.com\/#website"},"datePublished":"2026-06-19T00:03:51+00:00","dateModified":"2026-06-19T02:23:21+00:00","breadcrumb":{"@id":"https:\/\/360bizbrokers.com\/cim-generator-v-2\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/360bizbrokers.com\/cim-generator-v-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/360bizbrokers.com\/cim-generator-v-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/360bizbrokers.com\/"},{"@type":"ListItem","position":2,"name":"CIM Generator V.2"}]},{"@type":"WebSite","@id":"https:\/\/360bizbrokers.com\/#website","url":"https:\/\/360bizbrokers.com\/","name":"Florida 360 Business Brokers","description":"Buy &amp; Sell Businesses Advisory","publisher":{"@id":"https:\/\/360bizbrokers.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/360bizbrokers.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/360bizbrokers.com\/#organization","name":"Florida 360 Business Brokers","url":"https:\/\/360bizbrokers.com\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/360bizbrokers.com\/#\/schema\/logo\/image\/","url":"https:\/\/360bizbrokers.com\/wp-content\/uploads\/2025\/12\/LOGO-FLORIDA-360-BUSINESS-BROKERS.jpg","contentUrl":"https:\/\/360bizbrokers.com\/wp-content\/uploads\/2025\/12\/LOGO-FLORIDA-360-BUSINESS-BROKERS.jpg","width":1080,"height":1080,"caption":"Florida 360 Business Brokers"},"image":{"@id":"https:\/\/360bizbrokers.com\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/360bizbrokers.com\/pt\/wp-json\/wp\/v2\/pages\/1342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/360bizbrokers.com\/pt\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/360bizbrokers.com\/pt\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/360bizbrokers.com\/pt\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/360bizbrokers.com\/pt\/wp-json\/wp\/v2\/comments?post=1342"}],"version-history":[{"count":34,"href":"https:\/\/360bizbrokers.com\/pt\/wp-json\/wp\/v2\/pages\/1342\/revisions"}],"predecessor-version":[{"id":1380,"href":"https:\/\/360bizbrokers.com\/pt\/wp-json\/wp\/v2\/pages\/1342\/revisions\/1380"}],"wp:attachment":[{"href":"https:\/\/360bizbrokers.com\/pt\/wp-json\/wp\/v2\/media?parent=1342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}