.business-document-wrap { padding-bottom: 72px; }
.business-document-hero { min-height: 330px; margin-top: 0; padding: clamp(34px,5vw,58px); border: 1px solid color-mix(in srgb,var(--doc-accent) 25%,var(--line)); border-radius: 30px; display: grid; grid-template-columns: minmax(0,1fr) 330px; align-items: center; gap: 40px; position: relative; isolation: isolate; overflow: hidden; text-align: left; background: radial-gradient(circle at 85% 14%,color-mix(in srgb,var(--doc-accent) 18%,transparent),transparent 21rem),linear-gradient(145deg,var(--surface),color-mix(in srgb,var(--doc-soft) 72%,var(--surface))); box-shadow: 0 18px 42px rgba(18,38,82,.09); }
.business-document-hero::before { content:""; width:320px; height:320px; position:absolute; right:-110px; bottom:-210px; z-index:-1; border:38px solid color-mix(in srgb,var(--doc-accent) 9%,transparent); border-radius:50%; }
.business-document-hero-copy { min-width:0; }
.document-hero-chip { min-height:32px; padding:0 12px; border-radius:999px; display:inline-flex; align-items:center; gap:7px; color:var(--doc-accent); background:color-mix(in srgb,var(--doc-accent) 10%,var(--surface)); font-size:.7rem; font-weight:800; }
.document-hero-chip svg { width:15px; }
.business-document-hero h1 { margin:15px 0 10px; font-family:"Chakra Petch","Anuphan",sans-serif; font-size:clamp(2.7rem,5.5vw,4.7rem); line-height:1; letter-spacing:-.055em; }
.business-document-hero-copy > p { max-width:680px; margin:0; color:var(--muted); font-size:1rem; line-height:1.75; }
.document-hero-trust { margin-top:20px; display:flex; flex-wrap:wrap; gap:8px; }
.document-hero-trust span { min-height:32px; padding:0 10px; border:1px solid color-mix(in srgb,var(--doc-accent) 16%,var(--line)); border-radius:999px; display:inline-flex; align-items:center; gap:6px; background:color-mix(in srgb,var(--surface) 88%,transparent); font-size:.66rem; font-weight:700; }
.document-hero-trust svg { width:14px; color:var(--doc-accent); }
.business-document-hero-art { width:270px; height:220px; justify-self:center; position:relative; }
.hero-paper { width:176px; height:218px; position:absolute; left:47px; top:0; border:1px solid color-mix(in srgb,var(--doc-accent) 20%,#d9e2f0); border-radius:18px; background:#fff; box-shadow:0 25px 45px rgba(13,34,82,.18); }
.hero-paper-back { transform:translate(24px,6px) rotate(9deg); opacity:.65; }
.hero-paper-front { padding:28px 24px; display:grid; align-content:start; gap:13px; transform:rotate(-4deg); }
.hero-paper-front::before { content:""; width:66px; height:9px; border-radius:999px; background:var(--doc-accent); }
.hero-paper-front i { height:7px; border-radius:999px; background:#e6ebf3; }
.hero-paper-front i:nth-child(2) { width:78%; }
.hero-paper-front i:nth-child(3) { width:56%; }
.hero-paper-front b { width:58px; height:58px; margin:20px auto 0; border-radius:18px; display:grid; place-items:center; color:#fff; background:var(--doc-accent); box-shadow:0 12px 24px color-mix(in srgb,var(--doc-accent) 28%,transparent); }
.hero-paper-front b svg { width:30px; }
.hero-document-check { width:52px; height:52px; position:absolute; right:21px; bottom:13px; border:5px solid #fff; border-radius:50%; display:grid; place-items:center; color:#163100; background:#c8ff18; box-shadow:0 12px 24px rgba(75,116,0,.2); }
.hero-document-check svg { width:25px; stroke-width:3; }

.document-kind-nav { margin:18px 0 0; padding:8px; border:1px solid var(--line); border-radius:18px; display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:7px; overflow:auto; background:var(--surface); box-shadow:0 8px 20px rgba(19,35,76,.05); }
.document-kind-nav a { min-height:48px; padding:8px 10px; border-radius:12px; display:flex; align-items:center; justify-content:center; gap:7px; color:var(--muted); font-size:.71rem; font-weight:750; white-space:nowrap; transition:.2s ease; }
.document-kind-nav a:hover { color:var(--doc-accent); background:color-mix(in srgb,var(--doc-accent) 6%,var(--surface)); }
.document-kind-nav a.active { color:#fff; background:var(--doc-accent); box-shadow:0 8px 18px color-mix(in srgb,var(--doc-accent) 22%,transparent); }
.document-kind-nav svg { width:16px; }

.business-document-layout { margin-top:24px; display:grid; grid-template-columns:minmax(0,1fr); align-items:start; gap:22px; }
.business-document-layout .tool-sidebar { grid-template-columns:repeat(2,minmax(0,1fr)); }
.business-document-card { min-width:0; padding:clamp(18px,3vw,30px); border:1px solid var(--line); border-radius:26px; background:linear-gradient(145deg,var(--surface),color-mix(in srgb,var(--doc-soft) 20%,var(--surface))); box-shadow:0 12px 30px rgba(16,34,75,.07); }
.business-document-heading { margin-bottom:24px; display:flex; align-items:flex-start; justify-content:space-between; gap:20px; }
.business-document-heading h2 { margin:0; font-size:clamp(1.3rem,2vw,1.75rem); }
.business-document-heading p:last-child { margin:6px 0 0; color:var(--muted); font-size:.76rem; }
.business-document-heading > span { width:40px; height:40px; flex:0 0 auto; border-radius:13px; display:grid; place-items:center; color:#fff; background:var(--doc-accent); font-weight:900; box-shadow:0 9px 20px color-mix(in srgb,var(--doc-accent) 24%,transparent); }
.business-document-studio { display:grid; grid-template-columns:minmax(390px,.86fr) minmax(480px,1.14fr); align-items:start; gap:22px; }
.business-document-form { min-width:0; padding:20px; border:1px solid var(--line); border-radius:22px; display:grid; gap:20px; background:var(--surface); box-shadow:0 14px 30px rgba(18,37,79,.06); }
.document-form-intro { display:flex; align-items:center; gap:12px; }
.document-form-intro > span { width:44px; height:44px; flex:0 0 auto; border-radius:14px; display:grid; place-items:center; color:#fff; background:linear-gradient(145deg,var(--doc-accent),color-mix(in srgb,var(--doc-accent) 65%,#8255ef)); box-shadow:0 9px 20px color-mix(in srgb,var(--doc-accent) 25%,transparent); transform:rotate(-4deg); }
.document-form-intro svg { width:21px; }
.document-form-intro h3,.business-preview-panel > header h3 { margin:0; font-size:1.02rem; }
.document-form-intro p { margin:3px 0 0; color:var(--muted); font-size:.68rem; }
.document-theme-picker { margin:0; padding:0; border:0; display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.document-theme-picker legend { margin-bottom:8px; color:var(--muted); font-size:.68rem; font-weight:800; }
.document-theme-picker label { min-height:47px; padding:7px 9px; border:1px solid var(--line); border-radius:13px; display:flex; align-items:center; gap:7px; position:relative; cursor:pointer; background:var(--paper); font-size:.68rem; }
.document-theme-picker label:has(input:checked) { border-color:var(--doc-accent); box-shadow:0 0 0 3px color-mix(in srgb,var(--doc-accent) 9%,transparent); }
.document-theme-picker input { position:absolute; opacity:0; pointer-events:none; }
.theme-dot { width:26px; height:26px; flex:0 0 auto; border:3px solid #fff; border-radius:9px; box-shadow:0 3px 9px rgba(9,25,58,.16); }
.theme-modern { background:linear-gradient(135deg,#0b1734 50%,var(--doc-accent) 50%); }
.theme-minimal { background:linear-gradient(135deg,#e7f0f3 50%,#31556f 50%); }
.theme-executive { background:linear-gradient(135deg,#1d2433 50%,#b98a30 50%); }
.document-field-group { padding-top:18px; border-top:1px solid var(--line); }
.document-field-group > header { margin-bottom:12px; display:flex; align-items:center; gap:9px; }
.document-field-group > header > span { width:27px; height:27px; flex:0 0 auto; border-radius:9px; display:grid; place-items:center; color:var(--doc-accent); background:color-mix(in srgb,var(--doc-accent) 10%,var(--surface)); font-size:.7rem; font-weight:900; }
.document-field-group h3 { margin:0; font-size:.82rem; }
.document-control-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.document-control-grid > label,.document-item-row > label { min-width:0; display:grid; gap:6px; color:var(--muted); font-size:.66rem; font-weight:700; }
.document-control-grid input,.document-control-grid select,.document-control-grid textarea,.document-item-row input { width:100%; min-height:42px; padding:9px 10px; border:1px solid var(--line); border-radius:11px; outline:0; color:var(--ink); background:var(--paper); transition:border-color .2s ease,box-shadow .2s ease; }
.document-control-grid textarea { min-height:68px; resize:vertical; line-height:1.5; }
.document-control-grid :is(input,select,textarea):focus,.document-item-row input:focus { border-color:var(--doc-accent); box-shadow:0 0 0 3px color-mix(in srgb,var(--doc-accent) 9%,transparent); }
.field-wide { grid-column:1/-1; }
.document-items-heading { flex-wrap:wrap; }
.document-add-item { min-height:32px; margin-left:auto; padding:0 10px; border:1px solid color-mix(in srgb,var(--doc-accent) 28%,var(--line)); border-radius:999px; display:inline-flex; align-items:center; gap:5px; color:var(--doc-accent); background:color-mix(in srgb,var(--doc-accent) 5%,var(--surface)); font-size:.64rem; font-weight:800; cursor:pointer; }
.document-add-item:disabled { opacity:.45; cursor:not-allowed; }
.document-add-item svg { width:14px; }
.document-items { display:grid; gap:9px; }
.document-item-row { padding:10px; border:1px solid var(--line); border-radius:14px; display:grid; grid-template-columns:25px minmax(135px,1fr) 70px 74px 105px 34px; align-items:end; gap:7px; background:var(--paper); }
.document-item-number { width:25px; height:25px; margin-bottom:8px; border-radius:8px; display:grid; place-items:center; color:var(--doc-accent); background:color-mix(in srgb,var(--doc-accent) 9%,var(--surface)); font-size:.65rem; font-weight:900; }
.document-remove-item { width:34px; height:42px; border:0; border-radius:10px; display:grid; place-items:center; color:#d63d4b; background:color-mix(in srgb,#ff4d5e 9%,var(--surface)); cursor:pointer; }
.document-remove-item[hidden] { visibility:hidden; display:grid; }
.document-remove-item svg { width:16px; }
.document-item-limit { margin:8px 0 0; color:var(--muted); font-size:.58rem; }
.document-switch { min-height:60px; padding:10px 12px; border:1px solid var(--line); border-radius:13px; grid-template-columns:auto 1fr !important; align-items:center; gap:10px !important; cursor:pointer; background:var(--paper); }
.document-switch input { width:20px; min-height:20px; accent-color:var(--doc-accent); }
.document-switch span { display:grid; gap:2px; }
.document-switch small { color:var(--muted); font-weight:500; }
.document-draft-actions { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.document-draft-actions .tool-secondary { min-height:42px; padding:8px; display:inline-flex; align-items:center; justify-content:center; gap:5px; font-size:.61rem; }
.document-draft-actions svg { width:15px; }
.document-reset { color:#b43b48; }
.document-form-status { min-height:20px; margin:-8px 0 0; font-size:.65rem; font-weight:700; }
.document-form-status[data-state="success"] { color:#087c69; }
.document-form-status[data-state="error"] { color:#c23a49; }
.document-build-button { min-height:54px; font-size:.82rem; box-shadow:0 13px 28px color-mix(in srgb,var(--doc-accent) 22%,transparent); }
.document-build-button svg { width:18px; }

.business-preview-panel { min-width:0; padding:14px; position:sticky; top:92px; border:1px solid #d8e0ec; border-radius:22px; background:linear-gradient(145deg,#e7edf7,#f7f9fd); box-shadow:inset 0 1px #fff,0 15px 30px rgba(20,39,80,.08); }
.business-preview-panel > header { margin-bottom:11px; padding:2px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.business-preview-panel > header small { display:block; margin-bottom:2px; color:#657086; font-size:.59rem; font-weight:700; }
.business-live-chip { min-height:25px; padding:0 8px; border-radius:999px; display:inline-flex; align-items:center; gap:5px; color:#087c69; background:#dff9ef; font-size:.56rem; font-weight:900; letter-spacing:.08em; }
.business-live-chip i { width:6px; height:6px; border-radius:50%; background:#11b985; box-shadow:0 0 0 4px rgba(17,185,133,.13); }
.business-preview-scroll { max-width:100%; overflow:hidden; border-radius:15px; background:#fff; box-shadow:0 18px 38px rgba(21,40,82,.15); }
#businessDocumentPreview { width:100%; min-height:1px; position:relative; overflow:hidden; background:#fff; }
.business-document-sheet { --sheet-accent:var(--doc-accent); --sheet-ink:#0b1734; --sheet-soft:var(--doc-soft); width:620px; min-width:620px; min-height:870px; padding:39px 37px 30px; position:relative; overflow:hidden; transform-origin:left top; color:var(--sheet-ink); background:#fff; font-size:.63rem; line-height:1.45; }
.business-document-sheet.document-theme-minimal { --sheet-accent:#31556f; --sheet-ink:#182b39; --sheet-soft:#eef4f6; }
.business-document-sheet.document-theme-executive { --sheet-accent:#8c6821; --sheet-ink:#1d2433; --sheet-soft:#f7f1e3; }
.business-sheet-ribbon { height:9px; position:absolute; inset:0 0 auto; background:linear-gradient(90deg,var(--sheet-accent) 0 78%,color-mix(in srgb,var(--sheet-accent) 45%,#dfffb0) 78%); }
.business-sheet-header { padding-bottom:23px; border-bottom:1px solid #e3e7ef; display:grid; grid-template-columns:1fr auto; gap:22px; }
.business-sheet-company { display:grid; grid-template-columns:50px 1fr; align-items:start; gap:11px; }
.business-sheet-company > span { width:50px; height:50px; border-radius:15px; display:grid; place-items:center; color:#fff; background:var(--sheet-accent); font-size:1.2rem; font-weight:900; box-shadow:0 8px 18px color-mix(in srgb,var(--sheet-accent) 24%,transparent); }
.business-sheet-company strong,.business-sheet-company small,.business-sheet-meta small { display:block; }
.business-sheet-company strong { margin-bottom:4px; font-size:.9rem; }
.business-sheet-company small { max-width:270px; color:#737d91; font-size:.51rem; }
.business-sheet-meta { min-width:175px; text-align:right; }
.business-sheet-meta em { min-height:22px; padding:0 8px; border-radius:999px; display:inline-flex; align-items:center; color:#fff; background:var(--sheet-accent); font-size:.49rem; font-style:normal; font-weight:900; }
.business-sheet-meta h2 { margin:8px 0 1px; color:var(--sheet-accent); font-family:"Chakra Petch","Anuphan",sans-serif; font-size:1.36rem; letter-spacing:-.04em; }
.business-sheet-meta b { font-size:.63rem; }
.business-sheet-meta small { color:#737d91; font-size:.5rem; }
.business-sheet-customer { margin-top:21px; padding:15px 17px; border-radius:14px; display:grid; grid-template-columns:1.25fr .75fr; gap:18px; background:var(--sheet-soft); }
.business-sheet-customer > div { display:grid; align-content:start; gap:3px; }
.business-sheet-customer > div:last-child { grid-template-columns:auto 1fr; gap:4px 10px; }
.business-sheet-customer span,.business-sheet-customer small { color:#737d91; font-size:.49rem; }
.business-sheet-customer strong { font-size:.76rem; }
.business-sheet-customer b { font-size:.54rem; text-align:right; }
.business-sheet-table { margin-top:21px; }
.business-sheet-row { min-height:42px; padding:9px 9px; border-bottom:1px solid #e8ebf2; display:grid; align-items:center; gap:6px; }
.business-sheet-table.show-prices .business-sheet-row { grid-template-columns:25px minmax(160px,1fr) 50px 48px 72px 78px; }
.business-sheet-table.hide-prices .business-sheet-row { grid-template-columns:25px minmax(230px,1fr) 74px 68px; }
.business-sheet-row > :nth-last-child(-n+4) { text-align:right; }
.business-sheet-row strong { overflow-wrap:anywhere; }
.business-sheet-table-head { min-height:38px; border:0; border-radius:10px; color:#fff; background:var(--sheet-ink); font-weight:800; }
.business-sheet-summary { margin-top:23px; display:grid; grid-template-columns:minmax(0,1fr) 230px; align-items:start; gap:20px; }
.business-sheet-words { padding:13px 14px; border-radius:12px; display:grid; gap:4px; background:var(--sheet-soft); }
.business-sheet-words span,.business-sheet-words small { color:#737d91; font-size:.48rem; }
.business-sheet-words strong { color:var(--sheet-accent); font-size:.58rem; }
.business-sheet-summary dl { margin:0; display:grid; grid-template-columns:1fr auto; align-items:center; gap:7px 12px; }
.business-sheet-summary dt { color:#737d91; }
.business-sheet-summary dd { margin:0; text-align:right; font-weight:700; }
.business-sheet-summary .grand-label,.business-sheet-summary .grand-total { margin-top:4px; padding-block:10px; color:#fff; background:var(--sheet-accent); }
.business-sheet-summary .grand-label { padding-left:11px; border-radius:10px 0 0 10px; }
.business-sheet-summary .grand-total { padding-right:11px; border-radius:0 10px 10px 0; font-size:.72rem; }
.business-sheet-no-price { min-height:50px; margin-top:24px; border-radius:12px; display:flex; align-items:center; justify-content:center; gap:7px; color:var(--sheet-accent); background:var(--sheet-soft); font-weight:800; }
.business-sheet-no-price svg { width:16px; }
.business-sheet-note { margin-top:22px; padding:12px 14px; border:1px solid #e6e9ef; border-radius:12px; }
.business-sheet-note b { color:var(--sheet-accent); }
.business-sheet-note p { margin:4px 0; }
.business-sheet-note small { color:#7b8498; }
.business-sheet-footer { margin-top:55px; display:grid; grid-template-columns:135px 135px 1fr; align-items:end; gap:18px; }
.business-sheet-footer > span { display:grid; gap:3px; text-align:center; }
.business-sheet-footer i { height:1px; margin-bottom:4px; background:#afb6c5; }
.business-sheet-footer small,.business-sheet-footer p { color:#7b8498; font-size:.46rem; }
.business-sheet-footer p { margin:0; padding-top:10px; border-top:3px solid var(--sheet-accent); text-align:right; }
.business-document-actions { margin-top:13px; padding:13px; border:1px solid #d7dfec; border-radius:15px; display:grid; grid-template-columns:1fr 1fr; gap:9px; background:#fff; }
.business-document-actions[hidden] { display:none; }
.business-document-actions :is(.tool-primary,.tool-secondary) { min-height:44px; display:inline-flex; align-items:center; justify-content:center; gap:6px; }
.business-document-actions svg { width:16px; }
.document-building { grid-column:1/-1; min-height:44px; display:flex; align-items:center; justify-content:center; gap:9px; color:#243650; }
.document-building i { width:18px; height:18px; border:3px solid #d7dfec; border-top-color:var(--doc-accent); border-radius:50%; animation:document-spin .8s linear infinite; }
.document-action-error { grid-column:1/-1; margin:0; color:#bd3d49; text-align:center; }
@keyframes document-spin { to { transform:rotate(360deg); } }

@media (max-width:1180px) {
  .business-document-layout { grid-template-columns:1fr; }
  .business-document-layout .tool-sidebar { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .business-document-studio { grid-template-columns:1fr; }
  .business-preview-panel { position:static; }
}
@media (max-width:840px) {
  .business-document-hero { min-height:auto; padding:30px; grid-template-columns:1fr; text-align:center; }
  .business-document-hero-copy > p { margin-inline:auto; }
  .document-hero-trust { justify-content:center; }
  .business-document-hero-art { width:245px; height:200px; order:-1; }
  .hero-paper { width:160px; height:198px; left:42px; }
  .document-kind-nav { grid-template-columns:repeat(5,145px); }
  .business-document-layout .tool-sidebar { grid-template-columns:1fr; }
}
@media (max-width:620px) {
  .business-document-wrap { width:min(100% - 24px,1180px); }
  .business-document-hero { padding:24px 18px; border-radius:24px; text-align:left; }
  .business-document-hero h1 { font-size:clamp(2.35rem,12vw,3.2rem); }
  .business-document-hero-art { width:210px; height:175px; margin-inline:auto; }
  .hero-paper { width:140px; height:173px; left:36px; padding:22px 18px; }
  .hero-paper-front b { width:48px; height:48px; margin-top:10px; }
  .document-hero-trust { justify-content:flex-start; }
  .document-kind-nav { margin-top:12px; grid-template-columns:repeat(5,132px); }
  .business-document-card { padding:16px 12px; border-radius:22px; }
  .business-document-heading { padding-inline:3px; }
  .business-document-heading > span { width:36px; height:36px; }
  .business-document-form { padding:16px 13px; }
  .document-theme-picker { grid-template-columns:1fr; }
  .document-control-grid { grid-template-columns:1fr; }
  .field-wide { grid-column:auto; }
  .document-item-row { padding:10px; grid-template-columns:25px minmax(0,1fr) 72px 34px; }
  .document-item-row .document-item-detail { grid-column:2/4; }
  .document-item-row > label:nth-of-type(2) { grid-column:2; }
  .document-item-row > label:nth-of-type(3) { grid-column:3; }
  .document-item-row > label:nth-of-type(4) { grid-column:2/4; }
  .document-remove-item { grid-column:4; grid-row:2; }
  .document-draft-actions { grid-template-columns:1fr; }
  .business-preview-panel { padding:9px; }
  .business-document-actions { grid-template-columns:1fr; }
  .business-sheet-footer { margin-top:42px; }
}

@media print {
  @page { size:A4; margin:0; }
  body { background:#fff !important; }
  body * { visibility:hidden !important; }
  .business-document-sheet,.business-document-sheet * { visibility:visible !important; }
  #businessDocumentPreview { width:auto !important; height:auto !important; overflow:visible; }
  .business-document-sheet { width:210mm; min-width:0; min-height:297mm; position:absolute; left:0; top:0; transform:none !important; box-shadow:none; }
}
