/* ─── Compositor Layout ─────────────────────────────────── */
.compositor-view {
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Topbar ── */
.comp-topbar {
  height: 52px;
  min-height: 52px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  flex-shrink: 0;
}
.comp-topbar-left  { display: flex; align-items: center; gap: 16px; }
.comp-topbar-right { display: flex; align-items: center; gap: 10px; }
.comp-topbar-sep { width: 1px; height: 22px; background: var(--border); }
.comp-autosave-indicator { font-size: 11.5px; color: var(--tsec); white-space: nowrap; }
.comp-tb-link { background: none; border: none; color: var(--tsec); font-size: 13px; cursor: pointer; padding: 4px 6px; border-radius: 5px; transition: color 0.12s; }
.comp-tb-link:hover { color: var(--text); }
.btn-icon-sm { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: none; background: none; border-radius: 6px; cursor: pointer; color: var(--tsec); transition: background 0.1s, color 0.1s; }
.btn-icon-sm:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-icon-sm:disabled { opacity: 0.3; cursor: default; }
.btn-icon-sm .material-symbols-outlined { font-size: 18px; }
.comp-ratebar-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }
.comp-logo-text { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }

.doc-type-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  padding: 3px;
  gap: 2px;
}
.doc-type-btn {
  background: none;
  border: none;
  border-radius: var(--r-btn);
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--tsec);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}
.doc-type-btn:hover { color: var(--text); }
.doc-type-btn.active {
  background: var(--white);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.09);
}

/* ── Rate Bar ── */
.comp-ratebar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  font-size: 12.5px;
  color: var(--tsec);
  flex-shrink: 0;
  white-space: nowrap;
  scrollbar-width: none;
}
.comp-ratebar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comp-hours-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  font-size: 11.5px;
  color: var(--tsec);
  padding: 6px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-style: italic;
}
.comp-hours-hint-x {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--tsec);
  font-size: 11px;
  font-style: normal;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: underline;
  padding: 0;
}
.comp-hours-hint-x:hover { color: var(--text); }
.comp-ratebar label { display: flex; align-items: center; gap: 5px; padding: 8px 16px; }
.comp-ratebar .btn-ghost { border-radius: 0; border: none; background: transparent; color: var(--tsec); }
.comp-ratebar .btn-ghost:hover { border: none; background: transparent; color: var(--text); }
.comp-ratebar input[type="number"] {
  width: 40px;
  text-align: center;
  border: 1px solid var(--border-s);
  border-radius: 8px;
  padding: 4px 4px;
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--white);
  color: var(--text);
  -moz-appearance: textfield;
}
.comp-ratebar input[type="number"]::-webkit-outer-spin-button,
.comp-ratebar input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.comp-ratebar input[type="number"]:focus { outline: none; border-color: var(--primary); }
.comp-ratebar input.narrow { width: 40px; }
.rate-sep  { color: var(--tph); margin: 0 2px; }
.rate-summary { color: var(--text); font-weight: 500; }

/* ── Document Area ── */
.comp-document-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 80px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.3s;
}
.comp-document-area:hover,
.comp-document-area.is-scrolling {
  scrollbar-color: var(--border-s) transparent;
}
.comp-document-area::-webkit-scrollbar { width: 5px; }
.comp-document-area::-webkit-scrollbar-track { background: transparent; }
.comp-document-area::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
  transition: background 0.3s;
}
.comp-document-area:hover::-webkit-scrollbar-thumb,
.comp-document-area.is-scrolling::-webkit-scrollbar-thumb {
  background: var(--border-s);
}

/* ── Pages Column ── */
.pages-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* ── Document Page (A4) ── */
.document-card,
.doc-page {
  /* Design tokens — set by Design Panel / template system */
  --ink: #1A1A1A;
  --doc-paper: var(--white);
  --font-title: 'Inter', sans-serif;
  --font-block-title: 'Inter', sans-serif;
  --block-title-size: 14px;
  --block-title-weight: 700;
  --font-body: 'Inter', sans-serif;
  --body-weight: 400;
  --font-label: 'Inter', sans-serif;
  --title-size: 72px;
  --title-size-ia: 103px;
  --title-size-ib: 72px;
  --title-size-qa: 72px;
  --title-size-ic: 121px;
  --title-weight: 900;
  --title-case: uppercase;
  --body-size: 12px;
  --label-size: 10px;
  --label-weight: 700;
  --label-case: uppercase;
  --doc-pad: 56px;
  --col-gap: 24px;
  --section-gap: 20px;
  --qr-size: 58px;
  --qr-size-ia: 76px;
  --qr-size-ib: 50px;
  --qr-size-qa: 50px;
  --qr-size-ic: 50px;
  --logo-size: 30px;
  --logo-contact-gap: 14px;
  --hr-weight: 1.5px;
  --label-border: 1.5px;
  --ink-muted:       color-mix(in srgb, var(--ink) 40%, transparent);
  --ink-wash:        color-mix(in srgb, var(--ink) 10%, var(--doc-paper));
  --doc-paper-65:    color-mix(in srgb, var(--doc-paper) 65%, transparent);
  --_adaptive: oklch(from var(--doc-paper) clamp(0, calc((l - 0.5) * -999), 1) 0 0);

  width: 794px;
  min-height: 1122px;
  background: var(--doc-paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: var(--body-weight);
  border-radius: var(--r-lg);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  padding: var(--doc-pad);
  position: relative;
  box-sizing: border-box;
  overflow: visible;
}

/* ── Page Break Markers — no borrar esto se guarda para el futuro ──
   (reserved for future page-number display; not currently rendered)
.page-break-marker { ... }
.page-break-marker::after { content: attr(data-page); ... }
── */


/* ══════════════════════════════════════════════════════════
   PAGE BUILDER — blocks canvas
   ══════════════════════════════════════════════════════════ */

/* ── Blocks canvas ── */
#blocks-canvas {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Base block shell ── */
.doc-block {
  position: relative;
  display: flex;
  flex-direction: column;
  padding-top: 24px;
  border-top: 1px solid transparent;
  transition: border-color 0.15s;
}
.doc-block:hover { border-top-color: var(--ink-muted); }

/* ── Block controls toolbar (centered on top border) ── */
.block-controls {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--doc-paper);
  border-radius: 7px;
  padding: 2px 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
  white-space: nowrap;
}
.doc-block:hover .block-controls { opacity: 1; pointer-events: auto; border: 1px solid var(--ink-muted); }

