:root {
  --bg: #eef0f3; --panel: #fbfbfa; --line: #e3e6ea; --line2: #eff1f4; --text: #2b3340; --muted: #6b7686;
  --brand: #2b3d57; --accent: #4c76be; --danger: #ab4343; --warn-bg: #f7f2de; --sel: #f0e8b7;
  --row-h: 40px; --viber: #8579d9; --head-h: 56px; --font: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: var(--font)/1.35 "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
/* Без чорної рамки фокуса: поле лише трохи підсвічується кольором (власник: «прямокутник прибрати скрізь»). */
input:focus, select:focus, textarea:focus, button:focus { outline: none; }
input:focus, textarea:focus { border-color: var(--accent); }

/* ---------- кнопки ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 4px 10px; cursor: pointer;
  white-space: nowrap; line-height: 18px; }
.btn:hover { border-color: #bdc3cb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:disabled { background: #b4c2dd; border-color: #b4c2dd; cursor: default; }
.btn.danger { color: var(--danger); }
.btn.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; }
.btn.small { padding: 1px 7px; font-size: 12px; }
.ico { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 5px; text-decoration: none; font-size: 13px; border: 1px solid transparent; flex: none; }
.ico:hover { opacity: .75; }
.ico svg { width: 15px; height: 15px; }

/* ---------- шапка ---------- */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: var(--head-h);
  padding: 0 14px; background: var(--brand); color: #fff; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; white-space: nowrap; display: flex; align-items: center; gap: 7px; }
.brand img { width: 26px; height: 30px; display: block; }
.logo-big { display: block; width: 220px; max-width: 100%; margin: 0 auto 10px; }
.brand span { font-weight: 400; opacity: .7; font-size: 12px; margin-left: 3px; }
.brand.big { font-size: 22px; color: var(--brand); margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; }
.tab { background: none; border: 0; color: #cfd7e4; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
/* Активна вкладка — підкреслення, як у F-GAZY (без прямокутника). */
.tab:hover { color: #fff; }
.tab.active { color: #fff; box-shadow: inset 0 -2px 0 #72b5c8; border-radius: 0; }
/* Колір тексту — явно: інакше поле бере білий колір шапки і набране не видно. */
.search { flex: 1; max-width: 420px; border: 0; border-radius: 6px; padding: 7px 10px; color: var(--text); background: var(--panel); }
.me { margin-left: auto; display: flex; align-items: center; gap: 6px; white-space: nowrap; min-width: 0; }
/* Довге ім'я користувача не виштовхує «Вийти» за край екрана. */
#me-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.me form { margin: 0; }
.me .btn.link { color: #cfd7e4; }

/* ---------- фільтри ---------- */
.filters, .stages { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 0; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 3px 10px; cursor: pointer;
  white-space: nowrap; }
.chip b { font-weight: 600; color: var(--muted); margin-left: 4px; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.active b { color: #cfd7e4; }
/* Воронка — на всю ширину екрана, етапи однакові, між ними стрілки. */
.stages { padding-top: 6px; padding-bottom: 8px; flex-wrap: nowrap; align-items: center; gap: 4px; overflow-x: auto;
  scrollbar-width: thin; }
.chip.stage { flex: 1 1 0; min-width: min-content; text-align: center; padding: 5px 6px; border: 1.5px solid color-mix(in srgb, var(--c) 45%, #fff);
  border-left: 6px solid var(--c); border-radius: 18px; background: color-mix(in srgb, var(--c) 8%, #fff);
  overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 4px; line-height: 1.15;
  white-space: normal; font-size: 12px; min-height: 36px; }
.chip.stage span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chip.stage.side { flex: 0.7 1 0; }
.stage-gap { flex: none; width: 2px; align-self: stretch; background: var(--line); margin: 2px 6px; border-radius: 2px; }
.chip.stage b { flex: none; margin: 0; color: var(--text); }
.chip.stage.active { background: var(--c); border-color: var(--c); color: #fff; }
.chip.stage.active b { color: #fff; }
.arrow-sep { color: #9fa6b0; flex: none; }
/* Кнопка дзвінка біля телефону (потім — через телефонію). */
.call-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 24px; border-radius: 6px;
  background: #388d5d; color: #fff; flex: none; margin-left: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.call-btn:hover { background: #2e774e; color: #fff; }
.call-btn svg { width: 14px; height: 14px; }
/* Етап — як випадаючий список. */
/* Як у F-GAZY: плашка 27px, світлий фон кольору етапу, кольорова смужка зліва, темний текст 12.5px, стрілка ▾. */
.stage-dd { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: calc(100% - 8px); height: 27px;
  margin: 3px 4px; padding: 0 8px 0 10px; border: 0; border-radius: 6px; font-size: 12.5px; font-weight: 600;
  background: color-mix(in srgb, var(--c) 13%, #fff); color: color-mix(in srgb, var(--c) 55%, #000);
  box-shadow: inset 4px 0 0 var(--c); cursor: pointer; overflow: hidden; white-space: nowrap; }
.stage-dd b { font-weight: inherit; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.stage-dd::after { content: "▾"; flex: none; font-size: 10px; opacity: .6; }
.stage-dd:hover { filter: brightness(.97); }
table.leads td.c-stage { padding: 0; }
/* Етап відділено від решти, як у F-GAZY. */
table.leads td.c-stage, table.leads th.c-stage { border-left: 2px solid #d6dadf; }
/* Монтажники, резерв об'єкта */
.sub-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 4px; flex-wrap: wrap; }
.sub-head h2 { margin: 0 8px 0 0; font-size: 18px; }
.sub-search { flex: 1; max-width: 380px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.sub-select { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--panel); }
#view-installers .hint, #view-objects .hint { padding: 0 14px; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; table-layout: fixed; }
table.grid th { position: sticky; top: var(--head-h); z-index: 10; background: #ebedf1; text-align: left; font-weight: 700;
  font-size: 12px; color: #1f2630; padding: 6px; border-bottom: 1px solid var(--line); }
table.grid td { height: var(--row-h); padding: 2px 6px; border-bottom: 1px solid var(--line2); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
table.grid td.edit { cursor: text; }
table.grid td.editing { padding: 0; overflow: visible; }
table.grid td.editing input, table.grid td.editing select { width: 100%; height: calc(var(--row-h) - 1px);
  border: 2px solid var(--accent); border-radius: 3px; padding: 1px 5px; background: var(--panel); }
.i-num { width: 46px; } .i-code { width: 64px; } .i-phone { width: 150px; } .i-level { width: 104px; } .i-rank { width: 82px; }
.i-orders { width: 104px; } .i-act { width: 46px; }
.stars { color: #be922d; letter-spacing: 1px; }
.cnt { border: 1px solid var(--line); background: var(--panel); border-radius: 5px; width: 22px; height: 20px; cursor: pointer; line-height: 16px; }
.cnt:hover { border-color: var(--accent); color: var(--accent); }
.i-orders b { display: inline-block; min-width: 28px; text-align: center; }
tr.obj-row { cursor: pointer; }
tr.obj-row:hover td { background: #f8f9fb; }
tr.obj-row.hidden-lead { cursor: default; }
tr.obj-row.hidden-lead:hover td { background: none; }
.pick-q { margin-bottom: 8px; }
.pick-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.pick { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 8px; cursor: pointer; }
.pick:hover { border-color: var(--accent); background: #f1f4f9; }
.modal label.pick { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--text); font-size: 13px; }
.modal label.pick input[type=checkbox] { display: inline-block; width: 16px; height: 16px; margin: 2px 0 0; padding: 0; flex: none; }
.modal label.pick.near { border-color: #c3d4eb; }
/* Меню вибору з одного кліку (Мова, Область, Рівень). */
.menu-list { max-height: 320px; overflow-y: auto; }
.menu .menu-q { margin: 0 0 4px; }
.menu button.mopt { display: flex; align-items: center; gap: 8px; }
.menu button.mopt.cur, .menu button.stage-opt.cur { background: #ecf1fa; font-weight: 600; }
.menu button[hidden] { display: none; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
/* Перевірити об'єкти */
.objcheck { max-width: 480px; }
.menu button.obj-hit { white-space: normal; line-height: 1.35; border-bottom: 1px solid var(--line2); border-radius: 0; }
.menu button.obj-hit .muted { display: block; font-size: 12px; }
.menu button.obj-hit.same { background: #fdf6f4; }
.ok-note { margin: 4px 10px 8px; color: #2e6a41; }
/* Підвантаження таблиці */
.more { text-align: center; padding: 10px; color: var(--muted); }
.chip.export { margin-left: auto; border-color: #a5bbab; color: #2e6a41; }
/* Фільтри над таблицею — однакової ширини (власник 05.10.2026): рівні колонки; довга назва — у 2 рядки по словах;
   на вужчому екрані кнопки переходять у другий ряд, але лишаються однаковими. */
#filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); }
#filters .chip { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 3px 6px;
  text-align: center; line-height: 1.15; }
#filters .chip b { margin-left: 0; flex: none; }
#filters .chip span { white-space: normal; }
#filters .chip.export { margin-left: 0; }
/* Власник 05.10.2026: верхні кнопки на 15% вищі, між рядами фільтрів і етапів — більше повітря. */
#filters { margin-bottom: 10px; }
#filters .chip { min-height: 27px; }

/* ---------- таблиця ---------- */
.table-wrap { padding: 0 14px 10px; }
table.leads td { font-size: 13px; }
.chip { font-size: 13px; }
table.leads { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; table-layout: fixed; }
table.leads thead th { position: sticky; top: var(--head-h); z-index: 10; background: #ebedf1; text-align: left;
  font-weight: 700; font-size: 12px; color: #1f2630; padding: 6px 6px; border-bottom: 1px solid var(--line); }
table.leads thead th:first-child { border-top-left-radius: 8px; }
table.leads thead th:last-child { border-top-right-radius: 8px; }
/* Ширини — частками екрана, тож таблиця займає будь-який монітор; на вужчих екранах ховаємо другорядні колонки. */
.c-num { width: 62px; } .c-date { width: 6%; } .c-first { width: 8%; } .c-last { width: 9%; } .c-lang { width: 50px; }
.c-phone { width: 150px; } .c-city { width: 7.5%; } .c-region { width: 8%; } .c-msg { width: 7.5%; }
.c-remind { width: 122px; } .c-stage { width: 12.5%; }
.flag { display: inline-flex; vertical-align: middle; }
.flag svg { width: 22px; height: 14px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.flag b { font-size: 11px; color: var(--muted); }
select.msg { width: 100%; border: 0; background: transparent; color: var(--viber); font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 2px 0; text-overflow: ellipsis; }
select.msg:hover { color: #6c5ebe; }
table.leads thead th.viber-head { color: var(--viber); }
/* «🔔 На сьогодні» — перша кнопка фільтрів, помітна: жирна, з червоним лічильником (власник 05.10.2026). */
#filters .chip.today-chip { font-weight: 700; border-color: #e6c2cc; }
#filters .chip.today-chip b { min-width: 20px; padding: 0 6px; border-radius: 10px; background: #eff1f4; color: var(--text); }
#filters .chip.today-chip.has b { background: #c64f75; color: #fff; }
#filters .chip.today-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
td.c-msg { padding-top: 0; padding-bottom: 0; }
table.leads td { height: var(--row-h); padding: 0 8px; border-top: 1px solid #d0d5db; border-bottom: 1px solid #ebedef; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
tr.lead { cursor: default; }
tr.lead.alt td { background: #fafbfc; }
tr.lead:hover td { background: #f8f9fb; }
tr.lead.current td { background: var(--sel); }
tr.lead.open td { background: #eef2fb; border-bottom-color: #d1dbed; }
td.edit { cursor: text; }
td.c-num { color: var(--muted); cursor: pointer; }
td.c-num .arrow { display: inline-block; width: 12px; color: #9fa6b0; transition: transform .1s; }
tr.open td.c-num .arrow { transform: rotate(90deg); color: var(--accent); }
td.toggle { cursor: pointer; }
.stage-pill { display: inline-block; padding: 1px 8px; border-radius: 10px; color: #fff; background: var(--c);
  font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.phone-cell { display: flex; align-items: center; gap: 2px; }
.phone-cell .num { flex: 1; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.badge { display: inline-block; font-size: 11px; padding: 0 5px; border-radius: 4px; margin-left: 4px;
  background: #eff1f4; color: #4f5661; vertical-align: 1px; }
.badge.dup { background: #f3e5d1; color: #734917; }
.badge.inc { background: #f8e7e7; color: #853232; }
.badge.stale { background: #ebe8f6; color: #65529d; }
.badge.ok { background: #e3efe6; color: #2a5e3a; }
.badge.warn { background: #f4ecd2; color: #735317; }
.chip.warn { border-color: #cfaf72; color: #735317; }
.chip.warn.active { background: #9d7439; border-color: #9d7439; color: #fff; }
.key-mark { color: #a34e2b; font-weight: 700; }
.key-hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.remind.overdue { color: var(--danger); font-weight: 600; }
.remind.none { color: var(--danger); }
tr.no-next td.c-remind { background: #fcf3f3; }
.muted { color: var(--muted); }
.empty { padding: 30px; text-align: center; color: var(--muted); background: var(--panel); border: 1px solid var(--line);
  border-top: 0; }
.foot { padding: 0 14px 20px; color: var(--muted); font-size: 12px; }

/* редактор у клітинці */
td.editing { padding: 0; overflow: visible; }
/* Правка зберігається: нове значення вже видно, поле вводу закрито — можна одразу правити далі. */
td.saving { color: var(--muted); font-style: italic; }
td.editing input, td.editing select { width: 100%; height: calc(var(--row-h) - 1px); border: 2px solid var(--accent);
  border-radius: 3px; padding: 1px 5px; background: var(--panel); }

/* ---------- розкритий рядок ---------- */
tr.card > td { padding: 0; background: #fcfcfd; border-bottom: 2px solid #d1dbed; white-space: normal; height: auto; }
.card-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line);
  background: #f4f7fb; }
.card-bar .sp { flex: 1; }
.card-bar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }
.card-badges { padding: 6px 10px 0; display: flex; flex-wrap: wrap; gap: 4px; }
.card-badges .badge { margin: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.card-grid { display: grid; grid-template-columns: .84fr 1.1fr .875fr 1.685fr; gap: 10px; padding: 10px; align-items: start; }
.blk { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.blk h4 { margin: 0 0 6px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.blk h4 .sp { flex: 1; }
.fld .sub-lab { padding-left: 10px; }
.fld { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 6px; align-items: center; margin-bottom: 4px; }
.fld > span { color: var(--muted); font-size: 12px; }
.fld input, .fld select, .fld textarea { width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px;
  background: var(--panel); min-width: 0; }
.fld.missing input, .fld.missing select { border-color: #e2aeae; background: #fdf8f8; }
.fld .ro { padding: 3px 0; }
.fld .pair { display: flex; gap: 4px; align-items: center; }
.fld .pair > * { flex: 1; min-width: 0; }
.fld .pair label { flex: none; display: flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.q-toggle { width: 100%; text-align: left; }
.q-progress { height: 6px; background: #eff1f4; border-radius: 3px; overflow: hidden; margin: 6px 0; }
.q-progress i { display: block; height: 100%; background: #418b57; }
.qual-group { border-radius: 6px; padding: 4px 6px; margin-bottom: 6px; }
.qual-group.q-empty { background: var(--warn-bg); }
.qual-group > b { display: block; font-size: 12px; margin-bottom: 2px; }
.qual-item { margin-bottom: 4px; }
.qual-item > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.qual-item select { width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; background: var(--panel); }
.tags { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 3px; }
.tag { display: inline-flex; align-items: center; gap: 2px; background: var(--accent); color: #fff; border-radius: 11px;
  padding: 0 2px 0 8px; font-size: 12px; line-height: 20px; }
.tag-x { border: 0; background: none; color: #fff; cursor: pointer; font-size: 14px; line-height: 18px; padding: 0 5px; border-radius: 9px; }
.tag-x:hover { background: rgba(255,255,255,.25); }
.opts { display: flex; flex-wrap: wrap; gap: 3px; }
.opt { border: 1px solid var(--line); background: var(--panel); border-radius: 11px; padding: 0 8px; font-size: 12px; cursor: pointer;
  line-height: 20px; }
.opt.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.own-input { margin-top: 3px; width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
.part { display: flex; gap: 4px; margin-bottom: 3px; }
.part input, .part select { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 5px; padding: 2px 4px; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: 4px 0; border-bottom: 1px dashed var(--line2); font-size: 12px; overflow-wrap: anywhere; }
.hist li .when { color: var(--muted); }
.hist li.comment .txt { background: #faf8eb; border-radius: 4px; padding: 2px 5px; display: inline-block; margin-top: 2px;
  white-space: pre-wrap; font-size: 13px; }
.hist li .txt { white-space: pre-wrap; }
.add-comment { display: flex; gap: 4px; margin-bottom: 6px; }
.add-comment textarea { flex: 1; min-height: 34px; resize: vertical; border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; }
.dirty-note { color: #734917; font-size: 12px; }

/* ---------- спливаючі вікна ---------- */
.pop { position: absolute; z-index: 50; background: var(--panel); border: 1px solid #cdd4de; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20,35,60,.18); padding: 10px; width: 300px; max-width: calc(100vw - 16px); overflow-wrap: anywhere; }
.pop h5 { margin: 0 0 8px; font-size: 13px; }
.pop label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.pop select, .pop input, .pop textarea { display: block; width: 100%; margin-top: 2px; border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 6px; color: var(--text); }
.pop .row { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.pop .err { color: var(--danger); font-size: 12px; margin-bottom: 6px; }
.menu { padding: 4px; width: auto; min-width: 200px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 10px; border-radius: 5px;
  cursor: pointer; }
.menu button:hover { background: #f1f4f9; }
.menu button.stage-opt { display: flex; align-items: center; gap: 8px; }
.menu .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(15,25,45,.35); display: flex; align-items: center;
  justify-content: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 10px; padding: 16px; width: 460px; max-width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  overflow-wrap: anywhere; }
.modal h3 { margin: 0 0 10px; font-size: 16px; }
.modal label { display: block; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.modal input, .modal textarea { display: block; width: 100%; margin-top: 2px; border: 1px solid var(--line); border-radius: 5px;
  padding: 6px 8px; color: var(--text); }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70; background: #1f2630; color: #fff;
  padding: 8px 14px; border-radius: 8px; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); }

/* ---------- шаблони ---------- */
#view-templates { padding: 14px; max-width: 900px; }
.tpl-head h2 { margin: 0 0 4px; }
.hint { color: var(--muted); margin: 0 0 10px; }
.tpl { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 10px 0; }
.tpl input, .tpl textarea { width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; }
.tpl textarea { min-height: 80px; margin-top: 6px; resize: vertical; }
.tpl .row { display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end; }

/* ---------- Binotel (дзвінки) ---------- */
#view-binotel { padding-bottom: 20px; }
#bn-body > .empty, .bn-pad { margin-left: 14px; margin-right: 14px; }
#bn-body .table-wrap { margin: 0 14px; }
.bn-periods { padding-top: 8px; padding-bottom: 12px; align-items: center; }
.bn-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.bn-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 0 14px 14px; }
.bn-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.bn-tile .bn-l { color: var(--muted); font-size: 12px; }
.bn-tile .bn-v { font-size: 24px; font-weight: 700; margin: 2px 0; }
.bn-tile .bn-s { color: var(--muted); font-size: 12px; }
.bn-tile.bad { border-color: #e8bfbf; background: #fdf8f8; } .bn-tile.bad .bn-v { color: #ab4343; }
.bn-tile.good .bn-v { color: #2a5e3a; }
.bn-h { margin: 14px 14px 6px; font-size: 15px; }
.bn-grid .bn-date { width: 130px; } .bn-grid .bn-dir { width: 100px; } .bn-grid .bn-emp { width: 150px; }
.bn-grid .bn-res { width: 230px; } .bn-grid .bn-t { width: 100px; } .bn-grid .bn-rec { width: 90px; } .bn-grid .bn-n { width: 90px; }
.bn-grid .bn-tr { width: 150px; }
.bn-field { display: block; margin: 8px 0; color: var(--muted); font-size: 12px; }
.bn-field input, .bn-field select { display: block; width: 100%; margin-top: 3px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
  font-size: 14px; color: var(--text); background: var(--panel); }
#modal.wide { width: 760px; max-width: calc(100vw - 24px); }
.bn-sum { background: #f3f7fc; border: 1px solid #dde6f3; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bn-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 55vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  line-height: 1.5; margin-bottom: 10px; }
.bn-grid a { color: var(--accent); text-decoration: none; } .bn-grid a:hover { text-decoration: underline; }
.bn-ok { color: #2a5e3a; font-weight: 600; } .bn-bad { color: #ab4343; font-weight: 600; }
/* «Дзвінки»: колонки фіксованої ширини займають 1050 px — на 820–1250 «Клієнт» стискався до 0 (не видно ні імені, ні «+ Лід»),
   а на 820 сторінка їхала вбік. Тепер таблиця гортається всередині себе, «Клієнт» — щонайменше ~230 px. */
#bn-body .table-wrap { overflow-x: auto; }
#bn-body table.bn-calls { min-width: 1280px; }
@media (max-width: 760px) { #bn-body .table-wrap { overflow-x: auto; margin: 0 6px; } #bn-body table.bn-grid { min-width: 1100px; } #bn-body table.bn-calls { min-width: 1280px; } .bn-tiles { grid-template-columns: 1fr 1fr; margin: 0 10px 12px; }
  .bn-tile .bn-v { font-size: 20px; } }

/* ---------- вхід ---------- */
/* Вхід: окреме вікно на тлі фото Mycond (будинок з тепловим насосом праворуч, світле тло ліворуч під форму). */
body.auth { display: flex; min-height: 100vh; min-height: 100dvh; align-items: center; justify-content: flex-start;
  padding: 16px 16px 16px max(16px, 7vw); background: #f6f6f6 url("/static/login-hero.webp") right center / auto 100% no-repeat; }
body.auth .auth-box { width: 380px; padding: 32px 30px 28px; border: 0; border-radius: 18px;
  background: rgba(255, 255, 255, .94); box-shadow: 0 24px 60px rgba(31, 59, 99, .16), 0 2px 8px rgba(31, 59, 99, .06); }
body.auth .auth-box h1 { margin: 6px 0 2px; font-size: 22px; font-weight: 700; color: var(--brand); text-align: center; }
body.auth .auth-box .sub { margin: 0 0 14px; color: var(--muted); text-align: center; }
body.auth .auth-box input { padding: 11px 12px; border-radius: 10px; font-size: 15px; }
body.auth .auth-box .btn { padding: 12px; border-radius: 10px; font-weight: 600; margin-top: 12px; }
@media (max-width: 1100px) { body.auth { background-size: cover; background-position: 75% center; } }
@media (max-width: 760px) {
  body.auth { flex-direction: column; justify-content: flex-start; padding: 0 16px 24px;
    background: #f6f6f6 url("/static/login-hero.webp") 82% top / auto 300px no-repeat; }
  body.auth .auth-box { width: 100%; max-width: 420px; margin: 250px auto 0; padding: 24px 20px; }
}
.auth-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 340px; max-width: 100%; }
.auth-box label { display: block; margin: 10px 0; color: var(--muted); font-size: 12px; }
.auth-box input { display: block; width: 100%; margin-top: 3px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
  font-size: 16px; color: var(--text); }
.auth-box .btn { width: 100%; padding: 9px; margin-top: 8px; font-size: 15px; }
.auth-error { color: var(--danger); min-height: 18px; }

/* ---------- бот (Viber через Wazzup) ---------- */
#view-bot { padding-bottom: 20px; }
#view-bot > .hint, #bot-body > .hint, #bot-body > .empty { margin-left: 14px; margin-right: 14px; }
#bot-body { max-width: 1200px; padding-top: 8px; }
.bot-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bot-status .badge { margin: 0; font-size: 12px; padding: 2px 8px; }
.bot-how { background: #f3f7fc; border: 1px solid #dde6f3; border-radius: 8px; padding: 8px 12px; margin: 0 14px 10px; max-width: 900px; }
.bot-how ol { margin: 4px 0 0; padding-left: 20px; }
.bot-how li { margin: 2px 0; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; position: relative; }
.switch.ro { cursor: default; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 34px; height: 20px; border-radius: 10px; background: #ccd2d9; position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--panel);
  transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + i { background: #418b5f; }
.switch input:checked + i::after { left: 16px; }
.switch input:disabled + i { opacity: .55; }
.switch.small { font-size: 12px; color: var(--muted); }
.switch.small i { width: 28px; height: 16px; }
.switch.small i::after { width: 12px; height: 12px; }
.switch.small input:checked + i::after { left: 14px; }
.bot-step { margin: 8px 14px; }
.bot-step.off { opacity: .6; }
.bot-step .bs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bot-step textarea { min-height: 54px; }
.bs-opts { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 4px; color: var(--muted); font-size: 12px; }
.bot-tools { display: flex; gap: 8px; margin: 0 14px 10px; flex-wrap: wrap; }
.bot-connect { margin: 10px 14px; max-width: 760px; }
.bot-connect h3 { margin: 0 0 6px; font-size: 15px; }
.bot-connect .bot-tools { margin: 0 0 10px; }
.bot-connect ol.hint { padding-left: 20px; }
.bot-key { display: flex; gap: 8px; margin-bottom: 6px; }
.bot-key input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.bot-grid .b-phone { width: 140px; } .bot-grid .b-date { width: 130px; } .bot-grid .b-kw, .bot-grid .b-ph { width: 70px; }
.bot-grid .b-price { width: 140px; } .bot-grid .b-lead { width: 70px; } .bot-grid .b-who { width: 110px; } .bot-grid .b-st { width: 190px; }
.bot-st { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eff1f4; color: #4f5661; white-space: nowrap; }
.bot-st.st-active { background: #e6f2eb; color: #2e6a41; }
.bot-st.st-armed { background: #ecf1fa; color: #45659d; }
.bot-st.st-paused { background: #f7f0de; color: #735317; }
.bot-st.st-done { background: #ebe8f6; color: #65529d; }
.bot-st.st-stopped { background: #f8e7e7; color: #853232; }
.bot-err { color: var(--danger); }
.modal .row .sp { flex: 1; }
.modal textarea[data-imp] { min-height: 160px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
/* Чат Viber у картці ліда */
.blk h4.htabs { gap: 2px; margin-bottom: 8px; }
.htab { border: 0; background: none; padding: 2px 8px 4px; font-weight: 600; color: var(--muted); cursor: pointer; border-radius: 0; }
.htab:first-child { padding-left: 0; }
.htab.on { color: var(--text); box-shadow: inset 0 -2px 0 #72b5c8; }
.bot-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; font-size: 12px; }
.bot-line .sp { flex: 1; }
.chat { max-height: 340px; min-height: 90px; overflow-y: auto; background: #f7f8fa; border: 1px solid var(--line2); border-radius: 6px;
  padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.chat-empty { margin: auto; }
.msg { max-width: 88%; }
.msg .b { white-space: pre-wrap; word-break: break-word; padding: 5px 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line);
  font-size: 12.5px; text-align: left; }
.msg .m { font-size: 11px; color: var(--muted); margin-top: 1px; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; text-align: right; }
.msg.out .b { background: #f1effb; border-color: #e0dbf4; }
.msg.out.by-bot .b { background: #e9f2ed; border-color: #cce1d4; }
.msg.queued .b { opacity: .7; border-style: dashed; }
.msg.err .b { border-color: #e6bbbb; background: #fdf6f6; }
.chat-send { display: flex; gap: 4px; margin-top: 6px; }
.chat-send textarea { flex: 1; min-height: 34px; resize: vertical; border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; }

/* ---------- великий екран: блоки розкритого рядка в ряд; вузький ноутбук — 2×2 ---------- */
/* Великі монітори — крупніше. */
/* До 2400px — розміри як у F-GAZY (13px, рядок 35px); лише дуже великі монітори — трохи крупніше. */
@media (min-width: 2400px) { :root { --font: 15px; --row-h: 44px; } table.leads td { font-size: 14px; } .c-phone { width: 152px; } }
/* 761–1400 px: усе в один рядок шапки не влазить (у адміна 9 вкладок + пошук + «+ Лід» + ім'я) — сторінка їхала вбік
   на 820–1301 px, а «Вийти» опинявся за краєм. Вкладки — другим рядом, який за потреби гортається сам. */
@media (max-width: 1400px) and (min-width: 761px) {
  .top { flex-wrap: wrap; height: auto; min-height: var(--head-h); padding-top: 6px; padding-bottom: 4px; row-gap: 2px; }
  .tabs { order: 10; flex-basis: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .tab { flex: none; white-space: nowrap; }
  .search { min-width: 0; }
}
@media (max-width: 1400px) { .arrow-sep { display: none; } .chip.stage { padding: 5px 4px; font-size: 11.5px; } .stage-gap { margin: 2px 2px; } }
/* Вужчі ноутбуки — ховаємо колонки, що є в розкритому рядку. */
@media (max-width: 1500px) and (min-width: 761px) { .c-date { display: none; } }
@media (max-width: 1300px) and (min-width: 761px) { .c-region, .c-lang { display: none; } }
@media (max-width: 1100px) and (min-width: 761px) { .c-msg, .c-city { display: none; } }
@media (max-width: 1250px) and (min-width: 761px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  :root { --head-h: 96px; }
  .top { flex-wrap: wrap; height: auto; min-height: var(--head-h); padding: 6px 10px calc(6px) 10px;
    padding-top: max(6px, env(safe-area-inset-top)); gap: 6px; }
  .search { order: 10; flex-basis: 100%; max-width: none; font-size: 16px; }
  .me #me-name { display: none; }
  /* Вкладок стало багато (05.10.2026, + «Binotel») — на телефоні рядок вкладок гортається вбік, сторінка не ширшає. */
  .tabs { min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; } .tab { flex: none; white-space: nowrap; }
  .filters, .stages { flex-wrap: nowrap; overflow-x: auto; padding-left: 10px; padding-right: 10px; }
  .chip.stage, .chip.stage.side { flex: none; min-width: 120px; max-width: 160px; }
  #filters { display: flex; } #filters .chip { flex: none; white-space: nowrap; padding: 6px 12px; } #filters .chip span { white-space: nowrap; }
  .call-btn { width: 44px; height: 34px; } .call-btn svg { width: 20px; height: 20px; }
  #view-installers .table-wrap, #view-objects .table-wrap, #view-bot .table-wrap, #view-mailing .table-wrap { overflow-x: auto; }
  .bot-grid { min-width: 640px !important; }
  .chat { max-height: 55vh; }
  .chat-send textarea { font-size: 16px; }
  .bot-key { flex-wrap: wrap; } .bot-key input { font-size: 16px; flex-basis: 100%; }
  table.grid { min-width: 900px; } table.grid th { position: static; }
  .chip { padding: 6px 12px; }
  .table-wrap { padding: 0 8px 10px; }
  table.leads, table.leads tbody { display: block; border: 0; background: none; }
  table.leads thead { display: none; }
  tr.lead { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas:
      "first last stage" "phone phone remind" "comment comment comment"; gap: 2px 6px; background: var(--panel); border: 1px solid var(--line);
    border-radius: 10px; padding: 8px 10px; margin-top: 8px; }
  tr.lead td { display: block; width: auto !important; min-width: 0; border: 0; height: auto; padding: 0; background: none !important; box-shadow: none !important; }
  tr.lead td.c-first, tr.lead td.c-last { white-space: normal; }
  tr.lead.current { box-shadow: 0 0 0 2px #d1bc51; }
  tr.lead.open { border-color: var(--accent); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  tr.lead td.c-num, tr.lead td.c-date, tr.lead td.c-lang, tr.lead td.c-city, tr.lead td.c-region,
  tr.lead td.c-msg { display: none; }
  tr.lead td.c-first { grid-area: first; font-weight: 600; font-size: 15px; }
  tr.lead td.c-last { grid-area: last; font-weight: 600; font-size: 15px; }
  tr.lead td.c-stage { grid-area: stage; text-align: right; }
  tr.lead .stage-dd { width: auto; max-width: 62vw; height: 30px; margin: 0; }
  tr.lead td.c-phone { grid-area: phone; }
  tr.lead td.c-remind { grid-area: remind; text-align: right; }
  tr.lead td.c-comment { grid-area: comment; color: var(--muted); white-space: normal; }
  .phone-cell .ico { width: 40px; height: 34px; border: 1px solid var(--line); background: var(--panel); }
  .phone-cell .ico svg { width: 20px; height: 20px; }
  tr.card { display: block; }
  tr.card > td { display: block; border: 1px solid var(--accent); border-top: 0; border-radius: 0 0 10px 10px; }
  .card-bar { gap: 8px; }
  .card-bar .btn { padding: 8px 10px; }
  .card-bar .sp, .card-bar .sep { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .fld { grid-template-columns: 1fr; gap: 2px; }
  input, select, textarea { font-size: 16px !important; }
  .opt { line-height: 30px; padding: 0 12px; font-size: 14px; }
  .pop { position: fixed; left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto; border-radius: 14px 14px 0 0;
    padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .pop .btn, .modal .btn { padding: 10px 16px; }
  .menu button { padding: 12px 14px; }
}

/* ---------- дашборд: воронка ---------- */
.db-tiles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 6px 14px 14px; }
.db-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 18px; min-width: 150px; text-align: center; }
.db-l { color: var(--muted); font-size: 12px; } .db-v { font-size: 26px; font-weight: 700; color: var(--brand); }
.db-funnel { max-width: 1100px; margin: 0 auto; padding: 0 14px; }
.db-row { display: grid; grid-template-columns: 220px 1fr 220px; align-items: center; gap: 12px; width: 100%;
  border: 0; background: none; padding: 4px 0; cursor: pointer; text-align: left; }
.db-row:hover .db-bar { filter: brightness(1.08); }
.db-name { text-align: right; font-weight: 500; }
.db-track { display: flex; justify-content: center; }
.db-bar { display: flex; align-items: center; justify-content: center; height: 40px; border-radius: 8px; min-width: 44px;
  transition: width .3s; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.db-bar b { font-size: 17px; font-weight: 700; }
.db-pct { color: var(--muted); font-size: 13px; }
.db-pct-m { display: none; font-style: normal; color: var(--muted); font-weight: 400; }
.db-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 6px; border-top: 1px dashed var(--line); padding-top: 10px; }
.db-hint { text-align: center; margin: 16px 14px; }
@media (max-width: 760px) {
  .db-row { grid-template-columns: 1fr; gap: 4px; }
  .db-name { text-align: center; font-size: 13px; }
  .db-pct { display: none; } .db-pct-m { display: inline; }
  .db-bar { height: 34px; }
  .db-tile { min-width: 0; flex: 1 1 40%; }
}
#view-dashboard .sub-head { justify-content: center; }

.obj-btns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.obj-btns .btn { white-space: normal; text-align: left; }
.obj-btns .obj-in { margin: 0; font-size: 12px; padding: 2px 8px; }

/* ---------- мейлінг ---------- */
.ml-box select, .ml-box #ml-tpl { display: block; width: 100%; margin-top: 3px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.ml-stages { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.ml-stage { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-left: 4px solid var(--c);
  border-radius: 8px; padding: 4px 10px; cursor: pointer; background: var(--panel); font-size: 13px; }
.ml-stage b { color: var(--muted); font-weight: 600; }
.ml-count { margin: 4px 0 10px; }
.ml-stage input { width: auto; margin: 0; flex: none; display: inline-block; }
.ml-stage span { white-space: nowrap; }

/* ---------- монтажники: розгорнутий рядок з анкетою ---------- */
.i-toggle { cursor: pointer; white-space: nowrap; }
.i-toggle .tg { color: var(--muted); margin-right: 4px; font-size: 11px; }
tr.inst-row.open > td { background: #eef1f6; }
.i-wide { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.inst-card > td { padding: 0; background: #f7f8fa; border-bottom: 2px solid #d1dbed; white-space: normal; height: auto; }
.inst-card-in { display: flex; gap: 12px; padding: 12px; align-items: flex-start; }
.inst-card-in .blk { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.inst-contacts { flex: 0 0 360px; min-width: 0; overflow-wrap: anywhere; }
.inst-survey { flex: 1; min-width: 0; }
.inst-card-in h4 { margin: 0 0 8px; font-size: 14px; }
.survey { display: grid; grid-template-columns: minmax(220px, 42%) minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.survey dt { color: var(--muted); font-size: 12.5px; }
.survey dd { margin: 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .inst-card-in { flex-direction: column; } .inst-contacts { flex: none; width: 100%; }
  .survey { grid-template-columns: 1fr; gap: 2px; } .survey dd { margin-bottom: 8px; }
}

/* ---------- зручність (власник 08.10.2026) ---------- */
/* Блок «Сьогодні»: прострочені / на сьогодні / нові — з чого почати день. */
.today-box { display: inline-flex; align-items: stretch; gap: 3px; padding: 2px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); flex: none; }
.tb-l { border: 0; background: none; font-weight: 700; padding: 0 9px; border-radius: 13px; cursor: pointer; color: var(--text); }
.tb-l:hover { color: var(--accent); }
.tb-l.active { background: var(--brand); color: #fff; }
.tile { --tc: var(--accent); display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 13px;
  padding: 2px 4px 2px 10px; cursor: pointer; background: color-mix(in srgb, var(--tc) 9%, var(--panel)); color: var(--text);
  font-size: 13px; white-space: nowrap; }
.tile:hover { border-color: color-mix(in srgb, var(--tc) 45%, var(--panel)); }
.tile b { min-width: 22px; padding: 0 6px; border-radius: 10px; background: var(--tc); color: #fff; text-align: center; font-weight: 700; }
.tile.zero b { background: var(--line2); color: var(--muted); }
.tile.part { border-color: color-mix(in srgb, var(--tc) 50%, var(--panel)); }
.tile.active { background: var(--tc); color: #fff; } .tile.active b { background: rgba(255,255,255,.25); color: #fff; }
.t-over { --tc: #b84f5c; } .t-due { --tc: #b88a32; } .t-new { --tc: #4c76be; }

/* Збережені фільтри — кнопки ★ після звичайних. */
.f-sep { width: 1px; background: var(--line); margin: 3px 2px; align-self: stretch; flex: none; }
.chip.view .v-x { font-style: normal; margin-left: 3px; padding: 0 4px; border-radius: 8px; color: var(--muted); opacity: 0; }
.chip.view:hover .v-x { opacity: 1; } .chip.view .v-x:hover { background: var(--line); color: var(--danger); }
.chip.view.active .v-x { opacity: 1; color: #cfd7e4; }
.chip.add-view { border-style: dashed; color: var(--muted); }
.chip.add-view:hover { color: var(--accent); border-color: var(--accent); }

/* «+1д / +3д» — з'являються на рядку під мишею (і на вибраному рядку). */
table.leads td.c-remind { position: relative; }
.snz { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: none; gap: 3px; padding-left: 4px; background: inherit; }
.snz button { border: 1px solid var(--line); background: var(--panel); border-radius: 5px; font-size: 11px; line-height: 16px;
  padding: 1px 5px; cursor: pointer; color: var(--accent); font-weight: 600; }
.snz button:hover { border-color: var(--accent); }
tr.lead:hover .snz, tr.lead.current .snz { display: flex; }
@media (hover: none) { tr.lead:hover .snz { display: none; } tr.lead.current .snz { display: flex; } }

/* Підказки — під «?». */
.hint-btn { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0;
  border-radius: 11px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer;
  font-weight: 700; font-size: 12px; flex: none; vertical-align: 2px; }
.hint-btn.wide { width: auto; padding: 0 9px; font-weight: 600; }
.hint-btn:hover, .hint-btn.on { color: var(--accent); border-color: var(--accent); }
.hint-row { margin: 0 14px 8px; }
#tpl-list ~ .hint, .tpl-head .hint { margin-top: 6px; }

/* Меню «⚙ Налаштування». */
.tab-set { white-space: nowrap; }
.set-menu { width: 220px; }
.theme-btn { font-size: 15px; padding: 2px 6px !important; }
@media (max-width: 760px) {
  .tab-set span { display: none; }
  .snz { position: static; transform: none; justify-content: flex-end; margin-top: 4px; padding: 0; background: none; }
  .snz button { padding: 4px 10px; font-size: 12px; }
  .chip.view .v-x { opacity: 1; }
}

/* ---------- темна тема (власник 08.10.2026) ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171b21; --panel: #20252d; --line: #333b47; --line2: #2a313b; --text: #d6dbe3; --muted: #8b95a3;
  --brand: #1c2737; --accent: #6f93cf; --danger: #dd7b7b; --warn-bg: #3a3322; --sel: #3a3826; --viber: #a69bea;
}
:where(html[data-theme="dark"]) :where(input, select, textarea) { background-color: #1b2027; border-color: var(--line); color: var(--text); }
html[data-theme="dark"] .btn:hover { border-color: #4a5462; }
html[data-theme="dark"] .btn.primary:disabled { background: #3a4760; border-color: #3a4760; color: #a8b3c4; }
html[data-theme="dark"] .chip.active, html[data-theme="dark"] .tb-l.active { background: #3a5584; border-color: #3a5584; }
html[data-theme="dark"] .chip.stage { border-color: color-mix(in srgb, var(--c) 50%, var(--panel)); background: color-mix(in srgb, var(--c) 16%, var(--panel)); }
html[data-theme="dark"] .chip.stage.active { background: var(--c); }
html[data-theme="dark"] .stage-dd { background: color-mix(in srgb, var(--c) 26%, var(--panel)); color: color-mix(in srgb, var(--c) 35%, #fff); }
html[data-theme="dark"] table.leads thead th, html[data-theme="dark"] table.grid th { background: #262c35; color: #c3cad5; }
html[data-theme="dark"] table.leads td { border-top-color: var(--line); border-bottom-color: var(--line2); }
html[data-theme="dark"] tr.lead.alt td { background: #232930; }
html[data-theme="dark"] tr.lead:hover td, html[data-theme="dark"] tr.obj-row:hover td { background: #2a313a; }
html[data-theme="dark"] tr.lead.current td { background: var(--sel); }
html[data-theme="dark"] tr.lead.open td, html[data-theme="dark"] tr.inst-row.open > td { background: #25304a; border-bottom-color: #3a4a69; }
html[data-theme="dark"] tr.card > td, html[data-theme="dark"] tr.inst-card > td { background: #1c2128; border-bottom-color: #3a4a69; }
html[data-theme="dark"] tr.no-next td.c-remind { background: #3a2729; }
html[data-theme="dark"] table.leads td.c-stage, html[data-theme="dark"] table.leads th.c-stage { border-left-color: var(--line); }
html[data-theme="dark"] .badge { background: #2e353f; color: #b8c0cc; }
html[data-theme="dark"] .badge.dup, html[data-theme="dark"] .badge.warn { background: #3d3222; color: #e0bf87; }
html[data-theme="dark"] .badge.inc { background: #42282a; color: #eba3a3; }
html[data-theme="dark"] .badge.stale { background: #312c46; color: #b9addf; }
html[data-theme="dark"] .badge.ok { background: #233a2b; color: #9fd0ae; }
html[data-theme="dark"] .chip.warn { border-color: #7a6233; color: #e0bf87; }
html[data-theme="dark"] .chip.export { border-color: #3c5a45; color: #9fd0ae; }
html[data-theme="dark"] .ok-note, html[data-theme="dark"] .bn-ok, html[data-theme="dark"] .bn-tile.good .bn-v { color: #9fd0ae; }
html[data-theme="dark"] .pop { border-color: var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.5); }
html[data-theme="dark"] .menu button:hover, html[data-theme="dark"] .pick:hover { background: #2a3340; }
html[data-theme="dark"] .menu button.mopt.cur, html[data-theme="dark"] .menu button.stage-opt.cur { background: #2b3850; }
html[data-theme="dark"] .menu button.obj-hit.same { background: #3a2c25; }
html[data-theme="dark"] .modal { box-shadow: 0 12px 40px rgba(0,0,0,.6); }
html[data-theme="dark"] .modal-bg { background: rgba(0,0,0,.55); }
html[data-theme="dark"] .toast { background: #303846; }
html[data-theme="dark"] .fld.missing input, html[data-theme="dark"] .fld.missing select { border-color: #7a4246; background: #33242a; }
html[data-theme="dark"] .hist li.comment .txt { background: #34311f; }
html[data-theme="dark"] .q-progress { background: var(--line2); }
html[data-theme="dark"] .chat { background: #1b2027; }
html[data-theme="dark"] .msg .b { background: #262c35; border-color: var(--line); }
html[data-theme="dark"] .msg.out .b { background: #2d2a44; border-color: #3e3a5e; }
html[data-theme="dark"] .msg.out.by-bot .b { background: #223529; border-color: #2f4a39; }
html[data-theme="dark"] .msg.err .b { background: #3a2427; border-color: #6a3a3e; }
html[data-theme="dark"] .bn-sum, html[data-theme="dark"] .bot-how { background: #1f2836; border-color: #314157; }
html[data-theme="dark"] .bn-tile.bad { background: #33242a; border-color: #6a3a3e; }
html[data-theme="dark"] .switch i { background: #4a5260; }
html[data-theme="dark"] .bot-st { background: #2e353f; color: #b8c0cc; }
html[data-theme="dark"] .bot-st.st-active { background: #233a2b; color: #9fd0ae; }
html[data-theme="dark"] .bot-st.st-armed { background: #263452; color: #a9c0ea; }
html[data-theme="dark"] .bot-st.st-paused { background: #3d3222; color: #e0bf87; }
html[data-theme="dark"] .bot-st.st-done { background: #312c46; color: #b9addf; }
html[data-theme="dark"] .bot-st.st-stopped { background: #42282a; color: #eba3a3; }
html[data-theme="dark"] .db-v { color: var(--text); }
html[data-theme="dark"] .key-mark { color: #e09a72; }
html[data-theme="dark"] .dirty-note { color: #e0bf87; }
html[data-theme="dark"] select.msg:hover { color: #c3baf5; }
/* Блок «Сьогодні» — зліва, решта фільтрів — у сітці однакових клітинок праворуч (як було). */
#filters { display: flex; align-items: flex-start; gap: 6px; }
#filters .f-grid { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; }
#filters .today-box { min-height: 31px; }
#filters .chip.add-view { flex: none; width: 34px; padding: 3px 0; font-size: 15px; }
#filters .f-sep { display: none; }
@media (max-width: 760px) {
  #filters .f-grid { display: contents; }
  #filters .f-sep { display: block; }
}
html[data-theme="dark"] .card-bar { background: #1f2630; }
html[data-theme="dark"] { --warn-bg: #2e2b22; }
/* Збережена кнопка: хрестик у кутку, назва не налазить. */
#filters .chip.view { position: relative; padding-right: 16px; }
#filters .chip.view .v-x { position: absolute; top: 1px; right: 2px; margin: 0; padding: 0 3px; line-height: 14px; font-size: 13px; }

/* ---------- монтажники: оцінка за критеріями (власник 08.10.2026) ---------- */
th.i-score { width: 96px; }
#inst-table th[data-isort] { cursor: pointer; user-select: none; }
#inst-table th[data-isort].sorted { color: var(--accent); }
td.i-score { white-space: nowrap; font-variant-numeric: tabular-nums; cursor: pointer; }
td.i-score b { font-weight: 700; }
.sc-left { margin-left: 4px; font-size: 11px; color: var(--muted); }
.sc-bar { display: block; height: 3px; margin-top: 2px; background: var(--line2); border-radius: 2px; overflow: hidden; }
.sc-bar i { display: block; height: 100%; background: #5f9a4a; }
.inst-col { flex: 0 0 440px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.inst-col .inst-contacts { flex: none; }
.inst-rating h4 .muted { font-weight: 500; }
.rt-row { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 8px; align-items: center; padding: 4px 0; border-top: 1px solid var(--line2); }
.rt-l { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; font-size: 13px; }
.rt-l small { flex-basis: 100%; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-auto { font-style: normal; font-size: 10.5px; padding: 0 5px; border-radius: 8px; background: var(--line2); color: var(--muted); }
.rt-row select { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; background: var(--panel); font-size: 12.5px; }
.rt-row select.rt-none { color: var(--muted); border-style: dashed; }
@media (max-width: 900px) {
  .inst-col { flex: none; width: 100%; }
  .rt-row { grid-template-columns: 1fr; }
}

/* ---------- монтажники: меню «Критерії» ---------- */
#inst-crit-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.crit-panel { padding: 0 14px 20px; max-width: 980px; }
.crit-bar { position: sticky; top: var(--head-h); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  background: var(--bg); padding: 8px 0; border-bottom: 1px solid var(--line); }
.crit-bar .sp { flex: 1; }
.crit-panel > .hint { margin: 8px 0 10px; max-width: 75ch; }
.crit-list { display: grid; gap: 8px; }
.crit-q { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: grid; gap: 5px; }
.crit-q.off { opacity: .6; }
.crit-h { display: flex; gap: 8px; align-items: flex-start; }
.crit-n { min-width: 1.6em; color: var(--muted); font-variant-numeric: tabular-nums; }
.crit-t { flex: 1; min-width: 0; font-weight: 600; }
.crit-o { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.crit-o input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: var(--bg); }
.crit-s { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.crit-s button { width: 28px; height: 26px; border: 0; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.crit-s button + button { border-left: 1px solid var(--line); }
.crit-s button:disabled { cursor: default; }
.crit-s button[aria-pressed="true"] { color: #fff; }
.crit-s .s0[aria-pressed="true"] { background: #b9505a; } .crit-s .s1[aria-pressed="true"] { background: #c27448; }
.crit-s .s2[aria-pressed="true"] { background: #b8923a; } .crit-s .s3[aria-pressed="true"] { background: #6f9a44; }
.crit-s .s4[aria-pressed="true"] { background: #3f8a52; }
@media (max-width: 760px) { .crit-o { grid-template-columns: 1fr; } .crit-bar { position: static; } }

th.i-trained { width: 84px; }
.tr-s { font-variant-numeric: tabular-nums; }
.tr-s.tr4, .tr-s.tr5 { color: #3f8a52; } .tr-s.tr0, .tr-s.tr1 { color: var(--danger); }

/* Монтажники — смуги через рядок і підсвітка під мишею, як у базі клієнтів (власник 08.10.2026). */
tr.inst-row.alt > td { background: #f1f3f6; }
tr.inst-row:hover > td { background: #e9edf3; }
tr.inst-row.open > td { background: #e3e9f3; }
html[data-theme="dark"] tr.inst-row.alt > td { background: #262c35; }
html[data-theme="dark"] tr.inst-row:hover > td { background: #2c333d; }
html[data-theme="dark"] tr.inst-row.open > td { background: #25304a; }
/* База клієнтів — ті самі помітніші смуги (власник 08.10.2026: «так же и в базе CRM»). */
tr.lead.alt td { background: #f1f3f6; }
tr.lead:hover td { background: #e9edf3; }
tr.lead.current td { background: var(--sel); }
tr.lead.open td { background: #e3e9f3; }
html[data-theme="dark"] tr.lead.alt td { background: #262c35; }
html[data-theme="dark"] tr.lead:hover td { background: #2c333d; }
html[data-theme="dark"] tr.lead.current td { background: var(--sel); }
html[data-theme="dark"] tr.lead.open td { background: #25304a; }

/* меню «Viber» */
table.grid.vb-data { width: 100%; min-width: 0 !important; }
table.grid.vb-data th { position: static; width: 170px; white-space: normal; }
table.grid.vb-data td { height: auto; padding: 6px; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.vb-data code { font-size: 12px; overflow-wrap: anywhere; }
@media (max-width: 760px) { table.grid.vb-data th { width: 105px; } }
