:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7680;
  --accent: #1d4ed8;
  --ok: #15803d;
  --error: #b91c1c;
  --border: #e2e5e9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 15px/1.5 "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Шапка в два ряда (v0.141, Булат 24.10.2026): сверху — логотип, быстрые кнопки, пользователь; снизу — разделы */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(15,23,42,.04); }
.topbar-main { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 8px 24px; min-height: 52px;
  background: #0f2742; color: #e2e8f0; }
.brand { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; font-weight: 600; color: #fff;
  text-decoration: none; font-size: 16px; letter-spacing: .2px; }
.brand-logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: #2563eb;
  color: #fff; font-size: 13px; font-weight: 700; }
.quick { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.quick-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; white-space: nowrap;
  color: #e2e8f0; text-decoration: none; border: 1px solid rgba(255,255,255,.18); font-size: 14px; }
.quick-btn:hover { background: rgba(255,255,255,.08); }
.quick-btn.quick-accent { background: #16a34a; border-color: #16a34a; color: #fff; font-weight: 600; }
.quick-btn.quick-accent:hover { background: #15803d; }
.topbar-main .task-badge { color: #e2e8f0; border-color: rgba(255,255,255,.18); margin-right: 0; padding: 5px 12px; font-size: 14px; }
.topbar-main .task-badge:hover { background: rgba(255,255,255,.08); }
.topbar-main .task-badge.lamp { color: #fecaca; border-color: #ef4444; }
.topbar-main .task-badge.lamp-new { color: #bbf7d0; border-color: #22c55e; background: rgba(34,197,94,.12); }
.user { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: #cbd5e1; }
.quick-link, .topbar-main .btn-link { color: #cbd5e1; text-decoration: none; font-size: 14px; }
.quick-link:hover, .topbar-main .btn-link:hover { color: #fff; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; }
.user-avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #334e73;
  color: #fff; font-weight: 600; font-size: 13px; }
.user-name { display: flex; flex-direction: column; line-height: 1.15; color: #fff; font-size: 14px; }
.user-name small { color: #94a3b8; font-size: 11px; }
.menu { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 0 16px; background: var(--surface); }
.menu a { color: var(--text); text-decoration: none; }

.content { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px; }

h1 { font-size: 22px; font-weight: 600; margin: 0 0 16px; }

.status { font-weight: 600; }
.status.ok { color: var(--ok); }
.status.error { color: var(--error); }
.muted { color: var(--muted); font-size: 13px; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.msg { padding: 8px 12px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.msg.error { border-color: var(--error); color: var(--error); }
.msg.success { border-color: var(--ok); color: var(--ok); }

.footer {
  padding: 12px 24px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Шапка: пользователь и выход */
.user { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
form.inline { display: inline; margin: 0; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }

/* Кнопки и формы */
.btn {
  display: inline-block; padding: 6px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  font: inherit; text-decoration: none;
}
.btn-danger { background: var(--surface); color: var(--error); border-color: var(--error); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 24px; }
.narrow { max-width: 380px; margin: 40px auto; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label, .filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }

/* Таблицы */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; }
.table tr.inactive td { color: var(--muted); }
.table .actions { white-space: nowrap; }
.nowrap { white-space: nowrap; }
.badge { margin-left: 6px; padding: 1px 6px; border-radius: 10px; font-size: 11px; background: #e0e7ff; color: var(--accent); }
.pager { display: flex; gap: 16px; align-items: center; margin-top: 12px; }

/* Широкие таблицы прокручиваются внутри себя, а не всей страницей */
.table-wrap { overflow-x: auto; }

@media (max-width: 700px) {
  .topbar-main, .content, .footer { padding-left: 16px; padding-right: 16px; }
}

/* Телефон (Булат 10.11.2026: «верх мешает — убрать»): шапка не липнет к экрану, верхняя панель — одна строка значков
   с прокруткой вбок; поиск, «Мой день», пользователь, «Выйти» — по кнопке ☰ */
.top-toggle { display: none; }

/* Мобильная версия (Булат 10.11.2026: «полноценную мобильную версию, кнопки нажимались, удобно с телефона»).
   Сверху одна строка: логотип, значки (задачи, чат, WhatsApp, почта, обращения) и ☰. По ☰ — панель на весь экран:
   «Звонок», «Мой день», поиск обращения, разделы меню списком (нажатие раскрывает раздел), пользователь, выход. */
@media (max-width: 700px) {
  .topbar { position: sticky; top: 0; }
  .topbar-main { flex-wrap: nowrap; gap: 6px; padding: 6px 10px; min-height: 0; }
  .brand-text { display: none; }
  .brand-logo { width: 32px; height: 32px; }
  .top-toggle { display: inline-grid; place-items: center; flex: 0 0 auto; width: 42px; height: 38px; border-radius: 8px; margin-left: auto;
    border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; font-size: 22px; cursor: pointer; order: 3; }
  .quick { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto; gap: 6px; scrollbar-width: none; }
  .quick::-webkit-scrollbar { display: none; }
  .quick-btn, .topbar-main .task-badge { padding: 6px 10px; font-size: 13px; }
  .quick .lead-search, .quick a.quick-btn, .topbar-main .user, .menu { display: none; }

  /* открытая панель ☰ */
  .topbar.top-open { position: fixed; inset: 0; z-index: 1000; overflow-y: auto; background: var(--surface); }
  .topbar.top-open .topbar-main { flex-wrap: wrap; position: sticky; top: 0; z-index: 2; }
  .topbar.top-open .quick { flex-wrap: wrap; overflow: visible; flex-basis: 100%; order: 4; }
  .topbar.top-open .quick a.quick-btn { display: inline-flex; padding: 9px 14px; font-size: 15px; }
  .topbar.top-open .quick .lead-search { display: block; width: 100%; }
  .topbar.top-open .quick .lead-search input[type=search] { width: 100%; font-size: 16px; padding: 10px 12px; }
  .topbar.top-open .topbar-main .user { display: flex; flex-basis: 100%; order: 5; padding: 6px 0 4px; }
  .topbar.top-open .menu { display: block; padding: 4px 0 40px; }
  .topbar.top-open .menu > a.nav-top, .topbar.top-open .nav-section > .nav-top {
    display: flex; width: 100%; justify-content: space-between; padding: 14px 16px; font-size: 16px;
    border-bottom: 1px solid var(--border); white-space: normal; text-align: left; }
  .topbar.top-open .nav-section { position: static; }
  .topbar.top-open .nav-drop, .topbar.top-open .nav-section:hover .nav-drop,
  .topbar.top-open .nav-section:focus-within .nav-drop { display: none; position: static; width: auto; column-count: 1;
    box-shadow: none; border: 0; border-radius: 0; padding: 0 0 6px 12px; background: #f8fafc; }
  .topbar.top-open .nav-section.open .nav-drop { display: block; }
  .topbar.top-open .nav-section.open .caret { transform: rotate(180deg); }
  .topbar.top-open .nav-drop a { padding: 12px 14px; font-size: 15px; border-bottom: 1px solid #eef2f7; border-radius: 0; }
  body.menu-open { overflow: hidden; }

  /* работа пальцем: кнопки и поля крупнее, поля 16px — iPhone не увеличивает страницу при вводе */
  .content { padding: 12px 12px 24px; }
  h1 { font-size: 20px; }
  .btn, button.btn { padding: 10px 14px; min-height: 40px; }
  .btn-link { padding: 6px 2px; }
  input, select, textarea { font-size: 16px; }
  .filters { gap: 8px; }
  .filters label { flex: 1 1 140px; }
  .card { padding: 14px; }
  .page-head { gap: 8px; }
  .table th, .table td { padding: 8px 8px; }
}

/* Плашка об ошибке синхронизации */
.alert { padding: 10px 24px; background: #fef2f2; color: var(--error); border-bottom: 1px solid #fecaca; font-weight: 600; }
.alert a { color: var(--error); }
.table tr.sub td { border-top: 0; padding-top: 0; font-size: 12px; }
.error-text { white-space: pre-wrap; color: var(--error); font-size: 12px; margin: 4px 0 0; }
.btn[disabled] { opacity: .5; cursor: default; }

/* Экран «Параметры» */
.params fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; background: var(--surface);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.params legend { padding: 0 6px; font-weight: 600; color: var(--text); }
.params input:disabled { background: var(--bg); color: var(--muted); }

/* Модуль ДЗ: показатели, статусы, реестр */
h2 { font-size: 17px; font-weight: 600; margin: 24px 0 10px; }
.calc-info { margin: -8px 0 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 20px; font-weight: 600; white-space: nowrap; }
.kpi a { font-size: 12px; }
.kpi-bad .kpi-value { color: var(--error); }
.num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.narrow-table { max-width: 760px; }
.table tr.total td { font-weight: 600; background: var(--bg); }
.table.registry td, .table.registry th { padding: 6px 8px; font-size: 13px; }
.table.registry tr.open td { background: #fffdf5; }
.small { font-size: 12px; }
.st { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; background: #eef2f7; }
.st-paid_on_time { background: #e3f4e8; color: var(--ok); }
.st-waiting { background: #eef2f7; color: var(--text); }
.st-overdue_1 { background: #fff7d6; }
.st-overdue_2 { background: #ffebd0; }
.st-overdue_3 { background: #fde2e4; color: #9f1239; }
.st-overdue_4 { background: #f4d6d5; color: #9f1239; }
.st-overdue_5 { background: #ebc4c2; color: #7f1d1d; }
.st-return { background: #ede9fe; color: #5b21b6; }
.badge.warn { background: #fff7d6; color: #92400e; }
.filters .check { flex-direction: row; align-items: center; gap: 6px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.form.compact { gap: 8px; }
.form.compact label { flex-direction: column; }
.table.kv td:first-child { color: var(--muted); }
ul.links { line-height: 2; }

/* Напоминания */
h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.btn-small { padding: 3px 10px; font-size: 13px; }
.btn-wa { background: #16a34a; border-color: #16a34a; }
.btn-outline { background: var(--surface); color: var(--accent); }
.remind { display: inline-flex; gap: 6px; }
.letter { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; font: 14px/1.5 "Segoe UI", Roboto, Arial, sans-serif; max-width: 760px; }
.alert-inline { padding: 8px 12px; border-radius: 6px; background: #fff7d6; color: #92400e; }

/* Второй ряд: разделы вкладками; большие разделы раскрываются в 2–3 колонки */
.nav-top { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 10px 12px 9px; font: inherit; font-size: 14px; color: #334155; cursor: pointer; text-decoration: none; white-space: nowrap; }
.nav-top .caret { font-size: 10px; color: var(--muted); }
.nav-top:hover, .nav-section:focus-within .nav-top, .nav-section:hover .nav-top { color: var(--accent); background: #f1f5ff; }
.nav-top.active, .nav-section.active > .nav-top { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
.nav-section { position: relative; }
.nav-drop { display: none; position: absolute; top: 100%; left: 0; z-index: 40; min-width: 240px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(15,23,42,.14); }
.nav-drop { overflow-y: auto; overscroll-behavior: contain; }
/* не помещается по высоте — колонки сеткой (у column-count лишнее уходит вбок), прокрутка колесом внутри */
.nav-section:hover .nav-drop.scroll, .nav-section:focus-within .nav-drop.scroll { display: grid; column-count: auto;
  grid-template-columns: repeat(var(--c, 1), minmax(0, 1fr)); gap: 0 8px; align-content: start; }
.nav-drop.cols-2 { --c: 2; } .nav-drop.cols-3 { --c: 3; }
.nav-drop.cols-2 { width: 520px; column-count: 2; column-gap: 8px; }
.nav-drop.cols-3 { width: 780px; column-count: 3; }
.nav-drop.right { left: auto; right: 0; }
.nav-section:hover .nav-drop, .nav-section:focus-within .nav-drop { display: block; }
.nav-drop a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none;
  break-inside: avoid; font-size: 14px; }
.nav-drop a:hover { background: #f1f5ff; color: var(--accent); }
.nav-drop a.active { color: var(--accent); font-weight: 600; background: #eef2ff; }
@media (min-width: 701px) and (max-width: 900px) {
  .menu { flex-wrap: nowrap; overflow-x: auto; }
  .nav-drop.cols-2, .nav-drop.cols-3 { width: auto; column-count: 1; }
  .nav-section { position: static; }
  .nav-drop, .nav-drop.right { left: 8px; right: 8px; }
  .user-name small, .brand-text { display: none; }
}

/* Пульт */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
  color: var(--text); text-decoration: none; }
a.tile:hover { border-color: var(--accent); }
.tile-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.tile-title { font-weight: 600; }
.tile-big { font-size: 24px; font-weight: 600; white-space: nowrap; }
.tile-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 2px 0; }
.tile-row span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile.soon { opacity: .55; border-style: dashed; }
.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini th { font-weight: 400; font-size: 11px; text-align: left; }
.mini td, .mini th { padding: 3px 4px; vertical-align: top; }
.mini tr + tr td { border-top: 1px solid var(--border); }

/* --- Задачи: счётчик и лампочка в шапке (5.1) --- */
.task-badge { display: inline-flex; align-items: center; gap: .35em; padding: .2em .6em; border-radius: 1em;
  text-decoration: none; color: inherit; border: 1px solid rgba(127,127,127,.35); margin-right: .8em; white-space: nowrap; }
.task-badge .lamp-dot { width: .7em; height: .7em; border-radius: 50%; background: #9aa0a6; }
.task-badge.lamp { border-color: #d93025; color: #d93025; }
.task-badge.lamp .lamp-dot { background: #d93025; box-shadow: 0 0 6px #d93025; animation: lamp-blink 1s steps(2, start) infinite; }
@keyframes lamp-blink { to { visibility: hidden; } }
/* новая задача — зелёная мигающая (Булат 23.10.2026); просрочка/срочная — красная (выше) */
.task-badge.lamp-new { border-color: #16a34a; color: #15803d; background: rgba(22,163,74,.08); }
.task-badge.lamp-new .lamp-dot { background: #16a34a; box-shadow: 0 0 6px #16a34a; animation: lamp-blink 1s steps(2, start) infinite; }
@media (prefers-reduced-motion: reduce) { .task-badge.lamp .lamp-dot, .task-badge.lamp-new .lamp-dot { animation: none; } }
tr.row-overdue td { background: rgba(217,48,37,.07); }

.tile-wide { grid-column: 1 / -1; }
.tile-wide .table { margin: 8px 0; }

/* CRM: канбан обращений */
/* все этапы в ширину экрана; колонка прокручивается сама — горизонтальная полоса всегда у низа экрана (Булат 23.10.2026) */
.kanban { display: flex; gap: 8px; overflow-x: auto; align-items: flex-start; padding-bottom: 8px; }
.kanban-col { flex: 1 1 0; min-width: 175px; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; max-height: calc(100vh - 230px); overflow-y: auto; }
.kanban-col h3 { position: sticky; top: -8px; background: var(--surface, #fff); padding-top: 4px; z-index: 1; }
.kanban-col h3 { font-size: 14px; margin: 0 0 6px; display: flex; justify-content: space-between; gap: 6px; }
.kanban-card { display: block; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px;
  background: var(--bg); color: inherit; text-decoration: none; font-size: 13px; }
.kanban-card:hover { border-color: var(--muted); }
.kanban-card .t { font-weight: 600; }
.kanban-col.won h3 { color: var(--ok); }
.kanban-col.lost h3 { color: #b91c1c; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }

/* Почта: адресная книга под полем «Кому» */
.addr-wrap { position: relative; display: block; }
.addr-list { position: absolute; z-index: 20; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.12); max-height: 260px; overflow-y: auto; }
.addr-item { padding: 6px 10px; cursor: pointer; font-size: 13px; }
.addr-item:hover { background: var(--bg); }

/* CRM: обращения без КП клиенту */
.kanban-card.kp-late, tr.kp-late td { background: rgba(220, 38, 38, .10); }
.kanban-card.kp-late { border-left: 4px solid #dc2626; }
.kanban-card.kp-wait, tr.kp-wait td { background: rgba(217, 119, 6, .08); }
.kanban-card.kp-wait { border-left: 4px solid #d97706; }
.kp-note { color: #dc2626; font-weight: 600; }
.kp-legend { padding: 0 4px; border-radius: 3px; }
.kp-legend.kp-late { background: rgba(220, 38, 38, .15); }
.kp-legend.kp-wait { background: rgba(217, 119, 6, .15); }
.kanban-card.kp-ok, tr.kp-ok td { background: rgba(22, 163, 74, .08); }
.kanban-card.kp-ok { border-left: 4px solid #16a34a; }
.kp-legend.kp-ok { background: rgba(22, 163, 74, .15); }

/* CRM: переписка по обращению лентой */
.mail-item { border-left: 3px solid var(--border, #ddd); padding: 4px 8px; margin: 6px 0; }
.mail-item.mail-in { border-left-color: #2563eb; }
.mail-item.mail-out { border-left-color: #16a34a; margin-left: 24px; }

/* кабинет: заявка с оформлением */
.editor-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 8px 0 0; }
.editor-bar button, .editor-bar select { padding: 2px 8px; }
.editor { min-height: 180px; border: 1px solid var(--border, #ccc); border-radius: 6px; padding: 8px; background: #fff;
          overflow-x: auto; }
.editor table, .request-html table { border-collapse: collapse; }
.editor td, .editor th, .request-html td, .request-html th { border: 1px solid #ccc; padding: 2px 6px; }

/* ДЗ: запись после звонка в списке должников */
.note-pop { display: inline-block; vertical-align: top; }
.note-pop[open] form { position: absolute; z-index: 5; background: var(--card, #fff); border: 1px solid var(--border, #ccc);
                       border-radius: 6px; padding: 8px; width: 320px; right: 16px; box-shadow: 0 4px 16px rgba(0,0,0,.15); }

/* перетаскивание файла (static/js/dropfile.js) */
[data-drop] .drop-hint { border: 2px dashed var(--border, #cbd5e1); border-radius: 8px; padding: 10px; text-align: center;
  color: var(--muted, #6b7280); margin: 6px 0; font-size: 13px; }
[data-drop].drop-over { outline: 3px dashed #2563eb; outline-offset: 2px; }
[data-drop].drop-over .drop-hint { background: color-mix(in srgb, #2563eb 10%, transparent); color: #1d4ed8; }
[data-drop] .drop-hint.drop-ok { border-color: #16a34a; color: #15803d; }

/* Полоски целей на пульте: неделя и месяц (v0.145) */
.goals { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin: 0 0 16px; }
.goal-col { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.goal-title { font-weight: 600; margin-bottom: 8px; }
.goal { margin: 10px 0; }
.goal-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.goal-track { position: relative; height: 12px; background: #eef2f7; border-radius: 999px; margin-top: 6px; overflow: visible; }
.goal-fill { position: absolute; left: 0; top: 0; height: 100%; border-radius: 999px; background: #2563eb; transition: width .4s; }
.goal-fill.ahead { background: #16a34a; }
.goal-lag { position: absolute; top: 0; height: 100%; background: repeating-linear-gradient(45deg, #fecaca, #fecaca 4px, #fee2e2 4px, #fee2e2 8px); border-radius: 0 999px 999px 0; }
.goal-mark { position: absolute; top: -3px; width: 2px; height: 18px; background: #0f2742; border-radius: 1px; }
.goal-pct.ok { color: #15803d; } .goal-pct.warn { color: #b45309; } .goal-pct.bad { color: #b91c1c; }
.goal-note { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* сворачиваемые блоки (details.fold): заголовок — кнопка, ▸ / ▾ */
details.fold > summary { list-style: none; cursor: pointer; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { display: inline-block; margin: 0 0 8px; }
details.fold > summary h2::before { content: "▸ "; color: var(--muted); }
details.fold[open] > summary h2::before { content: "▾ "; }
details.fold { margin-bottom: 16px; }

/* Kaspi: выбор товаров — дерево групп 1С слева */
.kaspi-pick { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.group-tree { padding: 12px; max-height: calc(100vh - 220px); overflow-y: auto; position: sticky; top: 120px; }
.tree { list-style: none; margin: 0; padding-left: 14px; font-size: 14px; }
.group-tree > .tree { padding-left: 0; }
.tree li { margin: 2px 0; }
.tree summary { cursor: pointer; }
.tree a { color: var(--text); text-decoration: none; }
.tree a:hover { color: var(--accent); }
.tree a.active { color: var(--accent); font-weight: 600; }
.tree a.leaf { padding-left: 14px; display: inline-block; }
@media (max-width: 900px) { .kaspi-pick { grid-template-columns: 1fr; } .group-tree { position: static; max-height: 300px; } }

/* быстрый поиск обращения в шапке (v0.154) */
.lead-search { position: relative; margin: 0; }
.lead-search input[type=search] { width: 240px; padding: 5px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12); color: #fff; font-size: 13px; }
.lead-search input[type=search]::placeholder { color: rgba(255,255,255,.7); }
.lead-search input[type=search]:focus { outline: none; background: #fff; color: #111; width: 320px; }
.lead-search-list { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; width: 460px; max-width: 92vw;
  background: var(--surface, #fff); border: 1px solid var(--border, #ddd); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  max-height: 70vh; overflow-y: auto; }
.ls-item { display: block; padding: 7px 12px; color: var(--text, #111); text-decoration: none; font-size: 13px; border-bottom: 1px solid var(--border, #eee); }
.ls-item:hover { background: var(--bg, #f5f5f5); }
.ls-meta { display: block; color: var(--muted, #666); font-size: 12px; }
.ls-empty { color: var(--muted, #666); }
@media (max-width: 700px) { .lead-search input[type=search], .lead-search input[type=search]:focus { width: 100%; } }

/* гибкий поиск: подсказки-фасеты (v0.176) */
.facets { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 12px; }
.facets .chip { display: inline-block; padding: 2px 9px; margin: 2px 3px 2px 0; border: 1px solid var(--border, #d1d5db);
  border-radius: 12px; text-decoration: none; color: inherit; background: var(--card, #fff); white-space: nowrap; }
.facets .chip:hover { border-color: #2563eb; }
.facets .chip.on { background: #dbeafe; border-color: #2563eb; font-weight: 600; }
.facets .chip.off { background: #fee2e2; border-color: #dc2626; }
.facets .chip-x { margin: 0 6px 0 -2px; text-decoration: none; color: #dc2626; font-size: 12px; }

/* Полоса маршрута документа — templates/core/_route.html, core/route.py (Булат 31.10.2026) */
.route{display:flex;gap:0;flex-wrap:wrap;margin:6px 0 12px;background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:12px 8px}
.r-step{flex:1;min-width:120px;text-align:center;position:relative;padding:0 6px;color:#94a3b8}
.r-step:not(:last-child)::after{content:"";position:absolute;top:15px;left:calc(50% + 20px);right:calc(-50% + 20px);height:2px;background:#e2e8f0}
.r-step.done:not(:last-child)::after{background:#22c55e}
.r-dot{display:inline-flex;width:30px;height:30px;border-radius:50%;align-items:center;justify-content:center;background:#e2e8f0;color:#64748b;font-weight:700;font-size:14px}
.r-step b{display:block;margin-top:4px;color:#334155;font-size:13px}.r-step small{display:block;font-size:11px;line-height:1.3}
.r-step.done .r-dot{background:#22c55e;color:#fff}.r-step.now .r-dot{background:#f59e0b;color:#fff;box-shadow:0 0 0 4px #fde68a;animation:rpulse 1.6s infinite}
.r-step.now b{color:#b45309}.r-step.bad .r-dot{background:#ef4444;color:#fff}
@keyframes rpulse{50%{box-shadow:0 0 0 7px #fef3c7}}

/* ===== Кабинет клиента на телефоне (v0.277, Булат 10.11.2026: «мобильная версия кабинета клиента») =====
   Сверху — логотип, «Кабинет клиента» и «?»; разделы — нижней панелью под большим пальцем; остальное — «Ещё». */
.cab-title, .cab-tabs { display: none; }
.cab-dot { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #16a34a; color: #fff;
  font-size: 11px; line-height: 18px; text-align: center; }
.cab-sheet[hidden], .cab-dot[hidden] { display: none !important; }
/* порог телефона кабинета — 767px, как в cabinet.css (раньше 700: на 701–767 px был пустой отступ без нижней панели) */
@media (max-width: 767px) {
  body.cab-in { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.cab .cab-title { display: block; flex: 1; color: #fff; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; }
  body.cab .topbar-main .user { display: flex; flex-wrap: nowrap; }
  body.cab .topbar-main .user > :not(.page-help-btn):not(dialog) { display: none; }
  body.cab .page-help-btn { width: 34px; height: 34px; margin: 0; }
  body.cab .footer { padding-bottom: 16px; }
  .cab-tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; background: var(--surface);
    border-top: 1px solid var(--border); box-shadow: 0 -2px 12px rgba(15,23,42,.08); padding-bottom: env(safe-area-inset-bottom); }
  .cab-tabs a, .cab-tabs button { flex: 1 1 0; position: relative; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 1px; min-height: 58px; padding: 6px 2px; border: 0; background: none; color: #475569;
    font: inherit; font-size: 11px; text-decoration: none; cursor: pointer; }
  .cab-tabs i { font-style: normal; font-size: 21px; line-height: 1.1; }
  .cab-tabs .on { color: var(--accent); font-weight: 600; }
  .cab-tabs .on::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px;
    background: var(--accent); }
  .cab-badge { position: absolute; top: 4px; left: 54%; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #dc2626;
    color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; text-align: center; }
  .cab-badge[hidden] { display: none; }
  .cab-sheet { position: fixed; inset: 0; z-index: 95; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; }
  .cab-sheet-box { width: 100%; max-height: 85vh; overflow-y: auto; background: var(--surface); border-radius: 16px 16px 0 0;
    padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
  .cab-sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .cab-sheet-x { border: 0; background: none; font-size: 22px; width: 44px; height: 44px; cursor: pointer; }
  .cab-sheet-box > a { position: relative; display: block; padding: 13px 4px; font-size: 16px; color: var(--text); text-decoration: none;
    border-bottom: 1px solid #eef2f7; }
  .cab-sheet-box > a .cab-badge { position: static; margin-left: 6px; }
  .cab-sheet-user { display: flex; align-items: center; gap: 8px; padding: 10px 0 4px; color: var(--muted); }
  /* плавающие кнопки каталога и всплывающие сообщения — над нижней панелью */
  body.cab-in .float-nav { bottom: calc(70px + env(safe-area-inset-bottom)) !important; }
  body.cab-in .float-nav a[href$="/cart/"] { display: none; }
  body.cab-in .cart-toast, body.cab-in .cart-note { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
  body.cab .tiles { grid-template-columns: 1fr; gap: 10px; }
  body.cab .tile { padding: 14px; }
  body.cab .cols { grid-template-columns: 1fr; }
}

/* Таблица карточками на телефоне: <table class="table stack">, у ячеек data-label — подпись слева, значение справа.
   Ячейка .st-main — заголовок карточки на всю ширину. */
@media (max-width: 700px) {
  table.stack, table.stack tbody, table.stack tfoot { display: block; width: 100%; }
  table.stack { border: 0; background: none; }
  table.stack thead { display: none; }
  table.stack tbody tr { display: block; margin: 0 0 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; }
  table.stack tbody td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right !important;
    white-space: normal; }
  table.stack tbody td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left;
    flex: 0 0 auto; }
  table.stack tbody td.st-main { display: block; text-align: left !important; font-weight: 600; font-size: 15px; padding-bottom: 6px; }
  table.stack tbody td:empty { display: none; }
  table.stack tbody td[colspan] { display: block; text-align: left !important; }
  table.stack tfoot tr { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; }
  table.stack tfoot td { border: 0; padding: 0; }
  table.stack tfoot td:empty { display: none; }
  .table-wrap:has(> table.stack) { overflow: visible; }
}

/* ===== Телефон: ничего не шире экрана (v0.277, проверка 915 страниц сотрудников при ширине 390 px) =====
   длинные списки (поставщики, клиенты) раздували фильтры; таблицы без обёртки; полоса маршрута; длинные слова и коды */
@media (max-width: 700px) {
  .content { overflow-wrap: anywhere; }
  .content select, .content input, .content textarea { max-width: 100%; min-width: 0; }
  .content input[size] { width: auto; }
  .content label, .filters label, .form label { min-width: 0; max-width: 100%; }
  .content fieldset { min-width: 0; max-width: 100%; }
  .content table.table:not(.stack), .content table.mini, .content table:not([class]) { display: block; max-width: 100%; overflow-x: auto;
    -webkit-overflow-scrolling: touch; }
  .content .table-wrap { max-width: 100%; }
  .content pre, .content code { white-space: pre-wrap; word-break: break-all; }
  .content img, .content video, .content iframe { max-width: 100%; }
  .route { overflow: hidden; }
  .r-step { min-width: 90px; }
  .cols, .grid-2, .goals, .kpis { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; }
  .kaspi-pick { grid-template-columns: 1fr; }
  .note-pop[open] form { width: auto; left: 8px; right: 8px; }
  .letter { max-width: 100%; }
}
/* длинный текст в правой части строки плитки (список «нет прайса» на пульте раздувал страницу до 5 000 px) */
.tile-row span.small:last-child, .tile-row span.muted:last-child { white-space: normal; text-align: right; }

/* Телефон — дочистка после повторной проверки 11.11.2026 (пульт, карточка поставщика, расчётный лист, формы) */
@media (max-width: 700px) {
  .tiles > *, .grid > *, .cols > *, section.card, .card { min-width: 0; max-width: 100%; }
  .tile, .tile-wide { overflow-x: auto; }
  section.card { overflow-x: auto; }
  form.inline, .filters { flex-wrap: wrap; max-width: 100%; }
  input[size], input[type="text"], input[type="date"], textarea { max-width: 100%; }
  span.muted, span.small, .muted.small { white-space: normal; overflow-wrap: anywhere; }
}

/* Закреплённая шапка таблицы и сортировка (Булат 12.11.2026, «Товары Kaspi»): обёртка .sticky-head прокручивается сама,
   строка заголовков остаётся видна; th.sort-th — щелчок сортирует (static/js/tablesort.js). */
.table-wrap.sticky-head { max-height: calc(100vh - 150px); overflow: auto; }
.sticky-head thead th { position: sticky; top: 0; z-index: 3; background: var(--surface, #fff); box-shadow: 0 1px 0 var(--border); }
/* Шапка таблицы «упирается» в верхнее меню при прокрутке СТРАНИЦЫ — без своей прокрутки, видно максимум строк
   (Булат 12.11.2026, пополнение зала). Высота меню — --topbar-h (ставит base.html). */
.table-wrap.page-head-sticky { overflow: visible; }
.page-head-sticky thead th { position: sticky; top: var(--topbar-h, 0px); z-index: 5; background: var(--surface, #fff);
  box-shadow: 0 1px 0 var(--border), 0 2px 4px rgba(15,23,42,.06); }
.qty-zero { color: #fff; background: #dc2626; border-radius: 6px; padding: 1px 8px; font-weight: 700; }
.qty-low { color: #b45309; font-weight: 700; }
.qty-stock { color: #15803d; font-weight: 700; }
th.sort-th { cursor: pointer; user-select: none; white-space: nowrap; }
th.sort-th:hover { color: var(--text, #0f172a); }
th.sort-th::after { content: " ↕"; opacity: .35; font-size: 11px; }
th.sort-th[data-dir="asc"]::after { content: " ▲"; opacity: .9; }
th.sort-th[data-dir="desc"]::after { content: " ▼"; opacity: .9; }
/* все таблицы (29.11.2026): стрелка у «автоматических» колонок — только при наведении, чтобы не шуметь */
th.sort-th.sort-auto::after { opacity: 0; }
th.sort-th.sort-auto:hover::after { opacity: .45; }
th.sort-th.sort-auto[data-dir]::after { opacity: .9; }
.tf-box { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.tf-input { width: 16em; max-width: 100%; padding: 4px 8px; font-size: 13px; border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px; background: var(--card, #fff); color: inherit; }
.tf-count { font-size: 12px; color: var(--muted, #64748b); }
@media print { .tf-box { display: none !important; } th.sort-th::after { content: none !important; } }

/* Закреплённые шапки во всех таблицах (static/js/stickyhead.js, Булат 13.11.2026): сдвинутая шапка — непрозрачная,
   поверх строк, с тенью снизу. */
table.th-float thead th, table.th-float thead td { position: relative; z-index: 6; background: var(--surface, #fff);
  box-shadow: 0 1px 0 var(--border), 0 3px 6px rgba(15,23,42,.08); }
table.th-float tr:first-child > th { position: relative; z-index: 6; background: var(--surface, #fff);
  box-shadow: 0 1px 0 var(--border), 0 3px 6px rgba(15,23,42,.08); }

/* Общие детали нового дизайна экранов (Булат 16.11.2026, образец «Снабжение / Закупки») — работают и в прежнем виде:
   вкладки со счётчиками (.tabs-bar), карточки сумм (.sum-cards), плашки статусов (.pill), строка поиска (.find-bar) */
.tabs-bar { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 16px; }
.tabs-bar a { padding: 9px 14px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent;
  margin-bottom: -1px; font-weight: 500; white-space: nowrap; }
.tabs-bar a:hover { color: var(--text); }
.tabs-bar a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs-bar .n { display: inline-block; min-width: 22px; padding: 0 7px; margin-left: 6px; border-radius: 999px;
  background: #eef2f7; color: var(--muted); font-size: 12px; text-align: center; }
.tabs-bar a.on .n { background: #dbeafe; color: var(--accent); }
.sum-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 0 0 16px; }
.sum-card { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; text-decoration: none; color: var(--text); }
.sum-card .ic { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; flex: none;
  background: #dbeafe; }
.sum-card .lbl { color: var(--muted); font-size: 13px; }
.sum-card .val { font-size: 20px; font-weight: 700; white-space: nowrap; }
.sum-card .sub { font-size: 12px; color: var(--muted); }
.sum-card.bad { background: #fff5f5; border-color: #fecaca; }
.sum-card.bad .sub { color: var(--error); }
.sum-card .ic.green { background: #dcfce7; } .sum-card .ic.violet { background: #ede9fe; } .sum-card .ic.red { background: #fee2e2; }
.sum-card .ic.orange { background: #ffedd5; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px; border-radius: 999px; font-size: 12.5px;
  font-weight: 600; white-space: nowrap; background: #f1f5f9; color: #475569; }
.pill.green { background: #dcfce7; color: #15803d; } .pill.blue { background: #dbeafe; color: #1d4ed8; }
.pill.orange { background: #ffedd5; color: #c2410c; } .pill.red { background: #fee2e2; color: #b91c1c; }
.pill.violet { background: #ede9fe; color: #6d28d9; } .pill.teal { background: #ccfbf1; color: #0f766e; }
.find-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 14px; }
.find-bar input[type=search] { flex: 1; min-width: 220px; max-width: 420px; }
.find-bar .reset { margin-left: 4px; }
.late { color: var(--error); font-weight: 600; }
.warn-txt { color: #b45309; font-weight: 600; }
/* строка, требующая внимания (нет цены и т. п.) — заказ на пополнение, 16.11.2026 */
.table tr.row-warn td { background: #fffbeb; }
/* подзаголовки групп в выпадающем меню раздела (Булат 16.11.2026: «меню подсобрать») */
.nav-drop .nav-grp { break-after: avoid; break-inside: avoid; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: 10px 10px 3px; }
.nav-drop .nav-grp:first-child { padding-top: 2px; }
/* короткая подпись значков шапки (✅ 26 · ⚠6) — показывается только в новом виде на узком экране (ui-new.css) */
.task-badge .bi { display: none; }
/* Звонок WhatsApp в ERP (Булат 17.11.2026) — окно входящего звонка поверх страницы */
.wav-box { position: fixed; right: 18px; bottom: 18px; z-index: 9999; width: 340px; max-width: calc(100vw - 32px);
  background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(15,23,42,.28); border: 2px solid #22c55e;
  padding: 14px 16px; font-size: 14px; animation: wavpulse 1.4s ease-in-out infinite; }
.wav-box.talk { animation: none; border-color: #2563eb; }
.wav-box .wav-h b { font-size: 16px; }
.wav-box .wav-sub { color: #64748b; font-size: 12.5px; margin-top: 2px; }
.wav-box .wav-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.wav-box .wav-ok { background: #16a34a; color: #fff; border-color: #16a34a; }
.wav-box .wav-no, .wav-box .wav-end { background: #dc2626; color: #fff; border-color: #dc2626; }
.wav-box .wav-err { color: #b91c1c; font-size: 12.5px; margin-top: 6px; }
@keyframes wavpulse { 0%, 100% { box-shadow: 0 12px 40px rgba(22,163,74,.25); } 50% { box-shadow: 0 12px 48px rgba(22,163,74,.6); } }

/* Печать любой страницы ERP (static/js/report-print.js, Булат 30.11.2026): лист А4 (книжный / альбомный ставит скрипт),
   без меню, верхней строки, кнопок и фильтров; шапка таблицы повторяется на каждом листе; строки не рвутся.
   Выбор строк в отчётах (table[data-select]): колонка галочек, панель «Выбрано N». */
.print-only { display: none; }
.sel-col, table th.sel-col, table td.sel-col { width: 34px !important; min-width: 34px !important; max-width: 34px !important; padding-left: 4px !important; padding-right: 4px !important; text-align: center; }
.sel-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; padding: 8px 12px;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; }
tr.sel-on > td { background: #eff6ff !important; }
@media print {
  .nside, .topbar, .crumb, .noprint, .sel-col, .sel-bar, .find-bar, .tabs-bar form, .pwa-install,
  #restart-banner, .page-help, .rpt-actions, .rpt-filters { display: none !important; }
  .print-only { display: block !important; font-size: 9pt; color: #444; margin: 0 0 6px; }
  html, body, .content, main { background: #fff !important; color: #000 !important; margin: 0 !important;
    padding: 0 !important; max-width: none !important; width: auto !important; }
  body { font-size: 9pt; }
  table { width: 100% !important; border-collapse: collapse; font-size: 8.5pt; }
  th, td { padding: 3px 5px !important; }
  thead { display: table-header-group; }
  tr, img { break-inside: avoid; page-break-inside: avoid; }
  .rpt-sticky-wrap, .table-wrap, [style*="overflow"] { overflow: visible !important; max-height: none !important; }
  table.th-float thead th { position: static !important; box-shadow: none !important; }
  a { color: #000 !important; text-decoration: none !important; }
  /* «Печать выбранного» — только отмеченные строки этой таблицы */
  body.print-selected table.print-sel-table tbody tr:not(.sel-on) { display: none !important; }
}