.block-controls-sep {
  width: 1px;
  height: 14px;
  background: var(--ink-muted);
  margin: 0 3px;
}

.block-drag {
  display: flex;
  align-items: center;
  cursor: grab;
  padding: 2px 3px;
}
.block-drag .material-symbols-outlined { font-size: 14px; }

/* ── Block body (content area) ── */
.block-body { width: 100%; padding: 24px 0 8px 0; }

/* ── Block type label ── */
.block-type-label {
  position: static;
  background: none;
  padding: 0 0 8px;
  margin-bottom: 0;
  border-bottom: var(--label-border) solid var(--ink);
  font-size: var(--label-size);
  font-weight: var(--label-weight);
  letter-spacing: 0.09em;
  text-transform: var(--label-case);
  font-family: var(--font-label);
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
  z-index: auto;
  transition: color 0.15s;
  cursor: text;
  outline: none;
}
.block-type-label:focus { opacity: 0.7; }
.doc-block:hover .block-type-label { color: var(--ink); }
.plabel[contenteditable] { cursor: text; outline: none; }
.plabel[contenteditable]:focus { opacity: 0.7; }


.block-action-btn {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.block-action-btn .material-symbols-outlined { font-size: 14px; }

/* Controls: ink-muted default, ink on hover */
.block-controls .block-drag,
.block-controls .block-action-btn { color: var(--ink-muted); transition: color 0.1s; }
.block-controls .block-drag:hover,
.block-controls .block-action-btn:hover { color: var(--ink); }
.block-action-insert .material-symbols-outlined { font-size: 16px; }
.block-controls .block-tax-btn.active { color: var(--ink); }
.doc-block.drop-above::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--ink);
  pointer-events: none;
  z-index: 5;
}

/* ── Block cols layout ── */
.block-cols {
  display: flex;
  min-height: 60px;
}

/* ── Individual column ── */
.block-col {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
}
.block-col:first-child { padding-left: 0; }
.block-col:last-child  { padding-right: 0; }
/* ── Col controls (top, visible on col hover) ── */
.col-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 16px 2px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.block-col:hover .col-controls { opacity: 1; }
.col-ctrl-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--ink-muted);
  background: var(--doc-paper);
  border-radius: 6px;
  padding: 3px 10px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.12s;
}
.col-ctrl-btn:hover { border-color: var(--ink); color: var(--ink); }
.col-ctrl-btn .material-symbols-outlined { font-size: 13px; }

/* ── Col rows container ── */
.col-rows {
  flex: 1;
  padding: 0;
}

/* ── Individual row (title + body pair) ── */
.col-row {
  position: relative;
  padding: 8px 0 16px;
}

/* ── Row delete button ── */
.col-row-del {
  position: absolute;
  right: 8px;
  top: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.1s;
  padding: 0;
}
.col-row:hover .col-row-del { opacity: 1; }
.col-row-del:hover { color: var(--ink); }
.col-row-del .material-symbols-outlined { font-size: 13px; }

/* ── Row title (consistent with tg-title style) ── */
.col-row-title {
  display: block;
  font-size: var(--block-title-size);
  font-weight: var(--block-title-weight);
  letter-spacing: -0.01em;
  line-height: 1.4;
  font-family: var(--font-block-title);
  color: var(--ink);
  margin: 0 0 6px 0;
}
.col-row-title:empty::before { content: attr(data-ph); color: var(--ink-muted); pointer-events: none; }
.col-row-title:focus { outline: none; box-shadow: none; }

/* ── Row body ── */
.col-row-body {
  display: block;
  font-size: var(--body-size);
  color: var(--ink);
  line-height: 1.65;
  min-height: 18px;
  white-space: pre-wrap;
}
.col-row-body:empty::before { content: attr(data-ph); color: var(--ink-muted); pointer-events: none; }
.col-row-body:focus { outline: none; box-shadow: none; }

/* ── Col add-content button (bottom of column, shown on col hover) ── */
.col-add-btn {
  margin: 4px 0 0;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  transition: color 0.15s;
  flex-shrink: 0;
}
.col-add-btn:hover { color: var(--ink); }

.divider-line {
  display: block;
  width: 100%;
  border: none;
  border-bottom: var(--hr-weight) solid var(--ink);
}

/* ── Signature block ── */
.sig-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}
.sig-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sig-role {
  font-size: var(--block-title-size);
  font-weight: var(--block-title-weight);
  font-family: var(--font-block-title);
  color: var(--ink);
}
.sig-line {
  border-bottom: 1px solid var(--ink);
  height: 40px;
  margin-bottom: 4px;
}
.sig-name,
.sig-date {
  background: none;
  border: none;
  border-bottom: 1px solid var(--ink-muted);
  font-family: inherit;
  font-size: var(--body-size);
  color: var(--ink);
  width: 100%;
  padding: 3px 0;
  outline: none;
}
.sig-name::placeholder,
.sig-date::placeholder { color: var(--ink-muted); }

/* ── Task block specifics ── */
[data-btype="tasks"] .task-group { margin: 0; padding: 0; }
[data-btype="tasks"] .task-group + .task-group { margin-top: 4px; padding-top: 0; }
[data-btype="tasks"] .tg-drag { display: flex; }
.tasks-groups-container > .drop-indicator {
  height: 1px;
  background: var(--ink);
  margin: 0;
  padding: 0;
  pointer-events: none;
}
.drop-indicator-abs {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--ink);
  pointer-events: none;
  z-index: 10;
}
.tasks-add-group-btn {
  margin: 8px 0 12px auto;
  background: none;
  border: 1px solid var(--ink);
  border-radius: 20px;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px;
  transition: all 0.15s;
  align-self: flex-end;
}
.tasks-add-group-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--ink-wash);
}

/* ── Banking block ── */
.banking-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 12px;
}
.banking-notice .material-symbols-outlined { font-size: 15px; }
@media print { .banking-notice { display: none !important; } }
.banking-notice a { color: var(--primary); text-decoration: none; }
.banking-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 32px;
}
.banking-col {
  display: flex;
  flex-direction: column;
}
.banking-col input {
  width: 100%;
  font-size: var(--body-size);
  border: none;
  background: none;
  padding: 4px 0;
  color: var(--ink);
  font-family: inherit;
  outline: none;
}


