.editor-main { max-width: 1240px; }
.editor-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 12px 24px; margin: 12px 0 24px;
}
.editor-header h1 { font-size: clamp(26px, 4vw, 38px); margin-bottom: 8px; }
.editor-header p { margin: 0; color: var(--ink-2); font-size: 14px; }
.editor-header-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.editor-blanks { position: relative; }
.editor-blanks .tl-dl {
  position: absolute; z-index: 1; top: calc(100% + 6px); inset-inline-end: 0;
  width: max-content; max-width: 250px; margin: 0; padding: 10px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-float);
}
.editor-import summary { min-height: 44px; padding-block: 9px; cursor: pointer; font-weight: 800; }
.editor-import h2 { margin-top: 12px; }
.work-list { margin-top: 12px; }
.work-list-modes { display: flex; flex-wrap: wrap; gap: 6px; }
html.v2 .work-list .btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.work-list-entry { margin-top: 12px; }
.work-list-entry label { display: block; font-weight: 700; }
.work-list-entry textarea { display: block; resize: vertical; margin-bottom: 8px; }
.work-list-entry textarea:placeholder-shown { height: 84px; }
.work-list-status { padding: 10px 12px; background: var(--fill); border-radius: 12px; font-weight: 700; }
.work-list-status:empty { display: none; }

