/* Telcon calc — три колонки: каталог / наряд / итоги */

:root {
    --tc-ink: #1c355e;          /* фирменный тёмно-синий */
    --tc-ink-deep: #14284a;
    --tc-text: #1f2a3a;
    --tc-muted: #5f6f86;
    --tc-app-bg: #dfe6ef;       /* подложка всего калькулятора */
    --tc-surface: #ffffff;
    --tc-surface-2: #f3f6fa;
    --tc-head-bg: #f0f4f9;      /* шапки панелей и групп */
    --tc-line: #d7dfea;
    --tc-line-strong: #b9c6d6;
    --tc-panel-border: #b3c1d3;
    --tc-ok: #16865a;
    --tc-ok-soft: #e1f2e9;
    --tc-warn: #b0441f;
    --tc-warn-soft: #fbece5;
    --tc-mark: #ffe7a0;
    --tc-shadow: 0 1px 2px rgba(20, 40, 74, .08), 0 6px 18px rgba(20, 40, 74, .08);
    --tc-font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.tc-app,
.tc-mobile-bar {
    font-family: var(--tc-font);
    color: var(--tc-text);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
.tc-app, .tc-app *, .tc-mobile-bar * { box-sizing: border-box; }
.tc-app [hidden], .tc-mobile-bar [hidden] { display: none !important; }

:where(.tc-app, .tc-mobile-bar) :where(button, input, select, textarea) { font-family: inherit; font-size: inherit; color: inherit; }

.tc-app :focus-visible,
.tc-mobile-bar :focus-visible { outline: 2px solid var(--tc-ink); outline-offset: 2px; }

/* ---------- страница целиком (без шаблона сайта) ---------- */

html, body.tc-body { margin: 0; padding: 0; }
html, body.tc-body { overflow-x: clip; }
body.tc-body { background: var(--tc-app-bg); }

/* ---------- сетка ---------- */

.tc-app {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 330px;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    margin: 0;
    padding: 14px;
    background: var(--tc-app-bg);
}

.tc-panel {
    background: var(--tc-surface);
    border: 1px solid var(--tc-panel-border);
    border-radius: 12px;
    box-shadow: var(--tc-shadow);
    min-height: 0;
}

/* Компьютер: высота калькулятора = высота окна, панели неподвижны,
   колесо мыши прокручивает только содержимое той панели, над которой курсор */
@media (min-width: 1024px) {
    body.tc-body { overflow: hidden; }
    .tc-app { height: 100vh; height: 100dvh; }
    .tc-catalog, .tc-sheet, .tc-summary { height: 100%; overflow: hidden; }
    .tc-catalog-body,
    .tc-sheet-scroll,
    .tc-summary-scroll { overscroll-behavior: contain; }
}

/* ---------- шапка калькулятора ---------- */

.tc-apphead {
    grid-column: 1 / -1;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 2px 4px 0;
}
.tc-brand { display: flex; align-items: center; gap: 12px; }
.tc-logo {
    display: inline-flex; align-items: center;
    height: 44px;
    padding: 0 16px;
    border-radius: 10px;
    background: var(--tc-ink);
    box-shadow: 0 1px 3px rgba(20, 40, 74, .25);
}
.tc-logo-svg { display: block; height: 24px; width: auto; }
a.tc-logo { text-decoration: none; transition: background .15s; }
a.tc-logo:hover { background: var(--tc-ink-deep); }
h1.tc-brand-title { margin: 0; }
.tc-brand-text { padding-left: 14px; border-left: 1px solid var(--tc-panel-border); }
.tc-brand-title { font-size: 20px; font-weight: 600; color: var(--tc-ink); letter-spacing: -0.01em; line-height: 1.2; }
.tc-brand-sub { font-size: 13px; color: var(--tc-muted); }
.tc-apphead-right { display: flex; align-items: center; gap: 14px; }
.tc-version {
    padding: 3px 10px; border-radius: 12px;
    background: var(--tc-surface); border: 1px solid var(--tc-panel-border);
    font-size: 12px; font-weight: 600; color: var(--tc-ink);
}
.tc-link { font-size: 13px; color: var(--tc-ink); text-decoration: none; border-bottom: 1px solid var(--tc-line-strong); }
.tc-link:hover { border-color: var(--tc-ink); }

.tc-back {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px 8px 10px;
    border-radius: 8px;
    background: var(--tc-ink); color: #fff;
    font-size: 13px; font-weight: 600; text-decoration: none;
    transition: background .15s;
}
.tc-back:hover { background: var(--tc-ink-deep); color: #fff; }
.tc-back svg { width: 16px; height: 16px; flex: none; }
.tc-back, .tc-brand-title { white-space: nowrap; }

/* Блок пользователя в шапке */
.tc-user {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 4px 4px 4px;
    background: var(--tc-surface);
    border: 1px solid var(--tc-panel-border);
    border-radius: 10px;
}
.tc-avatar {
    display: grid; place-items: center; flex: none;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--tc-head-bg); color: var(--tc-ink);
    border: 1px solid var(--tc-panel-border);
    font-size: 12px; font-weight: 600;
}
.tc-user-text { display: flex; flex-direction: column; line-height: 1.2; max-width: 180px; }
.tc-user-name { font-size: 13px; font-weight: 600; color: var(--tc-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-user-role { font-size: 11.5px; color: var(--tc-muted); }
.tc-logout {
    display: grid; place-items: center; flex: none;
    width: 30px; height: 30px; border-radius: 7px;
    color: var(--tc-muted);
}
.tc-logout:hover { background: var(--tc-warn-soft); color: var(--tc-warn); }
.tc-logout svg { width: 17px; height: 17px; }

.tc-login {
    padding: 7px 14px;
    border: 1px solid var(--tc-ink); border-radius: 8px;
    background: var(--tc-surface); color: var(--tc-ink);
    font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.tc-login:hover { background: var(--tc-ink); color: #fff; }

/* Единый стиль заголовков панелей */
.tc-panel-titlebar { display: flex; align-items: center; gap: 10px; }
.tc-panel-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--tc-ink); line-height: 1.3; }
.tc-pill {
    min-width: 24px; padding: 1px 8px;
    border-radius: 12px;
    background: var(--tc-ink); color: #fff;
    font-size: 12px; font-weight: 600; text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ---------- левая панель: каталог ---------- */

.tc-catalog { display: flex; flex-direction: column; overflow: hidden; }

.tc-catalog-head {
    flex: none;
    padding: 14px 14px 12px;
    background: var(--tc-head-bg);
    border-bottom: 1px solid var(--tc-panel-border);
    border-radius: 11px 11px 0 0;
}
.tc-catalog-head .tc-panel-titlebar { justify-content: space-between; margin-bottom: 10px; }
.tc-drawer-done { display: none; }

.tc-collapse-toggle {
    display: inline-flex; align-items: center; gap: 4px;
    margin-left: auto;
    padding: 4px 9px 4px 6px;
    border: 1px solid var(--tc-line-strong);
    border-radius: 7px;
    background: #fff;
    color: var(--tc-ink);
    font-size: 12.5px; font-weight: 500;
    cursor: pointer;
}
.tc-collapse-toggle:hover { border-color: var(--tc-ink); }
.tc-collapse-toggle svg { width: 15px; height: 15px; flex: none; }
.tc-catalog.tc-searching .tc-collapse-toggle { display: none; }

.tc-search { position: relative; }
.tc-search-icon {
    position: absolute; left: 11px; top: 50%;
    width: 16px; height: 16px; margin-top: -8px;
    color: var(--tc-muted); pointer-events: none;
}
.tc-search input {
    width: 100%; height: 40px;
    padding: 0 34px;
    border: 1px solid var(--tc-line-strong);
    border-radius: 8px;
    background: #fff;
}
.tc-search input:focus { outline: none; border-color: var(--tc-ink); box-shadow: 0 0 0 3px rgba(28, 53, 94, .14); }
.tc-search-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px;
    border: 0; border-radius: 6px; background: transparent;
    color: var(--tc-muted); cursor: pointer; font-size: 13px;
}
.tc-search-clear:hover { background: var(--tc-line); color: var(--tc-text); }

.tc-catalog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.tc-group { border-bottom: 1px solid var(--tc-line); }

.tc-group-head {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 11px 14px;
    border: 0; background: var(--tc-surface);
    text-align: left; cursor: pointer;
    font-weight: 600; color: var(--tc-ink);
}
.tc-group-head:hover { background: var(--tc-surface-2); }
.tc-group.is-open > .tc-group-head,
.tc-catalog.tc-searching .tc-group-head {
    background: var(--tc-head-bg);
    border-bottom: 1px solid var(--tc-line);
}
.tc-group.has-selected > .tc-group-head { box-shadow: inset 3px 0 0 var(--tc-ok); }
.tc-group-name { flex: 1; min-width: 0; }

.tc-chev {
    flex: none;
    width: 7px; height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform .15s;
    margin: 0 4px 0 2px;
}
.tc-group.is-open .tc-chev,
.tc-catalog.tc-searching .tc-chev { transform: rotate(45deg); }

.tc-group-count {
    flex: none;
    min-width: 22px; padding: 1px 7px;
    border-radius: 11px;
    background: var(--tc-ok); color: #fff;
    font-size: 12px; font-weight: 600; text-align: center;
    font-variant-numeric: tabular-nums;
}

.tc-group-items,
.tc-freq-list { list-style: none; margin: 0; padding: 4px 6px 6px; }
.tc-group-items { display: none; }
.tc-group.is-open .tc-group-items,
.tc-catalog.tc-searching .tc-group-items { display: block; }

.tc-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 8px 10px 8px 12px;
    border: 0; border-radius: 8px;
    background: transparent;
    text-align: left; cursor: pointer;
}
.tc-item:hover { background: #e8eff8; }
.tc-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tc-item-name { font-size: 13.5px; line-height: 1.35; }
.tc-item-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
    font-size: 12px; color: var(--tc-muted);
    font-variant-numeric: tabular-nums;
}
.tc-item-num { color: var(--tc-ink); font-weight: 500; }

.tc-item-state {
    flex: none; position: relative;
    width: 24px; height: 24px; border-radius: 50%;
    border: 1.5px solid var(--tc-line-strong);
    color: var(--tc-ink); background: #fff;
}
.tc-item-state::before,
.tc-item-state::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    background: currentColor; border-radius: 1px;
}
.tc-item-state::before { width: 10px; height: 1.5px; margin: -0.75px 0 0 -5px; }
.tc-item-state::after  { width: 1.5px; height: 10px; margin: -5px 0 0 -0.75px; }
.tc-item:hover .tc-item-state { border-color: var(--tc-ink); background: var(--tc-ink); color: #fff; }

.tc-item.is-added .tc-item-name { color: var(--tc-ok); font-weight: 500; }
.tc-item.is-added .tc-item-state,
.tc-item.is-added:hover .tc-item-state { background: var(--tc-ok); border-color: var(--tc-ok); color: #fff; }
.tc-item.is-added .tc-item-state::before { width: 5px; height: 1.8px; margin: 1px 0 0 -5px; transform: rotate(45deg); }
.tc-item.is-added .tc-item-state::after { width: 1.8px; height: 10px; margin: -5px 0 0 1.5px; transform: rotate(45deg); }
.tc-item.just-added { animation: tc-pulse .6s ease-out; }
@keyframes tc-pulse { 0% { background: var(--tc-ok-soft); } 100% { background: transparent; } }

.tc-mark { background: var(--tc-mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.tc-search-empty { margin: 24px 16px; color: var(--tc-muted); text-align: center; font-size: 13px; }

/* Часто используемые — закреплены внизу панели, по умолчанию свёрнуты */
.tc-freq {
    flex: none;
    border-top: 1px solid var(--tc-panel-border);
    background: var(--tc-head-bg);
    border-radius: 0 0 11px 11px;
    max-height: 45%;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.tc-freq summary {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 14px;
    cursor: pointer; list-style: none;
    font-size: 13px; font-weight: 500; color: var(--tc-muted);
}
.tc-freq summary::-webkit-details-marker { display: none; }
.tc-freq summary::before {
    content: ""; width: 6px; height: 6px;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: rotate(-135deg); margin: 3px 4px 0 3px;
    transition: transform .15s;
}
.tc-freq[open] summary::before { transform: rotate(45deg); margin-top: -3px; }
.tc-freq summary:hover { color: var(--tc-ink); }
.tc-freq-list { background: var(--tc-surface); }
.tc-catalog.tc-searching .tc-freq { display: none; }

/* ---------- центр: выбранные работы ---------- */

.tc-sheet { display: flex; flex-direction: column; overflow: hidden; }

.tc-sheet-head {
    flex: none;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 20px;
    min-height: 60px;
    background: var(--tc-head-bg);
    border-bottom: 1px solid var(--tc-panel-border);
    border-radius: 11px 11px 0 0;
}
.tc-btn-clear {
    padding: 7px 12px;
    border: 1px solid var(--tc-line-strong); border-radius: 8px;
    background: #fff; color: var(--tc-warn);
    font-size: 13px; font-weight: 500; cursor: pointer;
}
.tc-btn-clear:hover { border-color: var(--tc-warn); background: var(--tc-warn-soft); }

/* Клиент и объект — общие для КП и наряда (правый блок, под суммой) */
.tc-client-bar {
    flex: none;
    display: flex; flex-direction: column; gap: 10px;
    margin: 14px 16px 0;
    padding: 12px 14px;
    border: 1px solid var(--tc-line-strong);
    border-radius: 10px;
    background: #fff;
}
.tc-client-bar .tc-client-field { margin-bottom: 0; }
.tc-client-bar .tc-field-label { margin-bottom: 4px; }

.tc-sheet-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.tc-sheet-group + .tc-sheet-group { border-top: 0; }
.tc-sheet-group-head {
    position: sticky; top: 0; z-index: 1;
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 9px 20px;
    background: var(--tc-ink);
    border-bottom: 0;
    font-size: 13px; font-weight: 600; color: #fff;
    font-variant-numeric: tabular-nums;
}
.tc-sheet-group-sum { white-space: nowrap; }

.tc-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto 92px 32px;
    align-items: center;
    gap: 12px;
    padding: 11px 12px 11px 20px;
    border-bottom: 1px solid var(--tc-line);
    background: #fff;
}
.tc-sheet-group:last-child .tc-row:last-child { border-bottom: 0; }
.tc-row:hover { background: #fafcfe; }
.tc-row.is-flash { animation: tc-flash 1.2s ease-out; }
@keyframes tc-flash { 0% { background: var(--tc-ok-soft); } 100% { background: #fff; } }

.tc-row-num { font-size: 12.5px; font-weight: 500; color: var(--tc-muted); font-variant-numeric: tabular-nums; }
.tc-row-name { font-weight: 600; line-height: 1.35; color: var(--tc-text); }
.tc-row-meta {
    display: flex; flex-wrap: wrap; gap: 2px 14px;
    margin-top: 3px;
    font-size: 12px; color: var(--tc-muted);
    font-variant-numeric: tabular-nums;
}

.tc-qty-wrap { display: flex; align-items: center; gap: 8px; }
.tc-qty {
    display: inline-flex; align-items: stretch;
    border: 1px solid var(--tc-line-strong); border-radius: 8px;
    background: #fff; overflow: hidden;
}
.tc-qty:focus-within { border-color: var(--tc-ink); box-shadow: 0 0 0 3px rgba(28, 53, 94, .14); }
.tc-step {
    width: 30px; border: 0; background: var(--tc-surface-2);
    color: var(--tc-ink); font-size: 16px; line-height: 1; cursor: pointer;
}
.tc-step:hover { background: var(--tc-line); }
.tc-qty .inp-volume-grid {
    width: 58px; height: 34px;
    border: 0; padding: 0 4px;
    text-align: center; font-weight: 600; color: var(--tc-ink);
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield; appearance: textfield;
    background: transparent;
}
.tc-qty .inp-volume-grid:focus { outline: none; }
.tc-qty .inp-volume-grid::-webkit-outer-spin-button,
.tc-qty .inp-volume-grid::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tc-qty-unit { min-width: 38px; font-size: 12px; color: var(--tc-muted); }

.tc-row-sum { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tc-row.is-zero .tc-row-sum { color: var(--tc-warn); }
.tc-row.is-zero .tc-qty { border-color: var(--tc-warn); }

.tc-row-remove {
    width: 30px; height: 30px;
    border: 0; border-radius: 8px; background: transparent;
    color: var(--tc-muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.tc-row-remove:hover { background: var(--tc-warn-soft); color: var(--tc-warn); }

.tc-badge-min2 {
    display: inline-block; vertical-align: 1px;
    padding: 1px 7px; border-radius: 10px;
    background: var(--tc-warn-soft); color: var(--tc-warn);
    font-size: 11px; font-weight: 600; white-space: nowrap;
}

.tc-empty { padding: 72px 24px; text-align: center; }
.tc-empty-title { margin: 0 0 6px; font-size: 16px; font-weight: 600; color: var(--tc-ink); }
.tc-empty-text { margin: 0 auto; max-width: 340px; color: var(--tc-muted); }
.tc-only-mobile { display: none; }

/* ---------- правая панель: итоги ---------- */

.tc-summary { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }

.tc-total {
    flex: none;
    padding: 16px 20px;
    background: var(--tc-ink);
    color: #fff;
    border-radius: 11px 11px 0 0;
}
.tc-total-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tc-total-label { font-size: 13px; color: rgba(255,255,255,.75); }
.tc-total-count {
    padding: 2px 10px;
    border-radius: 12px;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 12.5px; font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tc-total-value {
    margin-top: 2px;
    font-size: 34px; font-weight: 600; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums; line-height: 1.15;
}
.tc-total-cur { font-size: 16px; font-weight: 500; color: rgba(255,255,255,.75); letter-spacing: 0; }
.tc-total-meta {
    display: flex; gap: 16px; margin-top: 8px;
    font-size: 13px; color: rgba(255,255,255,.88);
    font-variant-numeric: tabular-nums;
}

.tc-warning {
    margin: 12px 16px 0;
    padding: 10px 12px;
    border: 1px solid #efc4b3;
    border-radius: 8px;
    background: var(--tc-warn-soft);
    color: var(--tc-warn);
    font-size: 13px; font-weight: 500;
}

/* Вкладки: активная — залитая, неактивная — прозрачная */
.tc-tabs {
    display: flex; gap: 4px;
    margin: 14px 16px 0;
    padding: 4px;
    background: var(--tc-app-bg);
    border-radius: 10px;
}
.tc-tab {
    flex: 1;
    padding: 8px;
    border: 0; border-radius: 7px;
    background: transparent;
    font-size: 13px; font-weight: 600; color: var(--tc-muted);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.tc-tab:hover { color: var(--tc-ink); background: rgba(255,255,255,.55); }
.tc-tab.active,
.tc-tab.active:hover { background: var(--tc-ink); color: #fff; box-shadow: 0 1px 3px rgba(20, 40, 74, .3); }

.tc-tab-panel {
    margin: 10px 16px 16px;
    padding: 12px 14px 14px;
    border: 1px solid var(--tc-line-strong);
    border-radius: 10px;
    background: #fff;
}

.tc-kt-row {
    display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 8px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--tc-line);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.tc-kt-idx { color: var(--tc-muted); }
.tc-kt-val { font-weight: 600; white-space: nowrap; }
.tc-kt-row.is-empty { color: var(--tc-muted); }
/* Пустая группа КП — красный бейдж «boş», чтобы менеджер ещё раз проверил, не забыл ли он её */
.tc-kt-row.is-empty .tc-kt-name { color: var(--tc-muted); }
.tc-kt-empty {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 10px;
    background: var(--tc-warn-soft);
    border: 1px solid #efc4b3;
    color: var(--tc-warn);
    font-size: 11.5px; font-weight: 600;
    line-height: 1.4;
}

.tc-kt-total {
    display: flex; justify-content: space-between; align-items: baseline;
    margin: 12px 0 4px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}
.tc-kt-total strong { font-size: 17px; color: var(--tc-ink); }

.tc-note,
.tc-muted { margin-top: 10px; font-size: 12.5px; color: var(--tc-muted); }
.tc-note { padding: 8px 10px; border-radius: 8px; background: var(--tc-warn-soft); color: var(--tc-warn); }

.tc-field { display: block; margin-bottom: 14px; }
.tc-field-label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 500; color: var(--tc-muted); }
.tc-field input[type="text"],
.tc-field select,
.tc-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--tc-line-strong);
    border-radius: 8px;
    background: #fff;
}
.tc-field textarea { resize: vertical; min-height: 84px; font-size: 13px; }
.tc-field input[type="text"]:focus,
.tc-field select:focus,
.tc-field textarea:focus { outline: none; border-color: var(--tc-ink); box-shadow: 0 0 0 3px rgba(28, 53, 94, .14); }

.tc-field input[type="text"] { height: 38px; font-size: 13.5px; }
.tc-field textarea#naryad_installers { min-height: 0; line-height: 1.5; }
.tc-req { color: var(--tc-warn); font-weight: 600; }
.tc-optional { font-weight: 400; color: var(--tc-muted); opacity: .8; }

/* Строки монтажников: имя + часы */
.tc-installers { display: flex; flex-direction: column; gap: 6px; }
.tc-inst-row { display: flex; align-items: center; gap: 6px; }
.tc-inst-idx { flex: none; width: 16px; font-size: 12px; color: var(--tc-muted); text-align: right; font-variant-numeric: tabular-nums; }
.tc-inst-name,
.tc-inst-h {
    height: 36px;
    padding: 0 9px;
    border: 1px solid var(--tc-line-strong);
    border-radius: 8px;
    background: #fff;
    font-size: 13.5px;
}
.tc-inst-name { flex: 1; min-width: 0; }
.tc-inst-hours { flex: none; display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--tc-muted); }
.tc-inst-h {
    width: 52px; padding: 0 4px; text-align: center; font-weight: 600; color: var(--tc-ink);
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield; appearance: textfield;
}
.tc-inst-h::-webkit-outer-spin-button,
.tc-inst-h::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tc-inst-name:focus,
.tc-inst-h:focus { outline: none; border-color: var(--tc-ink); box-shadow: 0 0 0 3px rgba(28, 53, 94, .14); }
.tc-installers .is-invalid,
.tc-installers .is-invalid:focus {
    border-color: var(--tc-warn);
    background: var(--tc-warn-soft);
    box-shadow: 0 0 0 3px rgba(176, 68, 31, .12);
}
.tc-field input.is-invalid,
.tc-field input.is-invalid:focus,
.tc-field textarea.is-invalid,
.tc-field textarea.is-invalid:focus {
    border-color: var(--tc-warn);
    background: var(--tc-warn-soft);
    box-shadow: 0 0 0 3px rgba(176, 68, 31, .12);
}
.tc-fields-error {
    margin-bottom: 12px;
    padding: 9px 11px;
    border: 1px solid #efc4b3;
    border-radius: 8px;
    background: var(--tc-warn-soft);
    color: var(--tc-warn);
    font-size: 12.5px; font-weight: 500;
}

.tc-metrics { margin-bottom: 14px; }
.tc-metric {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--tc-line);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.tc-metric span { color: var(--tc-muted); }
.tc-metric.is-accent strong { color: var(--tc-warn); }

.tc-btn {
    display: block; width: 100%;
    margin-top: 10px;
    padding: 11px 14px;
    border-radius: 8px;
    font-weight: 600; cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.tc-btn-outline { border: 1px solid var(--tc-ink); background: #fff; color: var(--tc-ink); }
.tc-btn-outline:hover { background: var(--tc-ink); color: #fff; }
.tc-btn-primary { border: 1px solid var(--tc-ok); background: var(--tc-ok); color: #fff; }
.tc-btn-primary:hover { background: #11704b; border-color: #11704b; }
.tc-btn:disabled { opacity: .6; cursor: wait; }

/* ---------- коммерческие предложения ---------- */

.tc-btn-ghost {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px dashed var(--tc-line-strong); background: var(--tc-surface-2); color: var(--tc-ink);
}
.tc-btn-ghost:hover { border-style: solid; border-color: var(--tc-ink); background: #fff; }
.tc-btn-ghost svg { width: 16px; height: 16px; }

.tc-kp-banner {
    flex: none;
    padding: 10px 20px;
    background: #eef4fc;
    border-bottom: 1px solid var(--tc-panel-border);
    box-shadow: inset 3px 0 0 var(--tc-ink);
    font-size: 13px;
}
.tc-kp-banner-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--tc-muted); font-variant-numeric: tabular-nums; }
.tc-kp-number { color: var(--tc-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tc-kp-banner-note { margin-top: 3px; color: var(--tc-muted); }
.tc-kp-dirty { color: var(--tc-warn); font-weight: 500; }

.tc-kp-status {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.tc-kp-status.is-pending  { background: #e7eef8; color: var(--tc-ink); }
.tc-kp-status.is-accepted { background: var(--tc-ok-soft); color: var(--tc-ok); }
.tc-kp-status.is-expired  { background: #f0f1f3; color: var(--tc-muted); }
.tc-kp-status.is-rejected { background: var(--tc-warn-soft); color: var(--tc-warn); }

.tc-price-diff { color: var(--tc-warn); }

/* Окно со списком КП */
.tc-modal-wrap {
    position: fixed; inset: 0; z-index: 10010;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    font-family: var(--tc-font); color: var(--tc-text); font-size: 14px; line-height: 1.45;
}
.tc-modal-wrap[hidden] { display: none; }
.tc-modal-wrap * { box-sizing: border-box; }
.tc-modal-backdrop { position: absolute; inset: 0; background: rgba(20, 40, 74, .45); }
.tc-modal {
    position: relative;
    display: flex; flex-direction: column;
    width: min(720px, 100%); max-height: min(760px, 100%);
    background: #fff;
    border: 1px solid var(--tc-panel-border);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(20, 40, 74, .3);
    overflow: hidden;
}
.tc-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    background: var(--tc-head-bg);
    border-bottom: 1px solid var(--tc-panel-border);
}
.tc-modal-close {
    width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent;
    color: var(--tc-muted); font-size: 15px; cursor: pointer;
}
.tc-modal-close:hover { background: var(--tc-line); color: var(--tc-text); }
.tc-modal-search { margin: 12px 18px 6px; }
.tc-modal-search input { font-family: inherit; font-size: 14px; color: inherit; }
.tc-modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 18px 18px; }
.tc-modal-msg { margin: 28px 0; text-align: center; color: var(--tc-muted); }
.tc-modal-msg.is-error { color: var(--tc-warn); }
body.tc-modal-open { overflow: hidden; }

.tc-kp-row {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--tc-line);
}
.tc-kp-row-main { flex: 1; min-width: 0; }
.tc-kp-row-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.tc-kp-row-total { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tc-kp-row-client { margin-top: 3px; font-weight: 500; }
.tc-kp-row-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 2px; font-size: 12px; color: var(--tc-muted); }
.tc-kp-open {
    flex: none;
    padding: 8px 16px; border: 1px solid var(--tc-ink); border-radius: 8px;
    background: #fff; color: var(--tc-ink); font: inherit; font-weight: 600; cursor: pointer;
}
.tc-kp-open:hover { background: var(--tc-ink); color: #fff; }
.tc-kp-more {
    display: block; width: 100%; margin-top: 12px; padding: 10px;
    border: 1px dashed var(--tc-line-strong); border-radius: 8px;
    background: var(--tc-surface-2); color: var(--tc-ink); font: inherit; font-weight: 500; cursor: pointer;
}

@media (max-width: 600px) {
    .tc-modal-wrap { padding: 0; }
    .tc-modal { width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; }
    .tc-kp-row { align-items: flex-start; }
    .tc-kp-banner { padding: 10px 14px; }
}

/* ---------- средние экраны ---------- */

.tc-mobile-bar,
.tc-backdrop { display: none; }

@media (max-width: 1279px) and (min-width: 1024px) {
    .tc-app { grid-template-columns: 270px minmax(0, 1fr) 300px; gap: 12px; padding: 12px; }
    .tc-row { grid-template-columns: minmax(0, 1fr) auto 84px 30px; padding-left: 16px; }
    .tc-row-num { display: none; }
    .tc-qty-unit { display: none; }
}

/* ---------- телефон и планшет: каталог выезжает слева, итоги внизу ---------- */

@media (max-width: 1023px) {
    .tc-app {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        padding: 10px 10px 90px;
    }

    .tc-brand-sub { display: none; }
    .tc-brand-title { font-size: 17px; }
    .tc-logo { height: 38px; padding: 0 12px; }
    .tc-logo-svg { height: 20px; }
    .tc-brand-text { padding-left: 10px; }
    .tc-apphead { gap: 8px; }
    .tc-back { padding: 7px 12px 7px 8px; }

    /* Плавная прокрутка на телефоне: без теней и обрезки скруглённых углов у длинных блоков,
       закрытый каталог и затемнение вообще не отрисовываются */
    .tc-panel { box-shadow: none; }
    .tc-sheet, .tc-summary, .tc-sheet-scroll { overflow: visible; }
    .tc-sheet-scroll { overscroll-behavior: auto; }
    .tc-sheet-head { border-radius: 11px 11px 0 0; }

    .tc-catalog {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        z-index: 10001;
        width: min(440px, 92vw);
        border-radius: 0 12px 12px 0;
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform .22s ease, visibility 0s linear .22s;
    }
    .tc-catalog-head, .tc-freq { border-radius: 0; }
    body.tc-drawer-open .tc-catalog {
        transform: none;
        visibility: visible;
        transition: transform .22s ease, visibility 0s;
        box-shadow: 0 10px 40px rgba(20, 40, 74, .3);
    }
    body.tc-drawer-open { overflow: hidden; }
    .tc-catalog-body { overscroll-behavior: contain; }
    /* Каталог-«шторка» не должен прокручиваться целиком: иначе браузер при фокусе/прокрутке к элементу
       сдвигает её вверх, и заголовок, поиск и первая группа уходят за край экрана.
       overflow: clip запрещает такую прокрутку (hidden — нет) */
    .tc-catalog { overflow: clip; }
    /* Длинные русские надписи («Развернуть», «Готово») не должны распирать шапку каталога */
    .tc-catalog-head .tc-panel-titlebar { flex-wrap: wrap; row-gap: 8px; }
    .tc-catalog-head .tc-panel-title { flex: 1 1 auto; min-width: 0; }

    .tc-drawer-done {
        display: inline-block;
        padding: 7px 14px; border: 0; border-radius: 8px;
        background: var(--tc-ink); color: #fff; font-weight: 600; cursor: pointer;
    }

    .tc-item { padding-top: 11px; padding-bottom: 11px; }

    .tc-backdrop {
        position: fixed; inset: 0; z-index: 10000;
        background: rgba(20, 40, 74, .45);
    }
    body.tc-drawer-open .tc-backdrop { display: block; }

    .tc-mobile-bar {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 9999;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-top: 1px solid var(--tc-panel-border);
    }
    .tc-mobile-sum { display: flex; flex-direction: column; line-height: 1.2; font-variant-numeric: tabular-nums; }
    .tc-mobile-sum span { font-size: 12px; color: var(--tc-muted); }
    .tc-mobile-sum strong { font-size: 18px; color: var(--tc-ink); }
    .tc-mobile-add {
        padding: 12px 18px; border: 0; border-radius: 10px;
        background: var(--tc-ink); color: #fff;
        font-weight: 600; font-size: 15px; cursor: pointer;
    }

    .tc-only-desktop { display: none; }
    .tc-only-mobile { display: block; }

    .tc-sheet-head { padding: 12px 14px; }
    .tc-sheet-group-head { position: static; padding: 9px 14px; }

    .tc-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "main remove"
            "qty  sum";
        gap: 8px 12px;
        padding: 12px 12px 12px 14px;
    }
    .tc-row-num { display: none; }
    .tc-row-main { grid-area: main; }
    .tc-qty-wrap { grid-area: qty; }
    .tc-row-sum { grid-area: sum; font-size: 15px; }
    .tc-row-remove { grid-area: remove; align-self: start; }
    .tc-step { width: 40px; font-size: 18px; }
    .tc-qty .inp-volume-grid { height: 40px; width: 64px; font-size: 16px; }
}

@media (max-width: 560px) {
    .tc-brand-text, .tc-user-text { display: none; }
    /* Шапка должна помещаться в ширину экрана: иначе страница становится шире телефона,
       браузер меняет масштаб и выдвижной каталог «уезжает» вверх (было в русской версии) */
    .tc-back-text { display: none; }
    .tc-back { padding: 7px 9px; }
    .tc-apphead-right { gap: 8px; min-width: 0; }
    .tc-lang a { padding: 4px 7px; }
    .tc-apphead { gap: 8px; padding: 2px 0 0; }
    .tc-logo { padding: 0 10px; }
    /* нижняя панель: «+ Добавить работу» длиннее по-русски — кнопка может сжиматься */
    .tc-mobile-sum { min-width: 0; }
    .tc-mobile-add { flex: 0 1 auto; min-width: 0; padding: 12px 14px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .tc-user { padding: 3px; gap: 2px; }
    .tc-login { padding: 7px 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .tc-app *, .tc-app *::before, .tc-app *::after { animation: none !important; transition: none !important; }
}

/* ---------- печать (документы печатаются через iframe в script.js) ---------- */

#motech_print_area { display: none !important; }

@media print {
    .tc-app, .tc-mobile-bar, .tc-backdrop { display: none !important; }
}