/* ── Canvas empty state ── */
.canvas-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  gap: 10px;
  text-align: center;
  border: 1px dashed var(--ink-muted);
  border-radius: var(--r-lg);
  margin-top: 8px;
  margin-bottom: 40px;
}
.canvas-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ink-wash);
  border: 1px solid var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.canvas-empty-icon .material-symbols-outlined { font-size: 24px; color: var(--ink-muted); }
.canvas-empty-title { font-size: 17px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.canvas-empty-sub   { font-size: 13px; color: var(--ink-muted); margin-bottom: 8px; }
.canvas-empty-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.canvas-empty-btn,
.canvas-empty-tpl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  min-width: 164px;
  background: var(--ink-wash);
  color: var(--ink);
  border: 1px solid var(--ink-muted);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.canvas-empty-btn:hover,
.canvas-empty-tpl-btn:hover { background: var(--ink); color: var(--doc-paper); }

/* ── Quote summary pill ── */
.totals-quote-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: 1px solid var(--ink-muted);
  border-radius: 8px;
  padding: 12px 20px;
  margin-bottom: 2px;
  width: 100%;
}
.totals-quote-label { font-size: 13px; font-weight: 500; color: var(--ink); }
.totals-quote-value { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }

/* ── Canvas add-zone (dashed bottom strip) ── */
.canvas-add-zone {
  margin: 14px 0 0;
  border: 1px dashed var(--ink-muted);
  border-radius: 8px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.canvas-add-zone:hover {
  background: var(--ink-wash);
  border-color: var(--ink);
}
.canvas-add-zone:hover .canvas-add-zone-btn { color: var(--ink); }
.canvas-add-zone-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
  padding: 0;
  pointer-events: none;
}

/* ── Block picker modal ── */
.block-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.22);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.block-picker-card {
  background: var(--white);
  border-radius: var(--r-lg);
  width: 740px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
}
.block-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.block-picker-header h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.block-picker-close {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--tsec);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}
.block-picker-close:hover { background: var(--bg); color: var(--text); }

/* ── Template picker ── */
.template-picker-modal {
  background: var(--white);
  border-radius: var(--r-lg);
  width: 600px;
  max-width: 92vw;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
}
.template-picker-modal .block-picker-header {
  margin-bottom: 20px;
}
.template-picker-modal .block-picker-header span {
  font-size: 15px;
  font-weight: 600;
}
.template-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-bottom: 8px;
}
.template-picker-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.template-picker-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.tpl-thumb {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tpl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tpl-thumb .material-symbols-outlined { font-size: 36px; color: var(--tph); }
.tpl-name {
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tpl-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  background: color-mix(in srgb, var(--white) 85%, transparent);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  color: var(--tsec);
}
.tpl-delete .material-symbols-outlined { font-size: 14px; }
.template-picker-card:hover .tpl-delete { opacity: 1; }
.template-picker-empty {
  text-align: center;
  padding: 30px 20px;
  color: var(--tsec);
  font-size: 13px;
  line-height: 1.6;
}

.block-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.block-picker-sep {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.block-type-tile {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 10px 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  background: none;
  font-family: inherit;
  color: var(--text);
}
.block-type-tile:hover {
  border-color: var(--primary);
  background: var(--primary-pale);
}
.block-type-tile .material-symbols-outlined {
  font-size: 22px;
  color: var(--tsec);
  margin-bottom: 7px;
  display: block;
}
.block-type-tile:hover .material-symbols-outlined { color: var(--primary); }
.block-type-tile-label { font-size: 12.5px; font-weight: 600; display: block; margin-bottom: 3px; }
.block-type-tile-desc  { font-size: 11px; color: var(--tsec); line-height: 1.4; }

/* ── Contenteditable ── */
[contenteditable] { outline: none; cursor: text; }
[contenteditable]:empty::before {
  content: attr(data-ph);
  color: var(--ink);
  pointer-events: none;
}
/* No focus ring — write directly on the document, not in a form */
[contenteditable]:focus { outline: none; box-shadow: none; }

/* ── Doc Header Area (wrapper that pads header/divider/from-to) ── */
.doc-header-area {
  padding: 0;
}

/* ── Doc Header ── */
.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}
.doc-from { display: flex; flex-direction: column; gap: 4px; max-width: 240px; }
.emitter-name  { font-size: 16px; font-weight: 700; display: block; letter-spacing: -0.01em; margin-bottom: 4px; }
.emitter-detail { font-size: 12.5px; display: block; }

.doc-title-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
}
.doc-type-label  { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; display: block; }
.doc-ref-line    { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.doc-ref-line span:first-child { font-size: 12px; }
.doc-ref-input   { font-weight: 600; min-width: 30px; font-size: 13px; color: var(--text); }
.doc-date        { font-size: 12.5px; display: block; }
.doc-project     { font-size: 12.5px; display: block; margin-top: 2px; }
.doc-logo        { max-height: 52px; max-width: 160px; margin-bottom: 10px; object-fit: contain; }

.doc-divider { border: none; border-top: var(--hr-weight) solid var(--ink); margin: var(--section-gap) 0; }

/* ── Parties ── */
.parties { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--col-gap); }
.parties--no-bank { grid-template-columns: 1fr 1fr; }
.parties--no-bank > div:first-child { display: none; }

.bank-bic-line { display: flex; gap: 0.4em; align-items: baseline; }
.parties > div { display: flex; flex-direction: column; gap: 2px; position: relative; }
.plabel     { font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: 0.08em; text-transform: var(--label-case); font-family: var(--font-label); margin-bottom: 6px; display: block; }
.pname      { font-size: var(--block-title-size); font-weight: var(--block-title-weight); font-family: var(--font-block-title); display: block; margin-bottom: 2px; }
.pdet       { font-size: var(--body-size); font-family: var(--font-body); display: block; line-height: 1.55; }
.bank-iban  { font-size: var(--block-title-size); font-weight: var(--block-title-weight); font-family: var(--font-block-title); display: block; margin-bottom: 2px; }
.parties-cityrow { display: flex; gap: 0.3em; flex-wrap: wrap; }
.parties-cityrow .pdet { display: inline; }

/* ── Template Header Layouts ────────────────────────────── */

/* Shared top row */
.doc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

/* Big title (INVOICE / QUOTATION) */
.doc-title {
  font-size: var(--title-size);
  font-weight: var(--title-weight);
  letter-spacing: -3px;
  line-height: 1;
  font-family: var(--font-title);
  text-transform: var(--title-case);
  margin-top: -10px;
  margin-left: -0.05em;
  display: block;
}