.editor-layout {
  display: grid; align-items: start; grid-template-columns: minmax(0, .95fr) minmax(0, 1fr); gap: 20px;
}
.editor-controls, .editor-preview { min-width: 0; }
.aosr-row { min-width: 0; padding: 12px; margin: 12px 0; border: 1px solid var(--line); border-radius: 12px; }
.aosr-row label { display: block; margin-bottom: 8px; }
[data-kind="aosr"] .card > label { display: block; margin-top: 14px; }
[data-kind="aosr"] details { margin-block: 12px; }
[data-kind="aosr"] summary { min-height: 44px; cursor: pointer; }
[data-kind="aosr"] details label { display: block; margin-top: 10px; }
[data-kind="aosr"] [data-aosr-paper] { overflow-wrap: anywhere; }
.editor-controls .card { margin-bottom: 12px; min-width: 0; max-width: 100%; }
.editor-controls .card h2 { font-size: 21px; }
.editor-controls .tl-seg label { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.editor-controls .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.editor-controls .tl-more summary { min-height: 44px; }
.editor-controls .tl-wide { grid-column: 1 / -1; }
.editor-steps {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px;
  margin: 0 0 12px; padding: 6px 12px; border-radius: 16px; background: var(--surface); list-style: none;
}
.editor-steps button {
  display: grid; align-content: center; gap: 5px; width: 100%; min-height: 44px;
  border: 0; background: transparent; cursor: pointer; padding: 0 3px; text-align: start;
}
.editor-step-bar { display: block; height: 6px; background: var(--line); border-radius: 99px; }
.editor-step-label { font-weight: 800; font-size: 14px; }
[data-progress="complete"] .editor-step-bar { background: var(--success); }
[data-progress="complete"] .editor-step-label { color: var(--success); }
[data-progress="current"] .editor-step-bar { background: var(--accent); }
[data-progress="future"] .editor-step-label { color: var(--ink-2); }
.editor-error { display: block; color: var(--danger); font-size: 13px; font-weight: 700; margin: 4px 0 0; }
.editor-navigation {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px; border-radius: 16px; background: var(--surface);
}
.editor-nav-total { display: grid; gap: 2px; min-width: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.editor-nav-total a { display: none; }
[data-editor-back] span + span { display: none; }
.editor-navigation .editor-next { min-height: 48px; background: var(--accent); color: var(--on-accent); }
.editor-ready-total { margin-bottom: 0; font-size: 24px; font-weight: 800; }
.document-shell #save-btn { background: var(--accent-soft); color: var(--accent-ink); }
[data-editor-ready-customer] { margin-top: 2px; overflow-wrap: anywhere; color: var(--ink-2); }
.editor-controls .tl-line {
  grid-template-columns: 22px repeat(3, minmax(0, 1fr)) 44px;
  grid-template-areas: "n name name name del" "n unit qty price del" "n sum sum sum del";
}
.editor-controls .tl-line .cap { display: block; }
.editor-controls .tl-sum { flex-direction: row; justify-content: space-between; align-items: baseline; padding-bottom: 0; }
.editor-controls .tl-stage .input { flex: 1; border-color: var(--control-line); }
.estimate-hint {
  position: absolute; z-index: 40; display: grid; max-height: 264px; overflow: auto;
  border: 1px solid var(--control-line); border-radius: 12px; background: var(--surface);
  box-shadow: var(--shadow-raise);
}
.estimate-hint-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-height: 40px;
  padding: 8px 12px; border: 0; background: none; text-align: start; cursor: pointer; color: var(--ink);
}
.estimate-hint-item small { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.estimate-hint-item:hover, .estimate-hint-item:focus { background: var(--fill); }
.invoice-bank-title { margin: 14px 0 4px; font-size: 16px; }
.editor-paper .invoice-bank-table { min-width: 0; font-size: 11px; }
.editor-paper .invoice-bank-table td:first-child { width: 52%; }
.invoice-preview-qr { display: flex; justify-content: center; align-items: center; min-height: 24px; margin: 10px 0 6px; }
.invoice-preview-qr svg { width: 160px; height: 160px; }

.editor-preview { position: sticky; top: 16px; scroll-margin-block: 14px 95px; }
.editor-preview-label { margin: 0 0 8px 6px; font-size: 14px; font-weight: 800; color: var(--ink-2); }
.editor-paper {
  padding: clamp(10px, 2vw, 26px); border-radius: 18px; box-shadow: var(--shadow-raise);
  background: #fff; color: #1b1f24; font-size: 13px; color-scheme: light; overflow-wrap: anywhere;
  min-width: 0; max-width: 100%;
}
.editor-paper section { padding: 8px; border-radius: 8px; }
.editor-paper .is-current { background: #fff1c7; }
.editor-paper p { margin: 4px 0; }
.editor-paper-heading { margin: 0 0 12px; text-align: center; }
.tools .editor-paper h2 { font-size: 17px; }
.editor-paper-scroll { width: 100%; min-width: 0; max-width: 100%; overflow: auto; }
.editor-paper-table { width: 100%; min-width: 365px; border-collapse: collapse; font-size: 12px; }
.editor-paper .ks-preview-table { min-width: 620px; }
.editor-paper .ks3-preview-table { min-width: 460px; }
.editor-paper .ks3-preview-table tbody th { font-weight: 700; }
.editor-paper-table :is(td, th) { padding: 4px 5px; border: 1px solid #868e98; text-align: start; }
.editor-paper-table thead { background: #eef0f3; }
.editor-paper-table :is(tbody, tfoot) td:last-child, .editor-paper-table tfoot th { text-align: end; }
.editor-paper-table :is(tbody, tfoot) td:last-child { white-space: nowrap; }
.editor-paper-table tbody td[colspan] { text-align: start; font-weight: 800; }
.editor-paper-table tfoot td { font-weight: 700; }
.editor-paper-signatures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.editor-paper-signatures > div { display: grid; align-content: start; gap: 4px; }
.recon-ops-wrap {
  display: block; width: 100%; max-width: 100%; min-width: 0;
  margin: 12px 0; overflow-x: auto; overflow-y: hidden; contain: inline-size;
}
.recon-ops-table { width: 620px; min-width: 620px; max-width: none; }
.recon-ops-table :is(th, td) { padding: 4px; vertical-align: middle; }
.recon-ops-table .input { margin: 0; min-height: 44px; }
.recon-ops-table [data-f="document"] { min-width: 220px; }
.recon-op-label { display: none; }
.tl-total, .editor-nav-total strong { overflow-wrap: anywhere; word-break: break-word; }

@media (max-width: 760px) {
  .editor-main { padding-bottom: 102px !important; }
  .editor-header { margin-bottom: 16px; }
  .editor-layout { grid-template-columns: minmax(0, 1fr); }
  .editor-preview { position: static; }
  .editor-blanks .tl-dl { inset-inline: 0 auto; }
  .editor-navigation {
    position: fixed; z-index: 3; inset: auto 0 0; border-radius: 16px 16px 0 0;
    border-top: 1px solid var(--line); box-shadow: var(--shadow-float);
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  }
  .editor-nav-total { flex: 1; order: -1; font-size: 14px; }
  .editor-nav-total a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; }
  [data-editor-back] span:first-child { display: none; }
  [data-editor-back] span + span { display: inline; }
  .editor-controls .form-row { grid-template-columns: minmax(0, 1fr); }
  .recon-ops-wrap { overflow: visible; }
  .recon-ops-table { display: block; width: 100%; min-width: 0; }
  .recon-ops-table thead { display: none; }
  .recon-ops-table tbody, .recon-ops-table tr, .recon-ops-table td { display: block; }
  .recon-ops-table tr.recon-op {
    position: relative; border: 1px solid var(--line); border-radius: 14px;
    padding: 10px 44px 10px 10px; margin-bottom: 10px;
  }
  .recon-ops-table td { border: 0; padding: 4px 0; }
  .recon-ops-table td:last-child { position: absolute; top: 8px; right: 8px; padding: 0; }
  .recon-ops-table .recon-op-label { display: block; color: var(--ink-2); font-size: 12px; font-weight: 700; }
  .recon-ops-table .input { width: 100%; }
  .recon-ops-table [data-f="document"] { min-width: 0; }
  .document-shell .tl-inn .btn { padding-inline: 8px; }
  .tools:has(.editor-main) .toasts { bottom: 90px; }
  .tools:has(.editor-main) .showcase-footer { padding-bottom: 76px; }
}
