.drawer.live-draft-dialog {
  inset: 0;
  width: min(1376px, calc(100% - 48px));
  height: min(1060px, calc(100dvh - 48px));
  margin: auto;
  border: 1px solid var(--crm-border);
  border-radius: 18px;
  background: var(--crm-surface);
  color: var(--crm-ink);
  box-shadow: 0 18px 70px rgb(32 32 73 / 32%);
}

.live-draft-dialog[open] { animation: live-draft-in 180ms var(--ease) both; }
.live-draft-dialog[open].is-closing { animation: live-draft-out 150ms var(--ease) both; }
.live-draft-dialog::backdrop { backdrop-filter: blur(2px); }
@keyframes live-draft-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes live-draft-out { from { opacity: 1; } to { opacity: 0; } }

.live-draft-dialog .drawer-head {
  padding: 16px 24px;
  border-color: var(--crm-border);
  background: linear-gradient(104deg, var(--crm-surface) 45%, #f5f4ff);
}
.live-draft-dialog .drawer-heading { display: flex; align-items: center; gap: 14px; min-width: 0; overflow-wrap: anywhere; }
.live-draft-icon {
  display: grid;
  flex: 0 0 46px;
  height: 46px;
  place-items: center;
  border: 1px solid #e3ddff;
  border-radius: 12px;
  color: var(--crm-indigo);
  background: linear-gradient(135deg, #f5f0ff, #e9edff);
}
.live-draft-icon svg { width: 22px; height: 22px; }
.live-draft-dialog .drawer-head h2 { margin: 0; font: 730 25px/1.18 var(--crm-font); letter-spacing: -.45px; }
.live-draft-dialog .drawer-head p { margin: 4px 0 0; color: var(--crm-muted); font-size: 13px; }
.live-draft-dialog [data-close] { flex: 0 0 36px; }
.live-draft-dialog .drawer-body { display: block; padding: 0; overflow: hidden; }
.live-draft-dialog .drawer-body > .form-grid {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(295px, var(--draft-editor-width, 350px)) minmax(0, 1fr);
  grid-template-rows: minmax(0,1fr);
  align-items: stretch;
  gap: 0;
}

.live-draft-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  overflow: auto;
  padding: 22px 20px;
  border-inline-end: 1px solid var(--crm-border);
  background: radial-gradient(100% 64% at 0 0, #eeebff, transparent), radial-gradient(75% 40% at 100% 42%, #e9f5fc, transparent), #f7f8fc;
}
.live-draft-editor > * { flex-shrink: 0; }
.quote-draft-fields, .quote-draft-details, .live-draft-notice {
  margin: 0;
  border: 1px solid #dce1f0;
  border-radius: var(--crm-radius);
  background: var(--crm-surface-glass);
  box-shadow: var(--crm-shadow);
}
.quote-draft-fields { display: grid; gap: 14px; padding: 16px; }
.quote-draft-fields h3 { margin: 0; font-size: 18px; letter-spacing: -.2px; }
.live-draft-dialog .field { min-width: 0; }
.live-draft-dialog .field > span { color: var(--crm-ink); }
.live-draft-dialog .field :is(input, textarea) { width: 100%; min-width: 0; border-radius: 8px; }
.live-draft-dialog .field input { min-height: 39px; }
.live-draft-dialog .field :is(input, textarea):focus-visible { border-color: var(--crm-indigo); box-shadow: var(--crm-focus); }
.quote-draft-comment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--crm-indigo);
  font-weight: 650;
}
.quote-draft-comment span { font-size: 20px; line-height: 1; font-weight: 400; }
.quote-draft-details summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.quote-draft-details summary::-webkit-details-marker { display: none; }
.quote-draft-details summary::after {
  content: '';
  width: 7px;
  height: 7px;
  border: solid var(--crm-muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.quote-draft-details[open] summary::after { transform: rotate(225deg); }
.quote-draft-details summary :is(strong, small) { display: block; }
.quote-draft-details summary small { color: var(--crm-muted); font-size: 12px; }
.quote-draft-parties { display: grid; gap: 12px; padding: 0 12px 12px; }
.quote-draft-parties .doc-draft-section { padding: 10px; }
.live-draft-notice { padding: 14px 16px; color: var(--crm-muted); font-size: 13px; }

.live-draft-dialog.doc-draft-invoice { --draft-editor-width: 400px; }
.live-draft-dialog .invoice-draft-payer {
  padding: 14px 16px;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  background: var(--crm-surface-glass);
  box-shadow: var(--crm-shadow);
}
.live-draft-dialog .doc-invoice-supplier,
.live-draft-dialog .doc-invoice-services { box-shadow: var(--crm-shadow); }

.live-draft-preview {
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  min-width: 0;
  min-height: 0;
  background: radial-gradient(ellipse at 80% 8%, #eef4fc, transparent 60%), radial-gradient(ellipse at 10% 85%, #eae9fb, transparent 65%), #e8edf7;
}
.live-draft-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--crm-border); background: #f9faff; }
.live-draft-toolbar h3 { margin: 0; font-size: 14px; }
.live-draft-toolbar span { color: var(--crm-muted); font-size: 12px; }
.live-draft-viewport { position: relative; display: flex; flex-direction: column; align-items: center; overflow: auto; padding: 14px 16px; overscroll-behavior: contain; }
.live-draft-paper { position: relative; flex: 0 0 auto; overflow: hidden; background: #fcfcff; box-shadow: 0 6px 24px rgb(39 43 87 / 17%); }
.live-draft-paper iframe { display: block; position: absolute; inset: 0 auto auto 0; width: 780px; border: 0; transform-origin: top left; }
.live-draft-preview-message {
  z-index: 1;
  position: sticky;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-block-end: 10px;
  border-radius: 9px;
  background: var(--crm-surface);
  color: var(--crm-muted);
  box-shadow: var(--crm-shadow);
}
.live-draft-preview-message p { margin: 0; }
.live-draft-dialog .drawer-footer { padding: 12px 24px; border-top-color: var(--crm-border); flex-wrap: wrap; }
.live-draft-dialog .drawer-footer [data-form-error] { margin: 0 auto 0 0; padding-block: 5px; }
.live-draft-dialog .drawer-footer .button { min-height: 42px; border-radius: 9px; }
.live-draft-dialog .drawer-footer .primary { background: var(--crm-gradient); }
.live-draft-dialog .drawer-footer .primary:enabled { box-shadow: 0 5px 11px rgb(92 65 229 / 23%); }

@media (max-width: 770px) {
  .drawer.live-draft-dialog { width: calc(100% - 16px); height: calc(100dvh - 16px); border-radius: 14px; }
  .live-draft-dialog .drawer-head, .live-draft-dialog .drawer-footer { padding: 12px; }
  .live-draft-dialog .drawer-head h2 { font-size: 19px; }
  .live-draft-icon { flex-basis: 34px; height: 34px; }
  .live-draft-dialog .drawer-body { overflow: auto; }
  .live-draft-dialog .drawer-body > .form-grid { height: auto; grid-template-columns: minmax(0,1fr); grid-template-rows: none; }
  .live-draft-editor { overflow: visible; padding: 12px; border-inline-end: 0; border-bottom: 1px solid var(--crm-border); }
  .live-draft-viewport { overflow: visible; }
  .live-draft-toolbar { padding: 12px 16px; }
}