/* Logo — left aligned */
.tpl-logo {
  display: block;
  height: var(--logo-size);
  width: auto;
  max-width: 260px;
  object-fit: contain;
  object-position: left top;
  transform-origin: top left;
  align-self: flex-start;
  color: var(--ink);
}
/* Logo — right aligned */
.tpl-logo-r {
  display: block;
  height: var(--logo-size);
  width: auto;
  max-width: 260px;
  object-fit: contain;
  object-position: right;
  margin-left: auto;
  color: var(--ink);
}
/* CSS mask fallback for CORS logos */
[data-logo-aspect].tpl-logo  { background-color: var(--ink); -webkit-mask: var(--logo-mask) no-repeat left top / auto 100%; mask: var(--logo-mask) no-repeat left top / auto 100%; }
[data-logo-aspect].tpl-logo-r { background-color: var(--ink); -webkit-mask: var(--logo-mask) no-repeat right top / auto 100%; mask: var(--logo-mask) no-repeat right top / auto 100%; margin-left: auto; }

/* Meta text */
.tpl-meta-r    { display: flex; flex-direction: column; gap: 1px; text-align: right; }
.tpl-meta-l    { display: flex; flex-direction: column; gap: 1px; }
.tpl-meta-proj { font-size: var(--block-title-size); font-weight: var(--block-title-weight); font-family: var(--font-block-title); display: block; }
.tpl-meta-sub  { font-size: var(--body-size); font-family: var(--font-body); display: block; }

/* Emitter block (Nord / QUO-A) */
.tpl-emitter { display: flex; flex-direction: column; align-items: flex-start; }
.tpl-ename   { font-size: 13px; font-weight: 700; margin: 8px 0 2px; font-family: var(--font-body); display: block; }
.tpl-edet    { font-size: var(--body-size); font-family: var(--font-body); display: block; }

/* Atlas: logo + inline contact */
.tpl-logo-contact      { display: flex; align-items: flex-start; gap: var(--logo-contact-gap); margin-top: 14px; }
.tpl-logo-contact-info { display: flex; flex-direction: column; gap: 1px; }
.tpl-ct                { font-size: var(--body-size); font-family: var(--font-body); display: block; }

/* Nord / QUO-A: right title block */
.tpl-title-block-r { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.tpl-ib-top .doc-title { font-size: var(--title-size-ib); }
.tpl-title-block-r .doc-title { margin-top: calc(var(--title-size-ib) * -0.15); }
.tpl-qa-top .doc-title { font-size: var(--title-size-qa); }
.tpl-meta-qr-row   { display: flex; align-items: flex-start; gap: 14px; }
.tpl-meta-qr-row .tpl-meta-r { align-self: flex-start; margin-top: -5px; flex: 1; }
.tpl-qr-meta-row .tpl-meta-l  { align-self: flex-start; margin-top: -5px; flex: 1; }

/* QUO-A: QR + meta left row */
.tpl-qr-meta-row { display: flex; align-items: flex-start; gap: 14px; margin-top: 14px; }

/* Atlas (ia): 2×2 grid, QR in header */
.tpl-ia-grid { display: grid; grid-template-columns: 1fr auto; align-items: start; margin-bottom: 28px; }
.tpl-ia-header { grid-column: 1 / -1; display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.tpl-ia-header .doc-title { flex: 1; min-width: 0; align-self: flex-end; font-size: var(--title-size-ia, var(--title-size)); margin-bottom: calc(var(--title-size-ia, var(--title-size)) * -0.14); margin-left: -0.07em; }
.tpl-ia-header .doc-qr { flex-shrink: 0; align-self: flex-end; width: var(--qr-size-ia); max-width: var(--qr-size-ia); }
.tpl-ia-grid .tpl-logo-contact { margin-top: 14px; }
.tpl-ia-grid .tpl-logo { margin-top: 4px; }
.tpl-ia-right { display: flex; align-items: flex-end; gap: 14px; justify-self: end; margin-top: 14px; }

/* Apex (ic): full-width title, QR alongside meta */
.tpl-ic-grid { display: grid; grid-template-columns: 1fr auto; align-items: start; margin-bottom: 28px; }
.tpl-ic-header { grid-column: 1 / -1; display: flex; align-items: flex-end; gap: 14px; }
.tpl-ic-header .doc-title { flex: 1; min-width: 0; align-self: flex-end; font-size: var(--title-size-ic, var(--title-size)); margin-bottom: calc(var(--title-size-ic, var(--title-size)) * -0.14); margin-left: -0.07em; }
.tpl-ic-grid .tpl-logo-contact { margin-top: 14px; }
.tpl-ic-grid .tpl-logo { margin-top: 4px; }
.tpl-ic-right { display: flex; align-items: flex-start; gap: 14px; justify-self: end; margin-top: 14px; }
.tpl-ic-right .doc-qr { margin-top: 5px; width: var(--qr-size-ic); max-width: var(--qr-size-ic); }
.tpl-meta-qr-row .doc-qr { width: var(--qr-size-ib); max-width: var(--qr-size-ib); }
.tpl-qr-meta-row .doc-qr { width: var(--qr-size-qa); max-width: var(--qr-size-qa); }

/* QR containers */
.tpl-qr-s, .tpl-qr-m { display: block; }

/* ── To-section client display ── */
.to-client-display {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background 0.12s;
}
.to-client-summary span { display: block; }

/* ── Client Picker Modal ── */
.cp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cp-overlay.hidden { display: none; }
.cp-modal {
  background: var(--white);
  border-radius: var(--r-lg);
  width: 440px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
  overflow: hidden;
}
.cp-head {
  display: flex;
  align-items: center;
  padding: 10px 10px 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 6px;
  flex-shrink: 0;
}
.cp-head-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.cp-search {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  background: none;
  color: var(--text);
}
.cp-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tsec);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: var(--r-sm);
  transition: background 0.1s;
}
.cp-close:hover { background: var(--bg); color: var(--text); }
.cp-close .material-symbols-outlined { font-size: 18px; }
.cp-list {
  overflow-y: auto;
  flex-shrink: 0;
  max-height: 220px;
  padding: 4px 0;
}
.cp-item {
  display: flex;
  align-items: center;
  padding: 8px 12px 8px 16px;
  cursor: pointer;
  gap: 8px;
  transition: background 0.1s;
}
.cp-item:hover { background: var(--bg); }
.cp-item-body { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.cp-item-name { font-size: 13px; font-weight: 600; color: var(--text); }
.cp-item-sub  { font-size: 12px; color: var(--tsec); }
.cp-item-edit {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tsec);
  opacity: 0;
  padding: 3px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  transition: opacity 0.1s, background 0.1s;
  flex-shrink: 0;
}
.cp-item:hover .cp-item-edit { opacity: 1; }
.cp-item-edit:hover { background: var(--border); color: var(--text); }
.cp-item-edit .material-symbols-outlined { font-size: 14px; }
.cp-empty { padding: 16px; text-align: center; color: var(--tsec); font-size: 13px; }
.cp-new-btn {
  margin: 8px 12px;
  padding: 8px 12px;
  border: 1.5px dashed var(--border-s);
  border-radius: var(--r-md);
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--tsec);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.1s, color 0.1s;
  flex-shrink: 0;
}
.cp-new-btn:hover { border-color: var(--text); color: var(--text); }
.cp-new-btn .material-symbols-outlined { font-size: 16px; }
.cp-form {
  border-top: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}
