.doc-tool {
  --doc-ink: #162940;
  --doc-hint: #505f72;
  --doc-border: #d7dfe8;
  --doc-blue: #244fc8;
  --doc-accent: #244fc8;
  color: var(--doc-ink);
  min-width: 0;
  container-type: inline-size;
}
.doc-tool *, .doc-tool *::before, .doc-tool *::after { box-sizing: border-box; }
.doc-actions, .doc-action-buttons, .doc-switcher, .doc-preview-bar, .doc-item-head {
  display: flex;
  align-items: center;
}
.doc-actions { justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.doc-action-buttons { flex-wrap: wrap; gap: .55rem; }
.doc-editor-heading h1 { margin: .52rem 0 0; font: inherit; font-size: 1.75rem; font-size: clamp(1.65rem, 3.5cqw, 2.25rem); line-height: 1.16; font-weight: 660; letter-spacing: -.055em; color: var(--doc-ink); }
.doc-back, .doc-remove { border: 0; background: transparent; color: var(--doc-blue); font: inherit; font-size: .88rem; font-weight: 600; line-height: 1.5; padding: .25rem .1rem; cursor: pointer; }
.doc-back:hover, .doc-remove:hover { text-decoration: underline; }
.doc-tool :is(button, input, textarea, select):focus-visible { outline: 3px solid #466ce4; outline-offset: 2px; }
.doc-btn, .doc-view {
  appearance: none;
  border-radius: .65rem;
  border: 1px solid var(--doc-border);
  background: #fff;
  color: var(--doc-ink);
  cursor: pointer;
  font: inherit;
  font-size: .88rem;
  line-height: 1.3;
  font-weight: 600;
  min-height: 43px;
  padding: .68rem 1rem;
  white-space: normal;
}
.doc-btn:hover, .doc-view:hover { background: #f3f6fb; }
.doc-primary { background: var(--doc-blue); color: #fff; border-color: var(--doc-blue); }
.doc-primary:hover { background: #173b9e; }
.doc-primary:disabled { cursor: wait; opacity: .7; }
.doc-notice { color: #205246; background: #eef7f2; font-size: .92rem; margin: 0 0 .8rem; padding: .7rem .9rem; border-radius: .6rem; }
.doc-notice[data-error="true"] { color: #882d30; background: #fff0ee; }
.doc-notice:empty { display: none; }
.doc-switcher { gap: .2rem; background: #eef2f7; padding: .25rem; border-radius: .75rem; margin: 0 0 .85rem; align-self: flex-start; width: max-content; }
.doc-view { border-color: transparent; background: transparent; min-height: 39px; }
.doc-view[aria-pressed="true"] { background: #fff; color: var(--doc-blue); border-color: #d5dfed; }
.doc-workspace, .doc-form, .doc-preview { min-width: 0; }
.doc-form { margin: 0; }
.doc-tool[data-view="edit"] .doc-preview, .doc-tool[data-view="preview"] .doc-form { display: none; }
.doc-fields { min-width: 0; margin: 0 0 1rem; padding: .8rem 1.05rem 1.05rem; border: 1px solid var(--doc-border); border-radius: .9rem; background: #fff; }
.doc-fields legend { color: var(--doc-ink); font: inherit; font-weight: 650; font-size: 1rem; line-height: 1.35; letter-spacing: -.025em; padding: 0 .32rem; margin-left: -.32rem; }
.doc-field { display: grid; gap: .35rem; min-width: 0; margin-top: .72rem; color: var(--doc-ink); font-size: .9rem; }
.doc-label { line-height: 1.45; font-weight: 560; }
.doc-field > :is(input, select, textarea) { display: block; width: 100%; min-width: 0; max-width: 100%; border: 1px solid #bfcad7; border-radius: .48rem; color: var(--doc-ink); background-color: #fff; padding: .6rem .66rem; font: inherit; line-height: 1.45; min-height: 43px; }
.doc-field > select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23364a61' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right .65rem center;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
.doc-field > textarea { resize: vertical; }
.doc-field > :is(input, textarea)::placeholder { color: #657487; opacity: 1; }
.doc-field > :is(input, textarea):user-invalid { border-color: #a52d3d; }
.doc-control-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.doc-item-editor { background: #f5f7fa; border: 1px solid #e0e6ee; padding: .68rem .75rem .8rem; border-radius: .65rem; }
.doc-item-editor + .doc-item-editor { margin-top: .6rem; }
.doc-item-head { justify-content: space-between; min-height: 1.65rem; }
.doc-item-head strong { font: inherit; font-size: .85rem; font-weight: 650; }
.doc-remove { color: #8d3942; font-size: .82rem; }
.doc-add { margin-top: .7rem; padding: .45rem .8rem; }
.doc-preview { background: #edf1f6; border: 1px solid var(--doc-border); border-radius: .9rem; padding: .75rem; }
.doc-preview-bar { color: var(--doc-hint); justify-content: space-between; gap: .5rem; font-size: .82rem; margin: 0 .15rem .65rem; }
.doc-preview-bar strong { color: #35475a; font-weight: 600; font-size: .91rem; }
.doc-canvas { max-width: 48rem; min-width: 0; margin: 0 auto; container-type: inline-size; }
.doc-sheet {
  margin: 0;
  width: 100%;
  aspect-ratio: 210/297;
  min-width: 0;
  border: 1px solid #d5dce6;
  padding: 6% 6.2%;
  border-radius: 2px;
  background: white;
  box-shadow: 0 .25rem 1rem rgba(27,48,75,.09);
  color: #172b41;
  font-family: Inter, Arial, sans-serif;
  font-size: .88rem;
  font-size: clamp(.73rem, 2.1cqw, .93rem);
  line-height: 1.49;
  overflow-wrap: anywhere;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.doc-letterhead, .doc-address-block, .doc-imprint, .doc-sumline { display: flex; justify-content: space-between; gap: 1.2em; }
.doc-letterhead { align-items: center; border-bottom: .15em solid #294eb6; padding: 0 0 1.25em; }
.doc-brand { width: min(37%, 12em); height: auto; max-width: 100%; display: block; object-fit: contain; }
.doc-sender { display: grid; justify-items: end; text-align: right; gap: .04em; font-size: .81em; color: #4b6074; line-height: 1.45; }
.doc-sender strong { letter-spacing: -.01em; color: #172b41; }
.doc-page-title { padding: 2em 0 1.28em; }
.doc-sheet .doc-page-title h3 { margin: 0; font-family: inherit; color: #12243b; font-weight: 670; font-size: 1.85rem; font-size: clamp(1.46rem, 5.4cqw, 2.5rem); line-height: 1.1; letter-spacing: -.047em; }
.doc-specimen { color: #3156b4; font-size: .76em; font-weight: 670; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .45em; }
.doc-address-block { align-items: flex-start; gap: 2em; padding-bottom: 1.25em; border-bottom: 1px solid #dae3ed; margin-bottom: 1.5em; }
.doc-recipient { min-width: 0; flex: 1 1 45%; color: #354d62; }
.doc-recipient > strong { display: block; color: #172b41; margin: .2em 0; font-size: 1.1em; font-weight: 635; line-height: 1.4; }
.doc-kicker { display: block; font-size: .77em; line-height: 1.45; font-weight: 630; color: #53667a; }
.doc-meta { display: grid; flex: 0 1 45%; min-width: 0; gap: .23em; }
.doc-meta-item { min-width: 0; }
.doc-meta .doc-meta-item { display: grid; grid-template-columns: minmax(0,.83fr) minmax(0,1.65fr); column-gap: .8em; align-items: baseline; }
.doc-meta .doc-meta-item > strong { text-align: right; font-size: .84em; }
.doc-meta-item strong { font-weight: 590; line-height: 1.45; }
.doc-sheet .doc-subject, .doc-content-block h4 { font-family: inherit; margin: 0 0 .5em; color: #172b41; font-size: 1.1em; line-height: 1.4; letter-spacing: -.018em; font-weight: 650; }
.doc-sheet .doc-subject { font-size: 1.25em; margin-bottom: 1em; }
.doc-content-block { margin: 1.15em 0; font-size: 1em; }
.doc-sheet .doc-prose { color: #2d4459; font-size: 1em; line-height: 1.57; white-space: pre-wrap; margin: 0 0 .65em; }
.doc-table { width: 100%; border-collapse: collapse; border-spacing: 0; table-layout: fixed; margin: 0; font-size: .92em; line-height: 1.47; }
.doc-table th, .doc-table td { text-align: left; padding: .65em .38em; vertical-align: top; border: 0; border-bottom: 1px solid #dce4ec; white-space: normal; overflow-wrap: anywhere; }
.doc-table th { background: #edf2fb; color: #354c67; font-size: .87em; font-weight: 650; }
.doc-table .doc-num { text-align: right; }
.doc-summary { margin: .95em 0 1.25em auto; width: max-content; min-width: min(55%, 18em); max-width: 100%; }
.doc-sumline { align-items: baseline; margin: .1em 0; padding: .2em .5em; color: #3d526a; }
.doc-sumline > :last-child { text-align: right; }
.doc-final-total { color: #162b4b; background: #edf2fb; border-top: 1px solid #b5c8e2; padding: .58em .55em; }
.doc-payment { display: grid; gap: .7em; }
.doc-imprint { align-items: center; margin-top: 2.25em; padding-top: .75em; border-top: 1px solid #cbd6e2; color: #586d81; font-size: .8em; }
.doc-imprint b { font-weight: 610; color: #33475d; }
/* Viewport fallback for browsers without container queries. */
@supports not (container-type: inline-size) {
  @media (min-width: 68rem) {
    .doc-switcher { display: none; }
    .doc-workspace { display: grid; grid-template-columns: minmax(17rem,.76fr) minmax(0,1.55fr); gap: 1.1rem; align-items: start; }
    .doc-tool[data-view] .doc-form, .doc-tool[data-view] .doc-preview { display: block; }
  }
}
@container (min-width: 53rem) {
  .doc-actions { flex-wrap: nowrap; }
  .doc-switcher { display: none; }
  .doc-workspace { display: grid; grid-template-columns: minmax(17rem,.76fr) minmax(0,1.55fr); gap: 1.1rem; align-items: start; }
  .doc-tool[data-view] .doc-form, .doc-tool[data-view] .doc-preview { display: block; }
  .doc-preview { padding: 1rem; }
}
@container (max-width: 24rem) {
  .doc-action-buttons { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .doc-btn, .doc-view { padding-left: .65rem; padding-right: .65rem; }
  .doc-fields { padding: .65rem .7rem .8rem; }
  .doc-preview { padding: .4rem; }
  .doc-sheet { padding: 5% 4%; }
  .doc-address-block { gap: .65em; }
  .doc-meta { flex: 0 1 48%; }
  .doc-meta .doc-meta-item { grid-template-columns: minmax(0,1fr); }
  .doc-meta .doc-meta-item > strong, .doc-meta .doc-kicker { text-align: right; }
  .doc-table th, .doc-table td { padding-left: .18em; padding-right: .18em; }
}
@page {
  size: A4 portrait;
  margin: 15mm 16mm 19mm;
}
@page {
  @bottom-left { content: "Automania"; font: 8pt Arial, sans-serif; color: #596c7e; }
  @bottom-right { content: counter(page) " / " counter(pages); font: 8pt Arial, sans-serif; color: #596c7e; }
}
@media print {
  /* Remove everything outside the active sheet, even when Studio wraps the
     editor in a sidebar, grid, dashboard pane or fixed-height layout. */
  .doc-print-path {
    position: static !important; float: none !important; display: block !important;
    width: auto !important; max-width: none !important; min-width: 0 !important;
    height: auto !important; min-height: 0 !important; max-height: none !important;
    overflow: visible !important; margin: 0 !important; padding: 0 !important;
    border: 0 !important; background: white !important; box-shadow: none !important;
    contain: none !important; container-type: normal !important; transform: none !important;

  }
  .doc-print-path > :not(.doc-print-path):not(.doc-sheet) { display: none !important; }
  .doc-print-path::before, .doc-print-path::after { display: none !important; }
  body:has(.doc-sheet) > :not(.doc-sheet):not(:has(.doc-sheet)),
  body *:has(.doc-sheet) > :not(.doc-sheet):not(:has(.doc-sheet)) { display: none !important; }
  body *:has(.doc-sheet)::before, body *:has(.doc-sheet)::after { display: none !important; }
  .doc-sheet {
    display: block !important; width: 100% !important; height: auto !important;
    min-height: 0 !important; aspect-ratio: auto !important; overflow: visible !important; margin: 0 !important;
    padding: 0 !important; border: 0 !important; border-radius: 0; box-shadow: none !important;
    font-size: 10.4pt !important; line-height: 1.46; print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  .doc-letterhead { break-inside: avoid; }
  .doc-brand { width: 38mm; }
  .doc-sheet .doc-page-title h3 { font-size: 27pt; }
  .doc-page-title, .doc-subject, .doc-content-block h4 { break-after: avoid; }
  .doc-address-block, .doc-table tr, .doc-summary, .doc-payment, .doc-imprint { break-inside: avoid; }
  .doc-table { display: table; }
  .doc-table thead { display: table-header-group; }
  .doc-table tbody { display: table-row-group; }
  .doc-sheet p { orphans: 2; widows: 2; }
}
