@font-face { font-family: Montserrat; src: url(/static/fonts/montserrat-cyrillic.woff2) format("woff2");
  font-weight: 100 900; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Montserrat; src: url(/static/fonts/montserrat-latin.woff2) format("woff2");
  font-weight: 100 900; }

:root { --accent: #a07462; --accent-dark: #85604f; --bg: #f6f3f1; --line: #e4dcd7; --text: #2b2421;
  --muted: #8a7d76; --danger: #b4443a; }
* { box-sizing: border-box; }
body { margin: 0; font-family: Montserrat, system-ui, sans-serif; font-size: 14px; color: var(--text);
  background: var(--bg); }
.test-banner { background: #f4d35e; color: #3a2f00; text-align: center; font-weight: 600; font-size: 13px;
  padding: 6px 10px; }
button, input, select { font: inherit; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px;
  cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.small { padding: 5px 10px; font-size: 13px; }
input, select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.err { color: var(--danger); min-height: 1.4em; }
.muted { color: var(--muted); }

/* Вход */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: #fff; border-radius: 16px; padding: 32px; width: 100%; max-width: 360px;
  box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--accent); }
.login-card label { display: block; margin: 16px 0 6px; font-weight: 600; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; margin-top: 20px; }

/* Каркас */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 20px 12px; display: flex;
  flex-direction: column; gap: 4px; }
.side .logo { font-weight: 800; color: var(--accent); font-size: 18px; padding: 0 10px 16px; }
.side a { display: block; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.side a.active, .side a:hover { background: var(--bg); color: var(--accent); }
.side .who { margin-top: auto; padding: 10px; font-size: 13px; }
main { padding: 24px 28px; min-width: 0; }
main h2 { margin: 0 0 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

table.grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
table.grid th, table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left;
  vertical-align: top; }
table.grid th { background: #faf7f5; font-weight: 600; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em; }
tr.off td { color: var(--muted); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--bg); font-size: 12px;
  margin: 0 4px 4px 0; }
.tag.won { background: #e3f1e4; } .tag.lost { background: #f6e1df; }

/* Модалка */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: grid; place-items: center;
  padding: 16px; z-index: 60;  /* выше карточки сделки (.panel 50) */ }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 440px;
  max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 12px; }
.modal label { display: block; margin: 12px 0 4px; font-weight: 600; }
.modal input, .modal select { width: 100%; }
.modal .checks { max-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; }
.modal .checks label { font-weight: 400; margin: 4px 0; display: flex; gap: 8px; align-items: center; }
.modal .checks input { width: auto; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 10px; }
  .side .logo { padding: 8px 10px; }
  .side .who { margin-top: 0; }
  main { padding: 16px; }
  table.grid { font-size: 13px; }
}
.tag { white-space: nowrap; }
.side .who a { display: inline; padding: 0; }
@media (max-width: 760px) {
  .side .who { width: 100%; display: flex; gap: 10px; align-items: baseline; padding: 6px 10px 0;
    border-top: 1px solid var(--line); }
  .side .who a { margin-left: auto; color: var(--accent); }
}

/* ── Этап 1: доска и карточка ─────────────────────────────────────── */
main.wide { padding-right: 12px; }
.board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 12px;
  min-height: calc(100vh - 120px); }
.col { flex: 0 0 260px; background: #f3eeea; border-radius: 12px; border-top: 4px solid var(--accent);
  display: flex; flex-direction: column; max-height: calc(100vh - 120px); }
.col.won { border-top-color: #5a9e60; } .col.lost { border-top-color: #b8655c; }
.col.drop { outline: 2px dashed var(--accent); }
.col-head { padding: 10px 12px 6px; }
.col-name { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.count { color: var(--muted); font-weight: 600; }
.small { font-size: 12px; }
.col-body { overflow-y: auto; padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px;
  min-height: 40px; }
.card { background: #fff; border-radius: 10px; padding: 10px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.08);
  cursor: pointer; }
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.14); }
.card.dragging { opacity: .4; }
.card-title { font-weight: 600; margin-bottom: 4px; word-break: break-word; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; gap: 6px; }
.card-task { font-size: 12px; margin-top: 6px; color: var(--muted); }
.card-task.overdue, .item.task.overdue > div:first-child { color: var(--danger); font-weight: 600; }
.avatars { display: flex; gap: 2px; margin-left: auto; }
.av { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px;
  display: grid; place-items: center; font-weight: 700; }

.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: #fff; z-index: 50;
  box-shadow: -4px 0 20px rgba(0,0,0,.15); display: flex; flex-direction: column; }
.panel-head { padding: 16px 20px 0; border-bottom: 1px solid var(--line); position: relative; }
.panel-head .x { position: absolute; right: 12px; top: 8px; border: 0; background: none; font-size: 26px;
  cursor: pointer; color: var(--muted); }
.panel-title { font-size: 18px; font-weight: 700; padding-right: 30px; word-break: break-word; }
.panel-meta { display: flex; gap: 8px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 20px; display: flex; flex-direction: column; gap: 8px; }
.feed { display: flex; flex-direction: column; gap: 8px; }
.item { border-radius: 10px; padding: 8px 12px; background: var(--bg); word-break: break-word; white-space: pre-wrap; }
.item.sys { background: none; padding: 2px 4px; }
.item.task { background: #fff7e8; } .item.task.done { background: #eef6ee; }
.item .result { margin-top: 4px; font-style: italic; }
.item.chat.mine { background: #f1e6e0; margin-left: 40px; }
.item.chat:not(.mine) { margin-right: 40px; }
.sub { font-weight: 700; margin-top: 10px; }
form.inline { display: flex; gap: 6px; margin-top: 6px; } form.inline input { flex: 1; min-width: 0; }
.composer { border-top: 1px solid var(--line); padding-top: 10px; margin-top: auto; display: flex;
  flex-direction: column; gap: 8px; }
textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
  box-sizing: border-box; resize: vertical; }
.task-row { display: flex; gap: 8px; flex-wrap: wrap; } .task-row[hidden] { display: none; }
.row { display: flex; gap: 8px; justify-content: flex-end; }
.about label { display: block; margin: 10px 0 4px; font-weight: 600; }
.about input { width: 100%; box-sizing: border-box; }
.about .checks label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.about .checks input { width: auto; }
.modal textarea { width: 100%; }

@media (max-width: 760px) {
  .board { flex-direction: column; align-items: stretch; overflow-x: visible; min-height: 0; }
  .col { flex: none; max-height: none; }
  .col-body { overflow: visible; }
  .panel-head, .panel-body { padding-left: 14px; padding-right: 14px; }
}
.panel-meta select { flex: 1; min-width: 0; max-width: 100%; box-sizing: border-box; }

/* Этап 2: общая воронка */
.inbox { display: flex; flex-direction: column; gap: 8px; }
.inbox-row { display: flex; gap: 12px; justify-content: space-between; background: #fff; border-radius: 10px;
  padding: 12px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.08); cursor: pointer; }
.inbox-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,.14); }
.inbox-main { min-width: 0; flex: 1; }
.inbox-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.copies { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.copies .tag { white-space: normal; }
.req-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.returned-note { background: #f6e1df; border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 13px; }
.dist-list { max-height: 50vh; overflow-y: auto; flex-direction: column; }
.dist-list label.match { font-weight: 600; }
.tiles { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border-radius: 10px; padding: 12px 16px; min-width: 140px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tile-n { font-size: 26px; font-weight: 700; }
@media (max-width: 700px) {
  .inbox-row { flex-direction: column; }
  .inbox-side { flex-direction: row; flex-wrap: wrap; align-items: center; }
}