.cp-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.cp-field { display: flex; flex-direction: column; gap: 4px; }
.cp-field-full { grid-column: 1 / -1; }
.cp-field label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--tsec);
  font-family: var(--font-label);
}
.cp-field input {
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  padding: 4px 0;
  outline: none;
  transition: border-color 0.1s;
}
.cp-field input:focus { border-bottom-color: var(--text); }
.cp-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
@media print {
  .cp-overlay { display: none !important; }
  .to-client-add { display: none !important; }
}

.th-row {
  display: flex;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-s);
}
.th-drag-sp { width: 0; flex-shrink: 0; }
.th-desc    { flex: 1; font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: 0.1em; text-transform: var(--label-case); font-family: var(--font-label); }
.th-right   { flex-shrink: 0; width: auto; display: flex; align-items: center; padding-left: 32px; }
.th-del-sp  { width: 0; flex-shrink: 0; }
.hours-hidden .titem-times,
.hours-hidden .th-right { display: none !important; }

/* Task Group */
.task-group {
  border-top: none;
  border-bottom: none;
  padding: 12px 0 8px;
  position: relative;
}
.tgrp-row {
  display: flex;
  align-items: center;
  margin: 6px 0;
  padding: 0;
}
.tg-drag {
  width: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  cursor: grab;
  user-select: none;
  touch-action: none;
  padding-right: 8px;
  transition: color 0.1s;
}
.tg-drag .material-symbols-outlined { font-size: 14px; }
.tg-drag:hover { color: var(--ink); }
.tg-inner  { flex: 1; display: flex; align-items: center; gap: 12px; }
.tg-title  { font-size: var(--block-title-size); font-weight: var(--block-title-weight); flex: 1; min-width: 40px; letter-spacing: -0.01em; font-family: var(--font-block-title); }
.tg-time   { font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.tg-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 0;
  padding: 4px 0;
  border-top: 1.5px solid var(--ink);
}
.tg-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.tg-summary-label { font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: 0.06em; text-transform: var(--label-case); font-family: var(--font-label); }
.tg-summary-time  { font-size: 12px; }
.tg-summary-amt   { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tg-amt    { font-size: 14px; font-weight: 700; white-space: nowrap; flex-shrink: 0; width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
.tg-del {
  width: auto;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-muted);
  transition: color 0.15s;
  padding-left: 14px;
  border-radius: var(--r-sm);
}
.tg-del .material-symbols-outlined { font-size: 18px; }
.tg-del:hover { color: var(--ink); }
.tg-items  { margin-top: 2px; }


/* Task Item */
.task-item {
  display: flex;
  align-items: center;
  padding: 6px 0;
  position: relative;
  border-top: 1px solid var(--ink-muted);
}
.titem-drag-sp { width: auto; flex-shrink: 0; padding-right: 8px; }
.titem-drag-sp .material-symbols-outlined { font-size: 14px; cursor: grab; display: block; color: var(--ink-muted); }
.titem-drag-sp:hover .material-symbols-outlined { color: var(--ink); }
.titem-l       { flex: 1; display: flex; align-items: center; }
.titem-name    { font-size: var(--body-size); min-width: 60px; flex: 1; display: block; }
.titem-right   { flex-shrink: 0; width: auto; display: flex; align-items: center; padding-left: 32px; }
.titem-times   { display: flex; align-items: center; gap: 4px; flex: 1; margin: 0 16px 0 8px; }

/* ── Per-line unit selector + qty×price ──────────────────── */
.titem-unit {
  border: 1px solid var(--ink-muted);
  background: var(--doc-paper);
  font-family: 'Inter', sans-serif;
  font-size: 11px; font-weight: 500;
  color: var(--ink-muted);
  border-radius: var(--r-sm);
  padding: 2px 4px;
  margin-right: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.titem-qty { display: flex; align-items: center; gap: 4px; flex: 1; }
.titem-qty-input, .titem-price-input {
  width: 46px;
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 500;
  color: var(--text);
  text-align: right;
  padding: 2px 3px;
  border-radius: 4px;
  transition: background 0.12s;
  -moz-appearance: textfield;
}
.titem-qty-input::-webkit-outer-spin-button,
.titem-qty-input::-webkit-inner-spin-button,
.titem-price-input::-webkit-outer-spin-button,
.titem-price-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.titem-qty-input:hover, .titem-price-input:hover { background: var(--ink-wash); }
.titem-qty-input:focus, .titem-price-input:focus { background: var(--ink-wash); outline: 1.5px solid var(--ink-muted); }
.titem-x, .titem-cur { font-size: 11px; color: var(--ink-muted); white-space: nowrap; }

/* Flat line: amount edited in-situ (doc-style, not a form field).
   Inherits .titem-amt look/color; focus uses the same token as the hour inputs. */
.titem-amt-cur { flex-shrink: 0; font-size: 13px; }
.titem-amt-edit {
  width: auto;
  min-width: 16px;
  cursor: text;
  outline: none;
  border-radius: 4px;
  padding: 2px 3px;
}
.titem-amt-edit:focus { background: var(--bg); }
.titem-amt-edit:empty::before { content: attr(data-ph); }

.tf { display: flex; align-items: center; gap: 0; }
.tf input {
  width: 22px;
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  text-align: right;
  padding: 2px 1px;
  border-radius: 4px;
  transition: outline 0.12s;
  -moz-appearance: textfield;
  flex-shrink: 0;
}
.tf input::-webkit-outer-spin-button,
.tf input::-webkit-inner-spin-button { -webkit-appearance: none; }
.tf input::placeholder { color: var(--ink-muted); }
.tf input:hover  { background: none; }
.tf input:focus  { background: none; outline: none; }
.tf label { font-size: 11px; padding-left: 2px; white-space: nowrap; color: var(--ink-muted); }

.titem-amt {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
  width: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.titem-del {
  width: auto;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-muted);
  transition: color 0.15s;
  padding-left: 14px;
  border-radius: var(--r-sm);
}
.titem-del .material-symbols-outlined { font-size: 18px; }
.titem-del:hover { color: var(--ink); }

/* Add line / add task buttons */
.tg-additem {
  margin: 6px 0 0;
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0 2px;
  transition: color 0.15s;
}
.tg-additem:hover { color: var(--ink); }

.add-divider-wrap { margin-top: 14px; }
.add-group-btn {
  background: none;
  border: 1px solid var(--border-s);
  border-radius: 20px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  transition: all 0.15s;
}
.add-group-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--bg); }

