/* CRM — оформление в стиле «Диспетчер проектов · Finder Edition v0.6.1»:
   дерево слева (как Total Commander), рабочая зона справа (как Finder), изумрудный акцент. */

:root {
  --bg: #f4f5f2;          /* рабочая зона */
  --side: #e9eee9;        /* боковая панель */
  --side-line: #d6ded5;
  --card: #ffffff;
  --bar: #fcfcfa;         /* toolbar */
  --text: #26332f;
  --text-2: #596c60;
  --text-3: #809086;
  --accent: #277557;
  --accent-dark: #1e6047;
  --accent-tab: #216b4a;
  --active: #d6e1d8;
  --hover: #dde8df;
  --line: #e0e7df;
  --line-2: #edf1ed;
  --btn-line: #d2ddd3;
  --input-line: #dce5dc;
  --input-bg: #fbfcfb;
  --warn-bg: #fff6ec; --warn-line: #f3dcb8; --warn-text: #835f34;
  --ok-bg: #eaf6ef; --ok-line: #c5e5d2; --ok-text: #26744f;
  --err-bg: #fdf0ee; --err-line: #efc4bd; --err-text: #9b3328;
  --danger: #b4432f;
  --radius: 13px; --radius-sm: 9px;
  --sidebar-width: 270px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-tab); }
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 27px; font-weight: 780; letter-spacing: -.8px; margin: 2px 0 6px; line-height: 1.2; }
h2 { font-size: 15px; font-weight: 700; letter-spacing: -.2px; margin: 0 0 13px; }
h3 { font-size: 13px; margin: 12px 0 4px; }

