/* «Шаблоны документов» и конструктор шаблона в «Компаниях» — BRIEF-r4 §1 «Документы», r4-doc-templates.md §3 а–в, д.
   Владелец — C2 (js/screens/org-templates.js), префикс dt-. Лист А4 — deal-docs.css (dp-*, C1).
   Вкус: цвет только у отклонений (◆ «печати нет», ◆ замечания шаблона), кнопки бледные, главная одна, эскизы — полоски. */

/* Переключатель «Реквизиты и файлы · Шаблоны документов N»: на широком окне — своей строкой под полосой вкладок (.od-view,
   org-docs.js); на узком (≤ 1279) — в строке заголовка раздела (org.js .org-hview, стили — org.css), чтобы не съедать высоту 1100×560 */
.od-view { display: flex; align-items: center; min-width: 0; margin: 0 0 12px; }
.od-view .seg button { height: 28px; font-size: 12.5px; }
@media (max-width: 1279px) { .od-view { display: none; } }

/* ══ Вид «Шаблоны документов» ══ */
.dt-page { min-width: 0; }
.dt-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.dt-main, .dt-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dt-list { padding: 10px 14px 12px; }
.dt-note { margin: 2px 2px 4px; font-size: 12.5px; line-height: 17px; color: var(--mut); }
.dt-g + .dt-g { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.dt-gh { display: flex; align-items: baseline; gap: 6px; padding: 4px 2px 4px; font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--mut2); }
.dt-gh em { font-style: normal; font-weight: 600; letter-spacing: 0; }
.dt-row { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 6px 6px 6px 4px; border-radius: 12px; cursor: pointer; transition: background .12s; }
.dt-row:hover { background: var(--l3); }
.dt-row:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--acc-soft); }
.dt-row.is-new { background: var(--acc-row); }
.dt-m { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.dt-n { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dt-n b { min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* K4-10: «что особенного» — до двух строк, переносом по словам (не режем посреди слова) */
.dt-s { min-width: 0; font-size: 12.5px; line-height: 17px; color: var(--mut); overflow: hidden; overflow-wrap: normal;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.dt-tag { flex: 0 0 auto; display: inline-flex; align-items: center; height: 19px; padding: 0 7px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--l1);
  font-size: 11px; font-weight: 600; line-height: 1; color: var(--mut); white-space: nowrap; }
.dt-tag.is-main { border-color: var(--acc-soft-brd); color: var(--acc); }
.dt-at { flex: 0 0 auto; font-size: 12px; color: var(--mut2); white-space: nowrap; }
/* K4-09: «Сделать основным» — по наведению или фокусу строки (и в «⋯»), поверх даты; на первом экране нет ряда одинаковых кнопок */
.dt-row { position: relative; }
.dt-mk { position: absolute; top: 50%; right: 44px; transform: translateY(-50%); flex: 0 0 auto; visibility: hidden; opacity: 0; transition: opacity .12s;
  box-shadow: -14px 0 10px -2px var(--l3); }
.dt-row:is(:hover, :focus-within) .dt-mk { visibility: visible; opacity: 1; }
.dt-more { flex: 0 0 auto; }
.dt-own { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; margin-top: 4px; padding: 8px 10px; border: 1px dashed var(--line-2); border-radius: 12px; background: none;
  font: inherit; font-size: 12.5px; color: var(--mut); text-align: left; cursor: pointer; }
.dt-own b { flex: 0 0 auto; font-weight: 600; color: var(--ink); }
.dt-own span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-own svg { flex: 0 0 auto; color: var(--acc); }
.dt-own:hover { border-color: var(--acc-soft-brd); background: var(--l3); }

/* эскиз листа: белый в обеих темах, полоски — блоки (цветом акцента — шапка, «О компании», печать) */
.dt-th { flex: 0 0 auto; display: flex; flex-direction: column; gap: 3px; box-sizing: border-box; width: 44px; height: 60px; padding: 6px 6px 5px; overflow: hidden;
  border-radius: 3px; background: #fff; box-shadow: 0 0 0 1px var(--line-2), 0 2px 5px rgba(22, 32, 46, .08); }
.dt-th.is-dense { gap: 2px; padding: 5px; }
.dt-th i { display: block; flex: 0 0 auto; height: 2px; border-radius: 1px; background: #dfe3ea; }
.dt-th i[data-k="head"] { height: 4px; width: 46%; background: var(--th-acc); }
.dt-th.is-r i[data-k="head"] { align-self: flex-end; }
.dt-th i[data-k="items"] { height: 9px; background: linear-gradient(#cfd5de, #cfd5de) 0 0 / 100% 2px no-repeat, repeating-linear-gradient(#fff 0 2px, #e6e9ef 2px 3px); }
.dt-th i[data-k="clauses"] { height: 8px; background: repeating-linear-gradient(#e3e7ee 0 2px, #fff 2px 3px); }
.dt-th i[data-k="totals"], .dt-th i[data-k="words"] { width: 44%; align-self: flex-end; background: #c3cad5; }
.dt-th i[data-k="about"] { height: 3px; background: linear-gradient(90deg, var(--th-acc) 0 28%, transparent 28% 36%, var(--th-acc) 36% 64%, transparent 64% 72%, var(--th-acc) 72%); opacity: .55; }
.dt-th i[data-k="sign"] { width: 58%; background: #c3cad5; }
.dt-th i[data-k="pay"] { height: 6px; background: linear-gradient(90deg, #e3e7ee 0 64%, transparent 64% 76%, #9aa3b0 76%); }
.dt-th i[data-k="foot"] { margin-top: auto; height: 1px; background: #d6dbe3; }
.dt-th i[data-k="gap"] { height: 1px; background: #e8ebf0; }

/* «Что подставляется в шаблоны» */
.dt-side-c .od-fc > span { max-width: 52%; overflow-wrap: anywhere; }
.dt-side-c .od-fc > b { min-width: 0; font-weight: 560; text-align: right; }
.dt-miss { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; font-weight: 560; color: var(--ink); }
.dt-miss > i { flex: 0 0 auto; width: 6.5px; height: 6.5px; border-radius: 1.5px; transform: rotate(45deg); background: var(--sig-wait); }
.dt-miss .link { padding: 0 2px; font-size: 12.5px; }
.dt-no { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dt-side-n { margin: 6px 0 0; font-size: 12px; line-height: 16px; color: var(--mut2); }

@media (max-width: 1279px) {
  .dt-grid { grid-template-columns: minmax(0, 1fr); }
  .dt-at { display: none; }
}
@media (max-height: 640px) {
  .dt-list { padding: 6px 12px 8px; }
  .dt-row { padding: 4px 6px 4px 4px; }
  .dt-th { width: 36px; height: 48px; padding: 5px; gap: 2px; }
  .dt-g + .dt-g { margin-top: 4px; padding-top: 4px; }
}

/* ══ Конструктор ══ */
.sheet.dt-ctor { width: min(1400px, 100%); height: calc(100vh - 48px); max-height: calc(100vh - 48px); }
.dt-ctor .sb { display: flex; overflow: hidden; }
.dt-ctor .sh { align-items: center; padding-top: 12px; padding-bottom: 10px; }
.dt-ctor .sh::before { top: 50%; margin-top: -14px; }
.dt-ctor .sh-title { font-size: 18px; }
.dt-ctor .sh-main { gap: 2px; }
.dt-ttl { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
/* K4-01: название целиком — без отрицательных полей по бокам (из-за них ширина содержимого считалась на 14 px меньше и flex
   ужимал кнопку); сдвиг влево под выравнивание — у обёртки */
.dt-ttl { margin-left: -7px; }
.dt-ttl:has(> b.dt-name) { margin-left: 0; }
.dt-ttl .dt-name { flex: 0 1 auto; min-width: 0; margin: -3px 0; font-size: inherit; font-weight: inherit; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-ttl .dt-name:is(b) { margin: 0; }
.dt-hr { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; margin-right: 6px; }
.dt-ex-l { flex: 0 0 auto; font-size: 12.5px; color: var(--mut); white-space: nowrap; }
.dt-ex { min-width: 0; max-width: 320px; }
.dt-ex > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-hr .dd-zoom { margin: 0; }

.dt-cw { flex: 1 1 auto; display: grid; grid-template-columns: 290px minmax(0, 1fr) 330px; grid-template-rows: minmax(0, 1fr) auto; width: 100%; min-width: 0; min-height: 0; }
.dt-bl { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 0; overflow: auto; padding: 12px 10px 14px 12px; border-right: 1px solid var(--line); background: var(--l1); }
.dt-cv { grid-column: 2; grid-row: 1; min-width: 0; min-height: 0; overflow: auto; padding: 24px; background: var(--l2); }
.dt-pp { display: flex; justify-content: center; align-items: flex-start; min-width: min-content; }
.dt-pp .dt-nodeal { width: min(420px, 100%); margin-top: 40px; }
.dt-pr { grid-column: 3; grid-row: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; overflow: auto; padding: 12px 16px 18px; border-left: 1px solid var(--line); background: var(--l1); }
.dt-chk { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; padding: 7px 18px; border-top: 1px solid var(--line); background: var(--l1); }
.dt-chk[hidden] { display: none; }
.dt-chk-r { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 12.5px; line-height: 17px; color: var(--ink); }
.dt-chk-r > i { flex: 0 0 auto; width: 6.5px; height: 6.5px; border-radius: 1.5px; transform: translateY(-1px) rotate(45deg); background: var(--sig-wait); }
.dt-chk-more { font-size: 12px; color: var(--mut2); cursor: help; }

/* блоки листа */
.dt-bl-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 4px; }
.dt-bl-h b { font-size: 13px; font-weight: 640; }
.dt-nar { display: none; }
.dt-bks { display: flex; flex-direction: column; gap: 2px; }
.dt-bk { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 4px 6px 4px; border-radius: 10px; cursor: pointer; transition: background .12s; }
.dt-bk:hover { background: var(--l3); }
.dt-bk.is-sel { background: var(--acc-row); }
.dt-bk.is-off .dt-bk-t b { color: var(--mut2); font-weight: 560; }
.dt-bk.is-drag { opacity: .45; }
.dt-bk.is-dropb { box-shadow: inset 0 2px 0 var(--acc); }
.dt-bk.is-dropa { box-shadow: inset 0 -2px 0 var(--acc); }
.dt-grip { display: inline-flex; flex: 0 0 auto; color: var(--mut2); cursor: grab; }
.dt-bk-t { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; }
.dt-bk-t b { font-size: 13px; font-weight: 600; line-height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-bk-t small { font-size: 11.5px; line-height: 15px; color: var(--mut2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-bk .toggle { flex: 0 0 auto; }
.dt-bk-m { flex: 0 0 auto; }
.dt-addb { align-self: flex-start; margin: 8px 0 0 4px; }

/* свойства */
.dt-pr-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dt-pr-b { display: flex; flex-direction: column; gap: 14px; min-width: 0; margin: 0; padding: 0; border: 0; }
.dt-pr-b:disabled { opacity: .78; }
.dt-pr .field { gap: 6px; }
.dt-ph { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dt-ph-t { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dt-ph-t b { font-size: 14px; font-weight: 640; }
.dt-ph-t small { font-size: 12px; line-height: 16px; color: var(--mut2); }
.dt-ph .toggle { flex: 0 0 auto; }
.dt-ta { min-height: 84px; resize: vertical; }
.dt-f-b { display: flex; }
.dt-seg { display: flex; flex-wrap: wrap; }
.dt-seg button { flex: 1 1 auto; justify-content: center; height: 28px; padding: 0 10px; font-size: 12.5px; }
.dt-dd { justify-content: space-between; width: 100%; }
.dt-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.dt-vars > span { font-size: 11.5px; color: var(--mut2); margin-right: 2px; }
.dt-var { height: 22px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--l2); font: inherit; font-size: 11.5px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.dt-var:hover { border-color: var(--acc-soft-brd); color: var(--acc); }
.dt-var-all { height: 22px; font-size: 11.5px; padding: 0 6px; }
.dt-cols { display: flex; flex-direction: column; gap: 1px; }
.dt-col { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 3px 2px; border-radius: 7px; }
.dt-col:hover { background: var(--l3); }
.dt-col.is-off .dt-col-l { color: var(--mut2); }
.dt-col.is-drag { opacity: .45; }
.dt-col.is-dropb { box-shadow: inset 0 2px 0 var(--acc); }
.dt-col.is-dropa { box-shadow: inset 0 -2px 0 var(--acc); }
.dt-col-l { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; font-size: 13px; line-height: 17px; }
.dt-col-l small { font-size: 11px; line-height: 14px; color: var(--mut2); }
.dt-facts { display: flex; flex-direction: column; gap: 6px; }
.dt-fact { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.dt-line { display: flex; align-items: center; gap: 4px; }
.dt-line .in { flex: 1 1 auto; min-width: 0; }
.dt-plus { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; height: 28px; padding: 0 8px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: 12.5px; color: var(--acc); cursor: pointer; }
.dt-plus:hover { background: var(--l3); }
.dt-cls { display: flex; flex-direction: column; gap: 10px; }
.dt-cl { display: flex; flex-direction: column; gap: 4px; }
.dt-cl-h { display: flex; align-items: center; gap: 4px; }
.dt-cl-h .in { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.dt-img { display: flex; max-width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.dt-img img { max-width: 100%; max-height: 90px; object-fit: contain; }
.dt-img-a { display: flex; gap: 6px; flex-wrap: wrap; }
.dt-x { margin: 0; font-size: 12.5px; line-height: 18px; color: var(--mut); }
.dt-x .link { font-size: 12.5px; padding: 0 2px; }
.dt-ro { margin: 0; font-size: 12.5px; color: var(--mut2); }
/* K4-19: «только смотреть» — ссылки и кнопки свойств серые, без отклика */
.dt-pr-b:disabled :is(.link, .dt-var, .dd, .dt-plus, .dt-sw) { color: var(--mut2); pointer-events: none; cursor: default; }
.dt-sws { display: flex; flex-wrap: wrap; gap: 8px; }
.dt-sw { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: var(--sw); cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08) inset; color: var(--mut); }
.dt-sw.is-on { box-shadow: 0 0 0 2px var(--l1), 0 0 0 4px var(--sw); }
.dt-sw.is-own { background: var(--sw); border: 1.5px dashed var(--line-3); }
.dt-sw.is-own.is-on { border-style: solid; border-color: transparent; box-shadow: 0 0 0 2px var(--l1), 0 0 0 4px var(--sw); }
.dt-paper-t { font-size: 13px; color: var(--mut); }

/* подвал */
.dt-ctor .sf { gap: 8px; }
.dt-stamp { min-width: 0; font-size: 12.5px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-ro-f { color: var(--mut2); }
.dt-ro-f::before { content: '·'; margin: 0 8px 0 0; }
/* K4-19: подсказка менеджеру — одна, в подвале, на любой ширине (ужимается многоточием, полная — в подсказке) */
.dt-ro-f { flex: 0 1 auto; }

/* K4-06 / K4-11: меню «На примере ▾» и «{ } Поле ▾» — шире, подписи и подсказки целиком (у .menu потолок 360 px) */
.menu.dt-menu-wide { max-width: min(520px, calc(100vw - 32px)); }
.menu.dt-menu-wide .mi { align-items: center; min-height: 34px; padding-top: 5px; padding-bottom: 5px; }
.menu.dt-menu-wide .mi-l { white-space: normal; overflow: visible; line-height: 17px; }
.menu.dt-menu-wide .mi-h { flex: 0 0 auto; max-width: 55%; white-space: normal; overflow: visible; text-align: right; line-height: 15px; }

/* K4-07: окно юрлица открыто «на печати» — раздел ненадолго подсвечен */
.le-sig { transition: background .4s, box-shadow .4s; border-radius: 10px; }
.le-sig.is-hl { background: var(--acc-row); box-shadow: 0 0 0 8px var(--acc-row); }
.dt-stamp.is-dirty { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.dt-stamp.is-dirty > i { flex: 0 0 auto; width: 6.5px; height: 6.5px; border-radius: 1.5px; transform: rotate(45deg); background: var(--sig-wait); }

/* «О компании» — три факта */
.dt-ab { display: flex; flex-direction: column; gap: 8px; }
.dt-ab-r { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px; }

/* узкое окно (1100): две колонки — свойства подменяют список блоков («‹ Все блоки») */
@media (max-width: 1239px) {
  .dt-cw { grid-template-columns: 272px minmax(0, 1fr); }
  .dt-pr { grid-column: 1; border-left: 0; border-right: 1px solid var(--line); padding: 10px 12px 14px; }
  .dt-cw[data-pane="blocks"] .dt-pr { display: none; }
  .dt-cw[data-pane="props"] .dt-bl { display: none; }
  .dt-nar { display: inline-flex; font-size: 12.5px; padding: 2px 4px; }
  .dt-cv { padding: 14px; }
  .dt-ex-l { display: none; }
  .dt-ex { max-width: 250px; }
  .dt-ctor .sh-title { font-size: 16px; }
  .dt-ctor .sh-ic { display: none; }
}
@media (max-height: 640px) {
  .dt-ctor .sh { padding-top: 8px; padding-bottom: 7px; }
  .dt-ctor .sh-sub { font-size: 12px; line-height: 16px; }
  .dt-bk { padding: 4px; }
  .dt-chk { padding: 5px 14px; }
}
@media (prefers-reduced-motion: reduce) { .dt-row, .dt-bk { transition: none; } }