/* Drag ghost & drop line */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9000;
  background: var(--white);
  border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  opacity: 0.92;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}
.drop-indicator {
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  margin: 2px 0;
  pointer-events: none;
}
/* ── Totals ── */
.totals-inner  { width: 100%; }
.totals-row    { display: flex; justify-content: space-between; font-size: 13px; }
.totals-row.fin {
  padding-top: 10px;
  font-size: 14px;
  font-weight: 700;
}
.totals-row.note { font-size: 11px; font-style: italic; justify-content: flex-start; }
.totals-inner .tax-row { display: block; padding: 5px 0; border-bottom: none; gap: 0; }
.totals-value { font-variant-numeric: tabular-nums; }

/* Neto callout */
.neto-callout {
  margin-top: 20px;
  background: var(--ink-wash);
  border: 1.5px solid var(--ink-muted);
  border-radius: var(--r-md);
  padding: 14px 20px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.neto-callout-label { font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: 0.08em; text-transform: var(--label-case); font-family: var(--font-label); color: var(--ink-muted); }
.neto-callout-note  { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
.neto-callout-value { font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }

.block-tax-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 10px 0;
}
.block-tax-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-label);
  color: var(--ink-muted);
}

/* ── Invoice Footer ── */
.ftxt         { font-size: var(--body-size); line-height: 1.65; min-height: 28px; }

/* ── Quote Clauses ── */
/*
  Shared skeleton for both 1-col and 2-col:
  [drag 26px]  [content flex:1]  [col-btn]  [trash 30px]
  Both .clause-block and .clause-pair use .clause-drag and .clause-del.
*/

/* Pre-task clause blocks */
.pre-clause-block {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.pre-clause-inner { flex: 1; }

/* Outer row — shared border and padding */
.clause-block,
.clause-pair {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding: 12px 0 8px;
}

/* Drag handle — identical in both */
.clause-drag {
  width: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: color 0.1s;
}
.clause-drag .material-symbols-outlined { font-size: 16px; }
.clause-drag:hover { color: var(--ink); }

/* Col-toggle button — identical in both */
.clause-col-btn {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border: 1px solid var(--ink-muted);
  border-radius: var(--r-sm);
  background: var(--doc-paper);
  color: var(--ink-muted);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: color 0.1s, border-color 0.1s;
}
.clause-col-btn:hover { color: var(--ink); border-color: var(--ink); }

/* Delete button — identical in both */
.clause-del {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-muted);
  transition: color 0.15s;
  padding: 0;
  border-radius: var(--r-sm);
}
.clause-del .material-symbols-outlined { font-size: 18px; }
.clause-del:hover { color: var(--ink); }

/* ── 1-col content ── */
.clause-block-inner {
  flex: 1;
  min-width: 0;
}
.clause-lbl {
  display: block;
  font-size: var(--block-title-size);
  font-weight: var(--block-title-weight);
  letter-spacing: -0.01em;
  font-family: var(--font-block-title);
  color: var(--ink);
  margin-bottom: 6px;
  flex: 1;
  min-width: 40px;
}
.clause-txt {
  font-size: 13px;
  min-width: 60px;
  flex: 1;
  display: block;
  color: var(--ink);
  line-height: 1.65;
  min-height: 36px;
}

/* ── 2-col content ── */
.clause-pair-cols {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0;
}
.clause-col {
  flex: 1;
  min-width: 0;
  padding-right: 16px;
}
.clause-col + .clause-col {
  border-left: 1px solid var(--border);
  padding-left: 16px;
  padding-right: 0;
}

.add-clause-btn {
  background: none;
  border: 1px solid var(--border-s);
  border-radius: 20px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  transition: all 0.15s;
  margin-top: 14px;
}
.add-clause-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--bg); }

/* Legacy clause styles kept for compat */
.clause-item { overflow: hidden; }
.clause-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.layout-toggle-btn { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px 8px; font-size: 11px; color: var(--tsec); cursor: pointer; }
.layout-toggle-btn:hover { background: var(--bg); color: var(--text); }
.clause-body-1col { padding: 10px 12px; }
.clause-body-text { font-size: var(--body-size); line-height: 1.5; }
.clause-label-input { flex: 1; font-size: var(--label-size); font-weight: var(--label-weight); text-transform: var(--label-case); letter-spacing: 0.08em; font-family: var(--font-label); }

