/* Online editor */
body.editor-page { overflow: hidden; }
body.editor-page .site-header .main-nav, body.editor-page .header-search { display: none; }
.editor { height: calc(100vh - 71px); height: calc(100dvh - 71px); display: grid; grid-template-rows: auto 1fr; }
.ed-toolbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fff; min-width: 0; }
.ed-title-wrap { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.ed-title { border: 1px solid transparent !important; background: transparent !important; font-weight: 650 !important; font-size: 1.02rem !important; color: var(--ink) !important; padding: 7px 10px !important; max-width: 380px; min-width: 120px; box-shadow: none !important; }
.ed-title:hover { border-color: var(--line) !important; }
.ed-title:focus { border-color: var(--lime-600) !important; background: #fff !important; }
.ed-status { font-size: 0.8rem; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.ed-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--lime-500); }
.ed-status.dirty::before { background: #f59e0b; }
.ed-status.busy::before { background: var(--info); }
.ed-actions { display: flex; align-items: center; gap: 6px; }
.ed-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.ed-trial-note { font-size: 0.8rem; color: var(--muted); margin-right: 4px; }
.ed-tabs { display: none; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.ed-tabs button { border: 0; background: none; font: inherit; font-size: 0.85rem; font-weight: 600; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.ed-tabs button[aria-selected='true'] { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

.ed-body { display: grid; grid-template-columns: 450px 1fr; min-height: 0; }
.ed-form { overflow-y: auto; border-right: 1px solid var(--line); background: #fff; padding: 16px 16px 120px; scroll-behavior: smooth; }
.ed-preview { overflow: auto; background: #e6eaf0; background-image: radial-gradient(rgba(15,23,42,.06) 1px, transparent 1px); background-size: 18px 18px; padding: 22px 28px 60px; }
.ed-hint { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--muted); margin-bottom: 14px; }
.ed-hint svg { width: 15px; height: 15px; }
.ed-page { position: relative; margin: 0 auto; box-shadow: 0 20px 50px -24px rgba(15,23,42,.45), 0 0 0 1px rgba(15,23,42,.06); background: #fff; }
.ed-page > .lpdoc { position: absolute; top: 0; left: 0; transform-origin: top left; }

/* sections */
.ed-sec { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: #fff; }
.ed-sec > summary { list-style: none; cursor: pointer; padding: 12px 14px; font-weight: 650; font-size: 0.93rem; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.ed-sec > summary::-webkit-details-marker { display: none; }
.ed-sec > summary .chev { margin-left: auto; width: 16px; height: 16px; color: var(--muted); transition: rotate .15s; }
.ed-sec[open] > summary .chev { rotate: 180deg; }
.ed-sec > summary .n { font-size: 0.75rem; font-weight: 600; color: var(--muted); background: var(--bg-soft); border-radius: 999px; padding: 1px 8px; }
.ed-sec-body { padding: 2px 14px 14px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; }
.ed-field { display: grid; gap: 4px; align-content: start; min-width: 0; }
.ed-field.full { grid-column: 1 / -1; }
.ed-field > label { font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.ed-form input[type='text'], .ed-form input[type='date'], .ed-form select, .ed-form textarea { padding: 8px 10px; font-size: 0.9rem; border-radius: 8px; }
.ed-form textarea { min-height: 70px; }
.ed-flash { animation: edflash 1.2s ease-out; }
@keyframes edflash { 0% { box-shadow: 0 0 0 4px rgba(132, 204, 22, 0.55); } 100% { box-shadow: 0 0 0 4px rgba(132, 204, 22, 0); } }

/* branding */
.ed-logo { display: flex; align-items: center; gap: 12px; }
.ed-logo .box { width: 120px; height: 48px; border: 1px dashed var(--line-2); border-radius: 8px; display: grid; place-items: center; background: var(--bg-soft) center/contain no-repeat; font-size: 0.75rem; color: var(--muted-2); overflow: hidden; }
.ed-logo .box img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* photo slots (business plans) */
.ed-pic-row { display: flex; gap: 14px; align-items: center; }
.ed-pic-thumb { flex: none; width: 132px; max-height: 150px; border: 1px dashed var(--line-2); border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--bg-soft); font-size: 0.75rem; color: var(--muted-2); }
.ed-pic-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-pic-actions { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.ed-pic-actions small { flex-basis: 100%; color: var(--muted); font-size: 0.74rem; }
/* the customer's own sections (business plans) */
.ed-x-head { cursor: pointer; }
.ed-x-note { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 0.8rem; }
.ed-check { align-content: end; }
.ed-check label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 500; color: var(--ink); cursor: pointer; padding-bottom: 8px; }
.ed-check input { width: 16px; height: 16px; margin: 0; }
.swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; padding: 0; }
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--ink); }
.swatches input[type='color'] { width: 30px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }

/* table rows */
.ed-rows { grid-column: 1 / -1; display: grid; gap: 8px; min-width: 0; }
.ed-row { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); min-width: 0; }
.ed-row-head { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 12px; font-size: 0.82rem; }
.ed-row-head .idx { font-weight: 700; color: var(--ink); }
.ed-row-head .sum { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ed-row-head .calc { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.ed-row-head button { border: 0; background: none; width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.ed-row-head button:hover { background: #fff; color: var(--ink); }
.ed-row-head button.del:hover { color: var(--danger); }
.ed-row-head button svg { width: 15px; height: 15px; }
.ed-row-body { padding: 0 10px 10px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.ed-row-body .ed-field.wide { grid-column: 1 / -1; }
.ed-row.collapsed .ed-row-body { display: none; }
.ed-add { grid-column: 1 / -1; }

.toast { position: fixed; bottom: 22px; left: 50%; translate: -50% 20px; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 0.9rem; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s; z-index: 100; max-width: min(520px, 90vw); }
.toast.show { opacity: 1; translate: -50% 0; }
.toast.error { background: #991b1b; }

.print-root { display: none; }

@media (max-width: 1180px) { .hide-md { display: none; } }
@media (max-width: 960px) {
  .ed-body { grid-template-columns: 1fr; }
  .ed-tabs { display: inline-flex; }
  .editor[data-view='edit'] .ed-preview { display: none; }
  .editor[data-view='preview'] .ed-form { display: none; }
  .ed-title { max-width: 180px; }
  .ed-status { display: none; }
}
@media (max-width: 640px) {
  .ed-toolbar { flex-wrap: wrap; }
  .ed-actions { flex-wrap: wrap; row-gap: 6px; }
  .ed-lang select { max-width: 96px; }
  .ed-title-wrap { order: 3; flex-basis: 100%; }
  .ed-sec-body, .ed-row-body { grid-template-columns: 1fr; }
}

/* Print: only the document */
@media print {
  @page { size: A4; margin: 0; }
  body.editor-page { overflow: visible; }
  body > *:not(main), main > *:not(#print-root) { display: none !important; }
  .print-root { display: block !important; }
  .print-root .lpdoc { width: 210mm; min-height: auto; padding: 13mm 12.5mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .lpdoc-table tr, .lpdoc-totals, .lpdoc-signs, .lpdoc-parties { break-inside: avoid; }
  /* business plans: full-bleed cover page, then normal margins on every following page */
  .print-root .lpdoc-plan { page: lpplan; padding: 0 12.5mm; }
  .print-root .lpdoc-plan .lpdoc-cover { page: lpcover; height: 296.5mm; margin: 0 -12.5mm; }
}
@page lpplan { size: A4; margin: 14mm 0 15mm; }
@page lpcover { size: A4; margin: 0; }

/* document language (independent of the website language) */
.ed-lang { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 2px 0 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer; }
.ed-lang svg { width: 15px; height: 15px; flex: none; }
.ed-lang select { width: auto; height: 30px; padding: 0 22px 0 2px; border: 0; background-color: transparent; box-shadow: none; font-size: 0.85rem; font-weight: 600; color: var(--ink); cursor: pointer; }
.ed-lang select:focus { box-shadow: none; }
.ed-lang:focus-within { border-color: var(--lime-600); box-shadow: 0 0 0 3px rgba(132, 204, 22, 0.18); }
