/* Режим «Смета» (дополняет css/style.css и css/gesn.css) */
.wrap.wide { max-width: 1320px; }
.tab-n { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--marker); color: #14213D; font: 600 12px/18px var(--mono); text-align: center; }
.tab-n[hidden] { display: none; }

.s-top { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 12px 0 8px; }
.s-title { flex: 1 1 320px; min-width: 0; height: 44px; padding: 0 14px; font-size: 17px; font-weight: 600; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); }
.s-title::placeholder { font-weight: 400; color: var(--muted); }
.s-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-main { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
.btn-main:hover { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.btn-quiet { background: transparent; }
.btn.armed { color: var(--danger); border-color: var(--danger); }
.s-opts { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 2px 0 12px; }
.s-opts .g-check { font-size: 13.5px; }

/* таблица */
.s-table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.s-table-wrap[hidden] { display: none; }
.s-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.s-table th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; background: var(--surface); }
.s-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.s-table tr:last-child td { border-bottom: 0; }
.s-table .s-n { width: 34px; color: var(--muted); font: 500 13px var(--mono); text-align: right; padding-top: 14px; }
.s-table th.s-n { padding-top: 10px; }
.s-type { width: 168px; }
.s-code { width: 200px; }
.s-code .code { font-size: 13px; white-space: nowrap; display: block; margin-top: 4px; }
.s-code .tag { margin-top: 4px; font-size: 11.5px; }
.s-name { min-width: 260px; }
.s-nm { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 4px 0 0; font-size: 14px; line-height: 1.4; color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.s-nm:hover { color: var(--action); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.s-note { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.s-unit { width: 92px; white-space: nowrap; padding-top: 12px !important; }
.s-vol { width: 150px; }
.s-qty, .s-lab { width: 96px; text-align: right; font: 500 13.5px var(--mono); white-space: nowrap; padding-top: 13px !important; }
.s-lab { color: var(--muted); }
.s-table th.s-qty, .s-table th.s-lab { font: 600 12.5px var(--sans); }
.s-acts { width: 92px; white-space: nowrap; text-align: right; }

.s-seg { display: inline-flex; padding: 2px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--paper); }
.s-seg button { border: 0; background: transparent; padding: 5px 9px; border-radius: 7px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.s-seg button.on { background: var(--ink); color: var(--paper); }
.s-seg button:not(.on):hover { color: var(--ink); background: var(--surface); }

.s-q, .s-v, .s-sectitle { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 14.5px; }
.s-q { border: 2px solid var(--ink); background: var(--surface); }
.s-q:focus, .s-v:focus, .s-sectitle:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--marker) 60%, transparent); }
.s-v { width: 96px; text-align: right; font-family: var(--mono); font-size: 14px; }
.s-v.bad { border-color: var(--danger); color: var(--danger); }
.s-vu { margin-left: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.s-vol { white-space: nowrap; }
.s-was { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.s-link { background: none; border: 0; padding: 0; color: var(--action); cursor: pointer; font-size: 12.5px; }
.s-link:hover { text-decoration: underline; }

.s-sec td { background: var(--paper); }
.s-sectitle { font-weight: 700; font-size: 15px; background: var(--surface); }
.s-ic { width: 26px; height: 26px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.s-ic:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }
.s-del:hover { color: var(--danger); border-color: var(--danger); }

.s-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; }
.s-summary { margin-left: auto; font-size: 13.5px; color: var(--muted); }
.s-summary b { color: var(--ink); font-weight: 600; }
.s-warn { color: var(--analog); }
#viewSmeta .empty { margin-top: 18px; }

/* выпадающий список подбора */
.s-drop { position: fixed; z-index: 50; overflow-y: auto; background: var(--surface); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 0 12px 32px rgba(10, 18, 30, .22); }
.s-drop[hidden] { display: none; }
.s-opt { display: grid; grid-template-columns: 210px 1fr auto; gap: 4px 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: start; }
.s-opt.sel { background: var(--marker-soft); }
.s-opt:hover:not(.sel) { background: var(--paper); }
.s-opt-l { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.s-opt-code { font: 600 12.5px/1.4 var(--mono); color: var(--ink); white-space: nowrap; }
.s-opt .pct { font-size: 11.5px; padding: 2px 4px; }
.s-opt .tag { font-size: 11px; padding: 1px 6px; }
.s-opt-name { font-size: 13.5px; line-height: 1.35; overflow-wrap: anywhere; }
.s-opt-note { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.s-opt-u { font-size: 12.5px; color: var(--muted); white-space: nowrap; text-align: right; }
.s-drop-msg { padding: 14px; font-size: 14px; color: var(--ink-2); }
.s-drop-foot { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 7px 12px; background: var(--paper); font-size: 12px; color: var(--muted); }

.act-add { font-weight: 600; }
.toast .toast-act { pointer-events: auto; margin-left: 12px; padding: 3px 10px; border-radius: 6px; border: 1px solid currentColor; background: transparent; color: var(--marker); cursor: pointer; font-size: 13px; font-weight: 600; }

/* телефон: строка сметы — карточка */
@media (max-width: 860px) {
  .s-table thead { display: none; }
  .s-table, .s-table tbody { display: block; }
  .s-table tr { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; padding: 10px; border-bottom: 1px solid var(--line); }
  .s-table tr:last-child { border-bottom: 0; }
  .s-table td { display: block; padding: 0; border: 0; width: auto !important; min-width: 0; text-align: left; }
  .s-table .s-n { grid-column: 1; grid-row: 1; padding-top: 6px; }
  .s-table .s-type { grid-column: 2; grid-row: 1; justify-self: start; }
  .s-table .s-acts { grid-column: 3; grid-row: 1; }
  .s-table .s-code, .s-table .s-name, .s-table .s-find, .s-table .s-secname { grid-column: 1 / -1; }
  .s-table .s-unit { grid-column: 1 / 3; padding-top: 0 !important; font-size: 13px; color: var(--muted); }
  .s-table .s-unit::before { content: "Ед. изм.: "; }
  .s-table .s-vol { grid-column: 1 / -1; }
  .s-table .s-qty, .s-table .s-lab { grid-column: auto; padding-top: 0 !important; font-size: 13px; text-align: left; }
  .s-table .s-qty:not(:empty)::before { content: "Кол-во: "; font-family: var(--sans); color: var(--muted); }
  .s-table .s-lab:not(:empty)::before { content: "Труд: "; font-family: var(--sans); }
  .s-table .s-qty:empty, .s-table .s-lab:empty { display: none; }
  .s-sec { background: var(--paper); }
  .s-sec td { background: transparent; }
  .s-v { width: 120px; }
  .s-opt { grid-template-columns: 1fr auto; }
  .s-opt-name { grid-column: 1 / -1; }
  .s-opt-u { grid-column: 2; grid-row: 1; }
  .s-summary { margin-left: 0; flex-basis: 100%; }
}

@media (max-width: 720px) {
  .tabs { gap: 0; }
  .tab { flex: 1 1 auto; min-width: 0; padding: 8px 4px; font-size: 13px; }
  .tab-n { min-width: 16px; padding: 0 4px; margin-left: 2px; font-size: 11px; line-height: 16px; }
}

/* связанные строки: неучтённые материалы, добавочные, комплект */
.s-child td { background: color-mix(in srgb, var(--paper) 55%, var(--surface)); }
.s-child .s-name, .s-child .s-find { padding-left: 22px; position: relative; }
.s-child .s-name::before, .s-child .s-find::before { content: "↳"; position: absolute; left: 6px; top: 10px; color: var(--muted); }
.s-link-tag { display: inline-block; margin-top: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; background: var(--weak-soft); color: var(--ink-2); }
.l-a { background: var(--analog-soft); color: var(--analog); font-weight: 600; }
.l-add { background: var(--direct-soft); color: var(--direct); }
.l-kit { background: var(--coef-soft); color: var(--coef); }
.s-auto { display: inline-block; padding-top: 8px; font-size: 12.5px; color: var(--muted); margin-right: 6px; }
/* пометки: из распознавания и подбора */
.s-flag { margin-top: 5px; padding: 4px 8px; border-radius: 7px; font-size: 12.5px; line-height: 1.4; }
.s-flag b { font-weight: 600; }
.f-check, .f-choose, .f-project, .f-choosemat, .f-negative, .f-volume { background: var(--analog-soft); color: var(--ink); }
.f-missing, .f-unread { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--ink); }
.f-question { background: var(--coef-soft); color: var(--ink); }
.s-flag .s-ok { margin-left: 4px; color: var(--muted); }
.s-src { margin-top: 3px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
tr.fl-check > td:first-child, tr.fl-choose > td:first-child, tr.fl-project > td:first-child, tr.fl-choosemat > td:first-child,
tr.fl-negative > td:first-child, tr.fl-volume > td:first-child { box-shadow: inset 4px 0 0 var(--marker); }
tr.fl-missing > td:first-child, tr.fl-unread > td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
tr.fl-question > td:first-child { box-shadow: inset 4px 0 0 var(--coef); }
tr.s-focus td { background: var(--marker-soft); transition: background .3s; }
.s-opts-line { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); padding: 0 0 10px; }