/* ── Invoice Type Bar (topbar) ── */
.comp-inv-type-top {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  padding: 3px;
}
.comp-inv-type-top.hidden { display: none; }
.inv-type-pill {
  padding: 5px 12px;
  border: none;
  border-radius: var(--r-btn);
  background: none;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--tsec);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.inv-type-pill.active {
  background: var(--white);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.inv-type-pill:hover:not(.active) { background: rgba(255,255,255,0.6); color: var(--text); }

/* ── Print ── */
@media print {
  @page { margin: 0; }
  body {
    margin: 0 !important; padding: 0 !important;
    background: var(--doc-paper, #fff) !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .sidebar, .mobile-nav, .ai-panel, .ai-toggle,
  .comp-topbar, .comp-ratebar, .comp-hours-hint,
  .neto-callout,
  .tg-drag, .tg-del, .tg-additem, .add-divider-wrap,
  .titem-del, .clause-drag, .clause-del, .clause-col-btn, .clause-actions,
  .block-controls, .col-controls, .col-add-btn, .col-row-del,
  .canvas-add-zone, .canvas-empty-state, .block-picker-overlay,
  .tasks-add-group-btn, .group-actions, .line-actions, .icon-btn,
  .neto-callout-edit, .block-tax-row, .comp-add-btns, .client-autocomplete, .inv-type-bar,
  button,
  #toast, .side-panel, .overlay-fullscreen { display: none !important; }
  .app-shell   { display: block !important; height: auto !important; }
  .main-content { height: auto !important; overflow: visible !important; }
  .comp-col { display: block !important; height: auto !important; }
  #view-compositor { display: block !important; height: auto !important; overflow: visible !important; }
  .comp-document-area {
    padding: 0 !important; margin: 0 !important;
    height: auto !important; min-height: 0 !important;
    overflow: visible !important; display: block !important;
    background: var(--doc-paper, #fff) !important;
  }
  .pages-column { gap: 0 !important; transform: none !important; display: block !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }
  .document-card,
  .doc-page {
    box-shadow: none !important;
    border-radius: 0 !important;
    width: 794px !important;
    max-width: 794px !important;
    min-height: 0 !important;
    padding: var(--doc-pad) !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    background: var(--doc-paper, #fff) !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }
  /* Blocks flow naturally — browser/Puppeteer creates pages on overflow */
  .doc-block { page-break-inside: avoid; break-inside: avoid; }
  .task-group, .task-item, .doc-block { overflow: visible; }

  /* Prevent blocks from splitting across PDF pages */
  .doc-block, .task-group, .totals-block, .neto-callout { page-break-inside: avoid; break-inside: avoid; }

  .titem-drag-sp, .th-drag-sp, .th-del-sp { display: none !important; }
  .titem-times { display: none !important; }
  .tg-amt { display: none !important; }
  .tg-summary { border-bottom: none; }
  .th-right, .titem-right { padding-left: 0 !important; }
  .th-tiempo { text-align: left; }
  .titem-times { flex-direction: column; align-items: flex-start; gap: 2px; }
  .tf {
    display: flex;
    flex-direction: row;
    align-items: baseline;
  }
  .tf input {
    width: 36px;
    min-width: 36px;
    text-align: right;
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    flex-shrink: 0;
  }
  .tf label {
    min-width: 52px;
    text-align: left;
    font-size: 13px;
    padding-left: 6px;
  }
}

/* ─── PDF Measurement Mode ──────────────────────────────── */
/* Applied briefly during repaginate() to measure PDF-equivalent block heights.
   Hides in-flow editor-only elements so block heights match the PDF. */
.pdf-measure .tg-additem,
.pdf-measure .tasks-add-group-btn,
.pdf-measure .col-add-btn { display: none !important; }

/* ─── Preview Mode ──────────────────────────────────────── */
.preview-mode .sidebar,
.preview-mode .comp-topbar,
.preview-mode .comp-ratebar,
.preview-mode .add-divider-wrap,
.preview-mode .tg-drag,
.preview-mode .titem-drag-sp,
.preview-mode .th-drag-sp,
.preview-mode .th-del-sp,
.preview-mode .group-actions,
.preview-mode .line-actions,
.preview-mode .icon-btn,
.preview-mode .neto-callout-edit,
.preview-mode .comp-add-btns,
.preview-mode .client-autocomplete,
.preview-mode .inv-type-bar,
.preview-mode button { display: none !important; }

.preview-mode .app-shell { display: flex; height: 100vh; }
.preview-mode .main-content { height: 100vh; overflow: hidden; }
.preview-mode #view-compositor { overflow: visible !important; }
.preview-mode .comp-document-area {
  background: var(--bg);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  overflow-y: auto;
}
.preview-mode .document-card,
.preview-mode .doc-page { max-width: 760px; width: 100%; }
.preview-mode [contenteditable] { cursor: default; outline: none; }
.preview-mode [contenteditable]:focus { box-shadow: none; }

/* ── Timer ── */
.timer-area {
  display: flex; align-items: center; gap: 10px;
  background: var(--text);
  border-radius: 999px;
  padding: 0 5px 0 12px;
  height: 34px;
}
.timer-display {
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  color: var(--white);
  min-width: 62px;
}
.timer-divider {
  width: 1px; height: 14px;
  background: var(--doc-paper-65);
  flex-shrink: 0;
}
.timer-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green-announce-border);
  flex-shrink: 0;
  transition: opacity 0.3s;
}
.timer-dot.pulsing { animation: timer-pulse 1.4s ease-in-out infinite; }
@keyframes timer-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* toggle rec/pause */
.timer-rec-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
  color: var(--doc-paper-65);
  text-transform: uppercase;
}
.timer-toggle {
  position: relative;
  width: 44px; height: 24px;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.25s ease;
  user-select: none;
}
.timer-toggle.is-running { background: var(--green-announce-border); }
.timer-toggle-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: left 0.25s ease;
  pointer-events: none;
}
.timer-toggle.is-running .timer-toggle-knob { left: 22px; }

/* ── Per-item timer pill ── */
.item-timer-pill {
  display: flex; align-items: center; gap: 7px;
  background: var(--ink);
  border-radius: 999px;
  padding: 0 4px 0 10px;
  height: 26px;
  flex-shrink: 0;
  margin: 0 16px 0 8px;
}
.item-timer-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green-announce-border);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.3s;
}
.item-timer-dot.pulsing {
  opacity: 1;
  animation: timer-pulse 1.4s ease-in-out infinite;
}
.item-timer-display {
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4px;
  color: var(--doc-paper-65);
  min-width: 52px;
}
.item-timer-pill:has(.item-timer-toggle.is-running) .item-timer-display { color: var(--doc-paper); }
.item-timer-toggle {
  position: relative;
  width: 36px; height: 20px;
  background: var(--doc-paper);
  color: var(--doc-paper);
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.25s ease;
}
.item-timer-toggle.is-running { background: var(--green-announce-border); }
.item-timer-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--ink);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: left 0.25s ease;
  pointer-events: none;
}
.item-timer-toggle.is-running .item-timer-knob { left: 18px; }

/* ── Services catalog popover ── */
.tasks-block-footer { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin: 8px 0 12px; }
.tasks-block-footer .tasks-add-group-btn { margin: 0; }