/* ── Каркас ─────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.side {
  background: var(--side); border-right: 1px solid var(--side-line); padding: 19px 10px 12px;
  overflow: auto; display: flex; flex-direction: column;
}
.logo { font-size: 19px; font-weight: 760; letter-spacing: -.5px; margin: 0 10px; }
.tiny { font-size: 11px; color: #526558; margin: 5px 10px 8px; }
.side-label { font-size: 10px; color: #53665a; font-weight: 750; letter-spacing: 1px; margin: 16px 10px 6px; text-transform: uppercase; }
.side-foot { margin-top: auto; padding: 14px 8px 4px; border-top: 1px solid var(--side-line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-user { font-size: 12px; font-weight: 650; line-height: 1.3; }
.side-user span { font-weight: 400; color: var(--text-2); font-size: 11px; }
.side-foot form { margin: 0; }
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.content { padding: 24px 29px 40px; overflow: auto; flex: 1; }
.page { max-width: none; }

/* ── Дерево (Total Commander) ───────────────────────────── */
.tree, .tree-nested { list-style: none; margin: 0; padding: 0; }
.tree-nested { display: none; padding-left: 12px; margin-left: 13px; border-left: 1px solid #d4ded5; }
.node.open > .tree-nested { display: block; }
.tree-row { display: flex; align-items: center; min-height: 30px; border-radius: 8px; gap: 2px; }
.tree-row:hover { background: var(--hover); }
.tree-row.active { background: var(--active); }
.tree-row.active .tree-link { font-weight: 740; }
.tree-row.in-section .tree-link { font-weight: 650; }
.tree-toggle {
  flex: 0 0 20px; height: 26px; border: 0; background: transparent; color: #526458; font-size: 10px;
  cursor: pointer; padding: 0; transition: transform .12s; border-radius: 6px;
}
.node.open > .tree-row > .tree-toggle { transform: rotate(90deg); }
.tree-spacer { flex: 0 0 20px; }
.tree-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; padding: 5px 6px 5px 2px;
  color: #34453b; text-decoration: none; font-size: 12.5px; border-radius: 6px; cursor: pointer;
}
.tree-link:hover { color: #1f2d27; }
.tree-ico { flex: none; width: 18px; text-align: center; font-size: 13px; }
.tree-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tree-count {
  flex: none; font-size: 10.5px; color: #4f6357; background: #dfe8e1; border-radius: 10px; padding: 0 7px; line-height: 17px;
}
.tree-row.active .tree-count { background: #c3d6c8; }
.tree-nested .tree-link { font-size: 12px; }

/* ── Панель инструментов ────────────────────────────────── */
.toolbar {
  background: var(--bar); border-bottom: 1px solid #dfe5df; display: flex; align-items: center; gap: 8px;
  padding: 11px 22px; flex-wrap: wrap;
}
.traffic { display: flex; gap: 7px; margin-right: 6px; }
.traffic i { height: 11px; width: 11px; border-radius: 50%; background: #ff6159; }
.traffic i:nth-child(2) { background: #febc2e; }
.traffic i:nth-child(3) { background: #29c840; }
.crumb { font-size: 13px; color: #63766b; display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; min-width: 0; overflow: hidden; white-space: nowrap; }
.crumb a { color: #63766b; text-decoration: none; }
.crumb a:hover { text-decoration: underline; color: var(--text); }
.crumb .sep { color: #a3b0a7; }
.crumb-current { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.crumb-current:not(:empty)::before { content: "›"; color: #a3b0a7; font-weight: 400; margin-right: 6px; }
.grow { flex: 1; }
.find-form { margin: 0; }
.find { border: 1px solid #d4dfd5; border-radius: 8px; padding: 8px 10px; background: #f6f8f5; width: 220px; font-size: 13px; }
.find:focus { background: #fff; border-color: #a6c5b3; outline: none; box-shadow: 0 0 0 3px #27755722; }
.btn.menu-btn { display: none; }

/* ── Кнопки ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--btn-line); background: #fff; color: #34483d;
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 620; line-height: 1.25;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #edf4ed; color: #26382d; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.icon { padding: 7px 10px; min-width: 34px; justify-content: center; }
.btn.small { padding: 5px 9px; font-size: 11.5px; }
.btn.big { padding: 11px 18px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: var(--err-line); margin-top: 12px; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-link { border-color: transparent; color: var(--danger); background: none; }
.help-mode-btn b { font-weight: 700; }
body.help-mode #help-toggle { background: var(--accent); border-color: var(--accent); color: #fff; }
.link-btn { background: none; border: 0; color: #9aa79f; cursor: pointer; font-size: 15px; }
.link-btn:hover { color: var(--danger); }
.actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ── Карточки, сообщения, строка состояния ─────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 15px; }
.card h2:first-child, .card > .head-row:first-child h2 { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 15px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.pre { white-space: pre-wrap; }
.error { color: var(--err-text); }
.nowrap { white-space: nowrap; }
.msg { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok-text); padding: 11px 13px; border-radius: 10px; margin-bottom: 14px; font-size: 12.5px; }
.msg.warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.msg.error { background: var(--err-bg); border-color: var(--err-line); color: var(--err-text); }
.footer {
  padding: 9px 26px; border-top: 1px solid var(--input-line); background: #fafbfa; color: #87958a; font-size: 11px;
  display: flex; justify-content: space-between; gap: 10px;
}
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-row h1, .head-row h2 { margin: 0; }
.content > p:first-child > a:only-child, .content > .msg + p > a:only-child { font-size: 12px; color: var(--text-3); text-decoration: none; }
.content > p:first-child > a:only-child:hover { color: var(--accent); }
.empty { border: 1px dashed #cad8ce; border-radius: 12px; padding: 30px; text-align: center; color: #7d8d81; }

/* ── Фильтры и списки (Finder) ──────────────────────────── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; align-items: center; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.filters input, .filters select {
  padding: 8px 10px; font-size: 13px; border: 1px solid var(--input-line); border-radius: 8px; background: var(--input-bg);
}
.filters .check { display: flex; align-items: center; gap: 5px; }
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; padding: 8px 14px; font-size: 11px; color: var(--text-3); font-weight: 650;
  background: #f7f9f6; border-bottom: 1px solid var(--line); position: sticky; top: 0;
}
.table td { padding: 9px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tbody tr:hover td { background: #f1f6f2; }
.table tr:last-child td { border-bottom: 0; }
.table td a { text-decoration: none; font-weight: 600; }
.table td a:hover { text-decoration: underline; }
.table-wrap h2.pad { padding: 16px 16px 4px; }
.pager { display: flex; gap: 16px; justify-content: center; margin: 16px 0; font-size: 12.5px; }
.view-switch { display: inline-flex; border: 1px solid var(--btn-line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.view-switch button { border: 0; background: none; padding: 7px 11px; font-size: 12px; cursor: pointer; color: #4c5e53; }
.view-switch button.active { background: var(--active); font-weight: 700; color: var(--text); }
[data-views] .tiles { display: none; }
[data-views][data-view="icons"] .tiles { display: grid; }
[data-views][data-view="icons"] .table-wrap { display: none; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 15px; margin-top: 4px; }
.tile {
  display: block; background: #fff; border: 1px solid #e1e7e1; border-radius: var(--radius); padding: 18px 12px 14px;
  min-height: 128px; text-align: center; text-decoration: none; color: inherit; box-shadow: 0 3px 10px #263d2c06;
}
.tile:hover { border-color: #a6c5b3; box-shadow: 0 7px 20px #263d2c0b; color: inherit; }
.tile .em { font-size: 34px; display: block; margin-bottom: 10px; line-height: 1; }
.tile b { display: block; font-size: 12.5px; overflow-wrap: anywhere; line-height: 1.35; }
.tile small { display: block; color: #8b9990; font-size: 11px; margin-top: 6px; line-height: 1.4; }

/* ── Свойства, комментарии, формы ──────────────────────── */
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, .85fr); gap: 17px; align-items: start; margin: 12px 0; }
.cols > .card, .cols > div > .card:first-child { margin-top: 0; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 12.5px; }
.props dt { color: var(--text-3); }
.props dd { margin: 0; }
.contact, .comment { padding: 10px 0; border-top: 1px solid var(--line-2); font-size: 12.5px; }
.contact a { text-decoration: none; }
.comment.system { color: var(--text-2); font-size: 12px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
.form { max-width: 680px; }
.field { margin: 0 0 14px; }
.field label { display: block; font-size: 12px; font-weight: 680; color: #516156; margin-bottom: 6px; }
.field input, .field select, .field textarea, .comment-form textarea,
.item-row input, .item-row textarea, .stage-row input, .stage-row select, .sketch-fields input, .sketch-fields textarea {
  width: 100%; padding: 9px 10px; font-size: 13px; border: 1px solid var(--input-line); border-radius: 8px;
  background: var(--input-bg); color: #283c30;
}
.field input:focus, .field select:focus, .field textarea:focus, .comment-form textarea:focus, .filters input:focus, .filters select:focus {
  background: #fff; border-color: #a6c5b3; outline: none; box-shadow: 0 0 0 3px #27755722;
}
.field textarea { line-height: 1.45; resize: vertical; }
.field.has-error input, .field.has-error select { border-color: #e3a296; }
.check-field label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); font-weight: 500; }
.check-field input, .checks input { width: auto; accent-color: #317b5b; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks .check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 30px; background: #e9f2ea; color: #47715d; font-size: 11px; margin-top: 3px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
details summary { cursor: pointer; color: var(--text-2); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #c4533f; color: #fff; font-size: 10.5px; line-height: 17px; text-align: center; font-style: normal; margin-left: 6px; }

/* ── Вкладки, статусы ───────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid #dfe6de; margin: 12px 0 17px; overflow-x: auto; }
.tabs a { padding: 11px 13px; text-decoration: none; color: #77897b; border-bottom: 2px solid transparent; white-space: nowrap; font-size: 12px; font-weight: 650; }
.tabs a.active { color: var(--accent-tab); border-bottom-color: var(--accent-tab); }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11.5px; background: #edf0ec; }
.status-pill.open { background: #e5efe8; color: #2f6b4e; }
.status-pill.review { background: var(--warn-bg); color: var(--warn-text); }
.status-pill.done { background: var(--ok-bg); color: var(--ok-text); }
.status-pill.overdue { background: var(--err-bg); color: var(--err-text); }
.prio { color: #c4533f; font-weight: 800; }

/* ── Главная ────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 15px; margin: 18px 0; }
.stats .card + .card { margin-top: 0; }
.stat { text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s; }
a.stat:hover { border-color: #a6c5b3; box-shadow: 0 7px 20px #263d2c0b; color: inherit; }
.stat-num { font-size: 28px; font-weight: 760; letter-spacing: -.6px; line-height: 1.2; }

/* ── Сделки: доска ──────────────────────────────────────── */
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; -webkit-overflow-scrolling: touch; }
.column { flex: 0 0 240px; background: #eaefea; border-radius: 12px; display: flex; flex-direction: column; max-height: 72vh; border: 1px solid #e0e7df; }
.column header { padding: 10px 12px 8px; border-top: 3px solid var(--accent); border-radius: 12px 12px 0 0; display: flex; flex-direction: column; font-size: 12.5px; }
.column .cards { padding: 0 8px 8px; min-height: 60px; overflow-y: auto; flex: 1; }
.deal-card { display: block; background: #fff; border: 1px solid #e1e7e1; border-radius: 10px; padding: 10px; margin-bottom: 8px; color: inherit; text-decoration: none; cursor: grab; font-size: 12.5px; }
.deal-card:hover { border-color: #a6c5b3; box-shadow: 0 5px 14px #263d2c10; color: inherit; }
.deal-title { font-weight: 650; line-height: 1.3; }
.deal-meta { display: flex; justify-content: space-between; margin-top: 6px; }
.sortable-ghost { opacity: .4; }
.finals { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.final { flex: 1; min-width: 220px; }
.final .cards { border: 2px dashed; border-radius: 12px; padding: 14px; min-height: 66px; display: flex; flex-direction: column; font-size: 12.5px; }
.final.won .cards { border-color: #8cc5a3; background: var(--ok-bg); color: var(--ok-text); }
.final.lost .cards { border-color: #e3a296; background: var(--err-bg); color: var(--err-text); }
.final .cards .deal-card { display: none; }

/* ── Сделки: карточка ───────────────────────────────────── */
.stages { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 16px; }
.stage-step { border: 1px solid var(--btn-line); background: #fff; border-radius: 8px; padding: 6px 10px; font-size: 11.5px; cursor: pointer; color: #4c5e53; }
.stage-step:hover { background: #edf4ed; }
.stage-step.done { background: #e5efe8; border-color: #cfe0d4; }
.stage-step.current { color: #fff; font-weight: 700; }
.stage-step.won:not(.current) { border-color: #8cc5a3; color: var(--ok-text); }
.stage-step.lost:not(.current) { border-color: #e3a296; color: var(--err-text); }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line-2); font-size: 12.5px; }
.file-row a { flex: 1; word-break: break-all; }
.file-row form { margin: 0; }
.upload { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.upload select { padding: 6px; border-radius: 8px; border: 1px solid var(--input-line); }

/* ── Задачи ─────────────────────────────────────────────── */
.task-group h2 { margin-top: 0; }
.task-group.overdue h2 { color: var(--err-text); }
.task-row { display: flex; gap: 12px; align-items: flex-start; padding: 11px 8px; border-top: 1px solid var(--line-2); border-radius: 8px; }
.task-row:first-of-type { border-top: 0; }
.task-row:hover { background: #f1f6f2; }
.task-row form { margin: 0; }
.task-main { flex: 1; min-width: 0; font-size: 13px; line-height: 1.5; }
.task-main > a { color: #26382d; text-decoration: none; font-weight: 600; }
.task-main > a:hover { text-decoration: underline; }
.check-btn {
  width: 26px; height: 26px; border: 1px solid #85a995; border-radius: 50%; background: #fff; color: transparent;
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0; flex: none; display: grid; place-items: center;
}
.check-btn:hover { background: #e5f3e9; color: #326b4c; }
.check-btn.ghost { border-style: dashed; border-color: #c3d1c7; cursor: default; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 16px; }
.task-actions form { margin: 0; }

/* ── Календарь ──────────────────────────────────────────── */
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.cal-title { margin: 0 8px; font-size: 14px; }
.cal-switch { margin-left: auto; display: flex; border: 1px solid var(--btn-line); border-radius: var(--radius-sm); overflow: hidden; }
.cal-switch a { padding: 7px 12px; text-decoration: none; color: #4c5e53; background: #fff; font-size: 12px; }
.cal-switch a.active { background: var(--active); color: var(--text); font-weight: 700; }
.cal.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-day { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 120px; }
.cal-day.today { border: 2px solid var(--accent); background: #f6faf7; }
.cal-day header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 12px; }
.cal-day header a { text-decoration: none; color: inherit; }
.cal-add { width: 22px; height: 22px; border-radius: 50%; background: #e9f2ea; color: var(--accent) !important; text-align: center; line-height: 22px; font-weight: 700; }
.visit { display: block; border-left: 4px solid var(--accent); background: #f7f9f6; border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; text-decoration: none; color: inherit; font-size: 12px; }
.visit:hover { background: #eef5ef; color: inherit; }
.visit.measure { border-left-color: #2a78d6; }
.visit.install { border-left-color: #eb6834; }
.visit.delivery { border-left-color: #1baf7a; }
.visit.meeting { border-left-color: #6250d6; }
.visit.other { border-left-color: #9aa79f; }
.visit.done { opacity: .6; }
.visit-title { font-weight: 650; line-height: 1.25; }

/* ── Отчёты ─────────────────────────────────────────────── */
.viz-root { --series-1: #2f8a66; --track: #e8ede8; --grid: #e0e7df; }
.colchart { display: flex; align-items: flex-end; gap: 2px; height: 220px; padding: 8px 0 0; border-bottom: 1px solid var(--grid); margin-bottom: 8px; }
.col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; position: relative; outline: none; }
.col-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.col-bar { width: 70%; max-width: 36px; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 2px; }
.col:hover .col-bar, .col:focus .col-bar { filter: brightness(1.15); }
.col-label { padding-top: 4px; }
.col-tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #22392d; color: #fff; padding: 6px 10px; border-radius: 9px; font-size: 12px; white-space: nowrap; z-index: 2; pointer-events: none; }
.col:hover .col-tip, .col:focus .col-tip { display: block; }
.col:first-child .col-tip { left: 0; transform: none; }
.col:last-child .col-tip { left: auto; right: 0; transform: none; }
.hbar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; }
.hbar-label { font-size: 12.5px; line-height: 1.25; }
.hbar-track { height: 8px; background: var(--track); border-radius: 0 4px 4px 0; }
.hbar-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-value { font-size: 12.5px; white-space: nowrap; min-width: 70px; text-align: right; }
.inline-bar { display: inline-block; height: 8px; background: var(--series-1); border-radius: 0 4px 4px 0; vertical-align: middle; max-width: 100px; }

/* ── Договоры ───────────────────────────────────────────── */
.contract-form .card { margin-bottom: 15px; }
.contract-form .form { max-width: none; }
.items-head, .item-row { display: grid; grid-template-columns: 1fr 70px 80px 120px 28px; gap: 6px; align-items: start; }
.items-head { margin: 8px 0 4px; }
.item-row { margin-bottom: 6px; }
.totals { font-size: 14px; margin: 12px 0 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stage-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.stage-row label { display: flex; align-items: center; gap: 4px; font-size: 12.5px; }
.stage-row .grow { flex: 1; min-width: 220px; }
input.tiny { width: 70px !important; }
.sketch-edit { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.sketch-edit img { width: 120px; height: 90px; object-fit: contain; background: #f2f5f2; border-radius: 7px; flex: none; }
.sketch-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.danger-text { color: var(--danger); margin-left: 12px; }
.doc-actions { margin: 12px 0 16px; }

/* ── Поиск ──────────────────────────────────────────────── */
.search-group h2 { display: flex; gap: 8px; align-items: center; }
.result { display: flex; gap: 12px; align-items: baseline; padding: 9px 4px; border-top: 1px solid var(--line-2); text-decoration: none; color: inherit; border-radius: 6px; }
.result:hover { background: #f1f6f2; color: inherit; }
.result:first-of-type { border-top: 0; }
.result b { font-weight: 650; }

/* ── Справка ────────────────────────────────────────────── */
.help-tip {
  position: absolute; z-index: 1000; max-width: 320px; background: #22392d; color: #fff; padding: 10px 12px;
  border-radius: 9px; font-size: 12px; line-height: 1.45; box-shadow: 0 10px 25px #10221950;
}
.help-tip b { display: block; margin-bottom: 3px; }
.help-tip a { display: inline-block; margin-top: 6px; color: #9fd8bb; }
body.help-mode [data-help] { outline: 2px dotted var(--accent); outline-offset: 2px; cursor: help !important; }
body.help-mode .main::before {
  content: "Режим справки: нажмите на любой элемент с точечной рамкой. Выключить — «Помощь: вкл.» вверху или Esc.";
  display: block; background: #e9f2ea; color: #2f5d47; text-align: center; padding: 6px; font-size: 12px; border-bottom: 1px solid #cfe0d4;
}
.help-search { width: 100%; padding: 10px 12px; font-size: 13px; border: 1px solid #cbd7cc; border-radius: 9px; margin: 12px 0; background: #fff; }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; font-size: 12.5px; }
.help-item { padding: 12px 0; border-top: 1px solid #e4eae5; font-size: 13px; line-height: 1.6; color: #405449; }
.help-item:first-of-type { border-top: 0; }
.help-target { background: #fef7e8; border-radius: 8px; padding: 12px; }
.help-intro ul { margin: 0; padding-left: 20px; }
.help-btn-sample { display: inline-block; padding: 0 6px; height: 20px; line-height: 18px; text-align: center; border-radius: 6px; border: 1px solid var(--btn-line); background: #fff; font-weight: 700; font-size: 11px; }

/* ── Вход ───────────────────────────────────────────────── */
.no-shell { display: grid; place-items: center; min-height: 100vh; background: var(--side); }
.login-wrap { width: min(380px, 92vw); }
.login { background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 26px; box-shadow: 0 15px 50px #19271e1a; }
.login h1 { font-size: 23px; }
.login label { display: block; margin: 12px 0; font-size: 12px; font-weight: 680; color: #516156; }
.login input { display: block; width: 100%; margin-top: 6px; padding: 11px; font-size: 16px; border: 1px solid var(--input-line); border-radius: 8px; background: var(--input-bg); }
.login button.primary { width: 100%; padding: 12px; font-size: 14px; color: #fff; background: var(--accent); border: 0; border-radius: var(--radius-sm); cursor: pointer; margin-top: 6px; }
.login button.primary:hover { background: var(--accent-dark); }

/* ── Нижняя панель (только телефон) ─────────────────────── */
.tabbar, .side-backdrop { display: none; }

/* ── Средние экраны ─────────────────────────────────────── */
@media (max-width: 1100px) { :root { --sidebar-width: 225px; } .find { width: 170px; } .cols { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .cal.week { grid-template-columns: 1fr; } .cal.week .cal-day:not(.today) .cal-empty { display: none; } .cal-day { min-height: 0; } }

/* ── Телефон: своя компоновка, а не сжатый компьютер ────── */
@media (max-width: 700px) {
  body { font-size: 14px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(84vw, 320px); transform: translateX(-102%);
    transition: transform .2s ease, box-shadow .2s; padding-top: max(19px, env(safe-area-inset-top));
  }
  body.side-open .side { transform: none; box-shadow: 8px 0 30px #10221930; }
  body.side-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: #19271e66; }
  .tree-row { min-height: 40px; }
  .tree-link, .tree-nested .tree-link { font-size: 14.5px; padding: 8px 6px 8px 2px; }
  .tree-toggle { flex-basis: 30px; height: 36px; font-size: 12px; }
  .toolbar { padding: 8px 12px; gap: 6px; padding-top: max(8px, env(safe-area-inset-top)); }
  .traffic, .toolbar .help-mode-btn ~ a.btn.icon, .toolbar > a.btn.icon[aria-label^="Вверх"] { display: none; }
  .btn.menu-btn { display: inline-flex; }
  .crumb { font-size: 12px; flex: 1 1 0; }
  .crumb > a:first-child, .crumb > .sep:first-of-type { display: none; }
  .crumb:has(.crumb-current:not(:empty)) > a, .crumb:has(.crumb-current:not(:empty)) > .sep { display: none; }
  .crumb-current::before { display: none; }
  .hm-label { display: none; }
  [data-views] .table td:nth-child(n+4), [data-views] .table th:nth-child(n+4) { display: none; }
  .crumb-current { max-width: none; }
  .find-form { order: 10; flex: 1 0 100%; }
  .find { width: 100%; font-size: 16px; padding: 9px 12px; }
  .help-mode-btn { padding: 7px 9px; font-size: 11.5px; }
  .content { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  .footer { display: none; }
  .tabbar {
    display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; background: #fbfcfa;
    border-top: 1px solid #dfe5df; padding: 4px 4px max(6px, env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0; border: 0; background: none;
    font-size: 10.5px; color: #5c6f63; text-decoration: none; position: relative; border-radius: 10px;
  }
  .tabbar span { font-size: 20px; line-height: 1.1; }
  .tabbar .active { color: var(--accent-tab); font-weight: 700; background: #e9f2ea; }
  .tabbar .badge { position: absolute; top: 0; left: 55%; margin: 0; }
  .field input, .field select, .field textarea, .comment-form textarea, .filters input, .filters select,
  .item-row input, .item-row textarea, .stage-row input, .stage-row select, .sketch-fields input, .sketch-fields textarea { font-size: 16px; }
  .btn { font-size: 13px; padding: 9px 12px; }
  .btn.small { font-size: 12.5px; }
  .card { padding: 15px; }
  .table td, .table th { padding: 8px 10px; }
  .items-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr 1fr 28px; padding: 8px 0; border-top: 1px solid var(--line-2); }
  .item-row textarea { grid-column: 1 / -1; }
  .two { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
  .stat-num { font-size: 24px; }
  body.help-mode .main::before { font-size: 11.5px; }
}

/* Поиск реквизитов по ИНН / БИК в форме договора */
.lookup-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.lookup-row .field { flex: 1; min-width: 160px; }
.lookup-row > .btn { margin-bottom: 14px; }
.lookup-status { margin: -6px 0 12px; min-height: 0; }
.lookup-status:empty { display: none; }
.lookup-status.ok { color: var(--ok-text); }
.lookup-status.warn { color: var(--warn-text); }
.deal-card.is-done { opacity: .6; }
.deal-card .status-pill { margin-top: 6px; }
.stages .btn.small { margin-left: 6px; }
.stage-step:disabled { cursor: default; }

/* ── Список задач как в Битриксе ────────────────────────── */
.status-pill.progress { background: #e3eefc; color: #2a5b9c; }
.status-pill.deferred { background: #efeef4; color: #5d5a73; }
.status-pill.cancelled { background: #f1f1ef; color: #8a8f88; }
.warn-text { color: var(--warn-text); }
.view-switch a { display: inline-block; padding: 7px 11px; font-size: 12px; color: #4c5e53; text-decoration: none; }
.view-switch a.active { background: var(--active); font-weight: 700; color: var(--text); }
.counters { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.counter { border: 1px solid var(--btn-line); background: #fff; border-radius: 20px; padding: 4px 11px; font-size: 12px; color: #4c5e53; text-decoration: none; }
.counter b { margin-left: 4px; }
.counter.red { border-color: var(--err-line); color: var(--err-text); background: var(--err-bg); }
.counter.amber { border-color: var(--warn-line); color: var(--warn-text); background: var(--warn-bg); }
.counter.active { box-shadow: 0 0 0 2px var(--accent) inset; }
.counter.reset { margin-left: auto; border-style: dashed; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.preset { padding: 6px 11px; border-radius: 8px; font-size: 12px; text-decoration: none; color: #4c5e53; background: #e9eee9; }
.preset:hover { background: var(--hover); color: var(--text); }
.preset.active { background: var(--accent); color: #fff; font-weight: 650; }
.list-tools { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 8px; }
.col-picker { position: relative; }
.col-picker summary { list-style: none; }
.col-picker summary::-webkit-details-marker { display: none; }
.col-menu { position: absolute; right: 0; top: 34px; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; box-shadow: 0 10px 25px #10221920; min-width: 190px; }
.col-menu label { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 12.5px; white-space: nowrap; }
.tasks-table th a { color: inherit; text-decoration: none; }
.tasks-table th a:hover { color: var(--accent); }
.tasks-table .c-check { width: 36px; padding-right: 0; }
.tasks-table .c-check form { margin: 0; }
.tasks-table .check-btn { width: 22px; height: 22px; font-size: 12px; }
.tasks-table tr.overdue .c-title a { color: var(--err-text); }
.tasks-table tr.inactive td { color: #8a978e; }
.tasks-table.hide-id .c-id,
.tasks-table.hide-stage .c-stage,
.tasks-table.hide-activity .c-activity,
.tasks-table.hide-deadline .c-deadline,
.tasks-table.hide-created_by .c-created_by,
.tasks-table.hide-responsible .c-responsible,
.tasks-table.hide-status .c-status,
.tasks-table.hide-group .c-group,
.tasks-table.hide-created .c-created,
.tasks-table.hide-changed .c-changed,
.tasks-table.hide-closed .c-closed,
.tasks-table.hide-estimate .c-estimate,
.tasks-table.hide-tracking .c-tracking,
.tasks-table.hide-mark .c-mark,
.tasks-table.hide-allow_deadline .c-allow_deadline,
.tasks-table.hide-spent .c-spent,
.tasks-table.hide-tags .c-tags,
.tasks-table.hide-started .c-started,
.tasks-table.hide-plan_end .c-plan_end,
.tasks-table.hide-link_type .c-link_type,
.tasks-table.hide-client .c-client,
.tasks-table.hide-deal .c-deal { display: none; }
@media (max-width: 700px) {
  .counter.reset { margin-left: 0; }
  .presets { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .preset { white-space: nowrap; }
  .tasks-table td:not(.c-check):not(.c-title):not(.c-deadline):not(.c-status),
  .tasks-table th:not(.c-check):not(.c-deadline):not(.c-status):not(:nth-child(3)) { display: none; }
}
.status-pill { white-space: nowrap; }
.filter-more { display: contents; }
.filter-more > summary { display: none; }
.filters input[type=search] { min-width: 240px; }
@media (max-width: 700px) {
  .filter-more { display: block; width: 100%; }
  .filter-more > summary { display: inline-flex; list-style: none; }
  .filter-more > summary::-webkit-details-marker { display: none; }
  .filter-more[open] > select { display: block; width: 100%; margin-top: 8px; }
  .filters input[type=search] { min-width: 0; }
}

/* Таблица задач во всю ширину, как в Битриксе */
.tasks-table th { white-space: nowrap; }
.tasks-table .c-title { min-width: 220px; }
.tasks-table .c-title a.struck { text-decoration: line-through; color: #8a978e; }
.cm-count { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.stage-bar { display: block; width: 90px; height: 5px; border-radius: 3px; background: var(--c, var(--accent)); margin: 4px 0 3px; }
.dl { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11.5px; white-space: nowrap; background: #edf1ed; color: #4c5e53; }
.dl.late { background: var(--err-bg); color: var(--err-text); font-weight: 650; }
.dl.soon { background: var(--warn-bg); color: var(--warn-text); }
.dl.tomorrow { background: var(--ok-bg); color: var(--ok-text); }
.dl.later { background: #e8f0f9; color: #2a5b9c; }
.dl.done, .dl.none { background: none; color: var(--text-3); padding: 0; }
.col-menu { display: grid; grid-template-columns: repeat(2, minmax(190px, 1fr)); gap: 0 18px; min-width: 420px; }
.col-menu-actions { grid-column: 1 / -1; border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 6px; font-size: 12px; }
.col-menu-actions .link { background: none; border: 0; color: var(--accent-tab); cursor: pointer; padding: 0; }
@media (max-width: 700px) { .col-menu { grid-template-columns: 1fr; min-width: 230px; } }
.form-extra { margin: 4px 0 16px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.form-extra > summary { font-size: 12.5px; font-weight: 650; color: var(--accent-tab); margin-bottom: 10px; }

/* Файлы задачи */
.files-title { margin-top: 18px; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.file-tile { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.file-thumb { display: grid; place-items: center; height: 110px; background: #f2f5f2; text-decoration: none; }
.file-thumb img { width: 100%; height: 110px; object-fit: cover; }
.file-ext { font-weight: 800; font-size: 18px; color: var(--accent-tab); letter-spacing: .5px; }
.file-meta { padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.file-meta a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; font-weight: 600; }
.file-tile form { position: absolute; top: 4px; right: 4px; margin: 0; }
.file-tile .link-btn { background: #ffffffd9; border-radius: 50%; width: 24px; height: 24px; line-height: 20px; }
.dropzone { border: 1.5px dashed #b9cdbf; border-radius: 10px; padding: 12px; text-align: center; font-size: 12.5px; margin: 0; }
.dropzone label { cursor: pointer; display: block; }
.dropzone.over { background: #eef6f0; border-color: var(--accent); }
.dropzone.busy { opacity: .6; pointer-events: none; }
.dropzone.busy label::after { content: " — загружаю…"; }