/* ── Tasks block — embedded summary ─────────────────────── */
.tasks-summary-wrap {
  border-top: 1px solid var(--ink-muted);
  margin-top: 16px;
}
.tasks-summary-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 10px 0;
}
.tasks-summary-hdr-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tsec);
}
.catalog-popover {
  position: fixed;
  z-index: 9999;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  min-width: 220px;
  max-width: 320px;
  overflow: hidden;
  padding: 4px 0;
}
.catalog-popover-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  background: none;
  border: none;
  padding: 8px 14px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  text-align: left;
  transition: background 0.1s;
}
.catalog-popover-item:hover { background: var(--bg); }
.catalog-item-name { font-weight: 500; color: var(--text); }
.catalog-item-rate { color: var(--tsec); font-size: 11px; font-variant-numeric: tabular-nums; }
.catalog-popover-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--tsec);
}
.catalog-popover-empty a { color: var(--green-strong); text-decoration: none; }
.catalog-popover-empty a:hover { text-decoration: underline; }

/* ── Compositor column wrapper (keeps topbar+ratebar+doc in one flex child) ── */
.comp-col { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── Design Panel ── */
.dp-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 340px;
  background: var(--white);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 150;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}
.dp-panel.open { transform: translateX(0); }
#main-content { transition: margin-right 0.25s ease; }
#main-content.dp-open { margin-right: 340px; }

/* ── Design Panel inner controls ── */
.dp-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
}
.dp-sec-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tsec);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-s);
}

/* toggle group */
.dp-toggle {
  display: flex;
  background: var(--ink-wash);
  border: solid 1px var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.dp-tgl {
  flex: 1;
  padding: 5px 0;
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--tsec);
  background: none;
}
.dp-tgl.on { background: var(--white); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* slider row */
.dp-sl-row { display: flex; flex-direction: column; gap: 4px; }
.dp-sl-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text); }
.dp-sl-label span { font-weight: 700; font-size: 11px; color: var(--tsec); }
.dp-sl-row input[type=range] { width: 100%; accent-color: var(--text); cursor: pointer; }

/* switch toggle */
.dp-uc-row { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--text); }
.dp-switch { position: relative; width: 34px; height: 18px; flex-shrink: 0; }
.dp-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.dp-sw-track { position: absolute; inset: 0; background: var(--border); border-radius: 18px; cursor: pointer; transition: .2s; }
.dp-sw-track:before { content: ''; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: var(--white); border-radius: 50%; transition: .2s; }
.dp-switch input:checked + .dp-sw-track { background: var(--text); }
.dp-switch input:checked + .dp-sw-track:before { transform: translateX(16px); }

.block-tax-row .dp-sw-track { background: var(--ink-muted); }
.block-tax-row .dp-sw-track:before { background: var(--doc-paper); }
.block-tax-row .dp-switch input:checked + .dp-sw-track { background: var(--ink); }

.doc-qr { overflow: hidden; width: var(--qr-size, 58px); transition: opacity 0.25s ease; }
.tpl-meta-qr-row, .tpl-qr-meta-row, .tpl-ic-right { transition: gap 0.3s ease; }
.document-card.qr-toggling .doc-qr { transition: opacity 0.25s ease, max-width 0.3s ease; }
.document-card.qr-hidden .doc-qr { opacity: 0; max-width: 0; pointer-events: none; }
.document-card.qr-hidden .tpl-meta-qr-row,
.document-card.qr-hidden .tpl-qr-meta-row,
.document-card.qr-hidden .tpl-ia-right,
.document-card.qr-hidden .tpl-ic-right { gap: 0; }

.dp-note { font-size: 11px; color: var(--tsec); }
#dp-qr-controls, #dp-qr-detail { display: flex; flex-direction: column; gap: 12px; }
.dp-url-input { --bg: #f4f4f4; width: 100%; box-sizing: border-box; padding: 5px 8px; font-size: 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); outline: none; }
.dp-url-input:focus { border-color: var(--text); }

/* color row */
.dp-color-row { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--text); }
.dp-cpk-swatch { width: 32px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.1); cursor: pointer; flex-shrink: 0; }

/* HSV color picker popover */
.dp-cpk {
  position: fixed;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.13);
  padding: 14px;
  width: 248px;
  z-index: 500;
  display: none;
  flex-direction: column;
  gap: 12px;
}
.dp-cpk.open { display: flex; }
.dp-cpk-sv-wrap { position: relative; border-radius: 10px; overflow: hidden; cursor: crosshair; height: 140px; flex-shrink: 0; }
.dp-cpk-sv { display: block; width: 100%; height: 100%; }
.dp-cpk-sv-thumb { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--white); box-shadow: 0 0 0 1px rgba(0,0,0,0.25), 0 2px 6px rgba(0,0,0,0.3); transform: translate(-50%,-50%); pointer-events: none; }
.dp-cpk-hue-wrap { position: relative; height: 18px; flex-shrink: 0; }
.dp-cpk-hue { position: absolute; top: 50%; left: 0; right: 0; height: 12px; transform: translateY(-50%); border-radius: 6px; background: linear-gradient(to right,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00); cursor: pointer; }
.dp-cpk-hue-thumb { position: absolute; top: 50%; transform: translate(-50%,-50%); width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--white); box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 2px 4px rgba(0,0,0,0.2); pointer-events: none; }
.dp-cpk-input-row { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 50px; padding: 7px 12px; }
.dp-cpk-preview { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.08); }
.dp-cpk-hash { font-size: 14px; color: var(--tph); font-weight: 500; }
.dp-cpk-hex { flex: 1; border: none; background: none; outline: none; font-size: 14px; font-weight: 600; color: var(--text); text-transform: uppercase; min-width: 0; }
.dp-cpk-copy { width: 28px; height: 28px; border: 1.5px solid var(--border); border-radius: 7px; background: var(--white); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--tsec); flex-shrink: 0; }

/* Force ALL document text to use the ink design token — no exceptions */
.doc-header-area, .doc-header-area * { color: var(--ink); }
.doc-header-area .tg-additem { margin: 0; padding: 2px 0; color: var(--ink-muted); }
.doc-header-area .tg-additem:hover { color: var(--ink); }
.block-body input, .block-body label, .block-body select,
.block-body button, .block-body textarea { font-family: inherit; }
.block-body input, .block-body label, .block-body select { color: var(--ink); background: transparent; }


/* Design panel close button — identical to AI dismiss */
.dp-close-btn { background: var(--primary) !important; border-color: var(--primary) !important; color: var(--white) !important; width: 33.5px !important; height: 33.5px !important; border-radius: 50% !important; }
.dp-close-btn:hover { background: var(--primary-hover) !important; border-color: var(--primary-hover) !important; }
