/* KorsaCRM — чёрно-белый минимализм, шрифт Onest (вариативный, лежит рядом: fonts/) */

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/onest-cyrillic-ext.woff2) format("woff2-variations");
  unicode-range: u+0460-052f, u+1c80-1c8a, u+20b4, u+2de0-2dff, u+a640-a69f, u+fe2e-fe2f;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/onest-cyrillic.woff2) format("woff2-variations");
  unicode-range: u+0301, u+0400-045f, u+0490-0491, u+04b0-04b1, u+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/onest-latin-ext.woff2) format("woff2-variations");
  unicode-range: u+0100-02ba, u+02bd-02c5, u+02c7-02cc, u+02ce-02d7, u+02dd-02ff, u+0304, u+0308, u+0329, u+1d00-1dbf, u+1e00-1e9f, u+1ef2-1eff, u+2020, u+20a0-20ab, u+20ad-20c0, u+2113, u+2c60-2c7f, u+a720-a7ff;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/onest-latin.woff2) format("woff2-variations");
  unicode-range: u+0000-00ff, u+0131, u+0152-0153, u+02bb-02bc, u+02c6, u+02da, u+02dc, u+0304, u+0308, u+0329, u+2000-206f, u+20ac, u+2122, u+2191, u+2193, u+2212, u+2215, u+feff, u+fffd;
}

:root {
  color-scheme: light;
  --ink: #0a0a0a;
  --ink-soft: #3d3d3d;
  --ink-hover: #2b2b2b;
  --on-ink: #ffffff;              /* текст и значки на «чернильной» плашке */
  --on-ink-soft: rgba(255, 255, 255, .62);
  --muted: #8a8a8a;
  --faint: #b5b5b5;
  --line: #e6e6e6;
  --line-soft: #efefef;
  --soft: #f4f4f2;
  --bg: #fafaf9;
  --paper: #ffffff;
  --overlay: rgba(10, 10, 10, .42);
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, .14);
  --sidebar-w: 216px;
  /* просрочка: до порога «тишины» — жёлтый, дальше — красный */
  --soon: #b45309;
  --soon-bg: #fef3c7;
  --late: #dc2626;
  --late-bg: #fee2e2;
  --good: #15803d;
  --good-bg: #dcfce7;
}

/* Тёмная тема — та же чёрно-белая система, роли токенов не меняются:
   paper остаётся самой светлой поверхностью (карточки), soft — подложка,
   ink — основной контраст, поэтому вся вёрстка работает без правок. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #f4f4f5;
    --ink-soft: #c6c6ca;
    --ink-hover: #e2e2e5;
    --on-ink: #0a0a0b;
    --on-ink-soft: rgba(10, 10, 11, .6);
    --muted: #8b8b93;
    --faint: #78787f;
    --line: #33333a;
    --line-soft: #26262b;
    --soft: #17171a;
    --bg: #0a0a0b;
    --paper: #1c1c20;
    --overlay: rgba(0, 0, 0, .62);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-pop: 0 16px 48px rgba(0, 0, 0, .6);
    --soon: #fbbf24;
    --soon-bg: rgba(251, 191, 36, .14);
    --late: #f87171;
    --late-bg: rgba(248, 113, 113, .14);
    --good: #4ade80;
    --good-bg: rgba(74, 222, 128, .14);
  }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip.proj { color: color-mix(in srgb, var(--pc) 70%, white); }
}
:root[data-theme="dark"] .chip.proj { color: color-mix(in srgb, var(--pc) 70%, white); }
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f4f5;
  --ink-soft: #c6c6ca;
  --ink-hover: #e2e2e5;
  --on-ink: #0a0a0b;
  --on-ink-soft: rgba(10, 10, 11, .6);
  --muted: #8b8b93;
  --faint: #78787f;
  --line: #33333a;
  --line-soft: #26262b;
  --soft: #17171a;
  --bg: #0a0a0b;
  --paper: #1c1c20;
  --overlay: rgba(0, 0, 0, .62);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-pop: 0 16px 48px rgba(0, 0, 0, .6);
  --soon: #fbbf24;
  --soon-bg: rgba(251, 191, 36, .14);
  --late: #f87171;
  --late-bg: rgba(248, 113, 113, .14);
    --good: #4ade80;
    --good-bg: rgba(74, 222, 128, .14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Onest", Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { width: 16px; height: 16px; flex: none; }

#app { display: flex; min-height: 100vh; }

/* ---------- Сайдбар ---------- */
#sidebar {
  width: var(--sidebar-w);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 20px 12px 16px;
}
.logo {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.02em;
  padding: 4px 10px 18px;
  display: block;
}
.logo span { font-weight: 400; color: var(--muted); }

#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { stroke-width: 1.8; }
.nav-item:hover { background: var(--soft); color: var(--ink); }
.nav-item.active { background: var(--ink); color: var(--on-ink); }
.nav-item .count {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.nav-item.active .count { color: var(--on-ink-soft); }

.sidebar-foot { margin-top: auto; padding: 10px 4px 0; }
.db-status { font-size: 13px; color: var(--faint); padding: 10px 6px 0; }

/* аккаунты */
.avatar {
  width: 26px; height: 26px; border-radius: 999px; flex: none;
  background: var(--ink); color: var(--on-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.avatar-sm { width: 20px; height: 20px; font-size: 11.5px; }
.account-row {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 8px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--paper); text-align: left;
  transition: background .15s;
}
.account-row:hover { background: var(--soft); }
.account-row .acc-name { font-weight: 700; font-size: 15px; flex: 1; }
.account-row .acc-switch { font-size: 12.5px; color: var(--faint); font-weight: 600; }
.account-pick { display: flex; flex-direction: column; gap: 8px; }
.account-option {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  font-weight: 700; font-size: 16px;
  transition: background .15s, border-color .15s;
}
.account-option:hover { background: var(--soft); border-color: var(--faint); }
.account-option.current { border-color: var(--ink); }
.tl-icon.tl-avatar { background: var(--ink); color: var(--on-ink); border-color: var(--ink); font-weight: 700; font-size: 14px; }
.tl-meta b { color: var(--ink-soft); }

/* ---------- Топбар ---------- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
#page-title { font-size: 21px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }

.pills { display: flex; gap: 4px; background: var(--soft); border-radius: 999px; padding: 3px; }
.pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.pill:hover { color: var(--ink); }
.pill.active { background: var(--ink); color: var(--on-ink); }

.kbd {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--paper);
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-weight: 600;
  font-size: 15px;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn-primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--soft); }
.btn-danger:hover { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }
.btn-sm { padding: 4px 10px; font-size: 14.5px; border-radius: 7px; }
.btn svg { stroke-width: 2; }

/* ---------- Контент ---------- */
#view { padding: 24px 28px 60px; flex: 1; min-width: 0; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.toolbar .meta { color: var(--muted); font-size: 14.5px; font-weight: 500; }

.input, .select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus { border-color: var(--ink); }
.input::placeholder { color: var(--faint); }
.search-input { min-width: 220px; }

/* селекты: убираем нативный вид, своя стрелка */
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238a8a8a" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 13px;
  cursor: pointer;
}
.select:hover { border-color: var(--faint); }

/* ---------- Экран входа ---------- */
body.login-mode { background: var(--bg); }
.login-wrap {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.login-card {
  width: 340px;
  max-width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-logo { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.login-logo span { font-weight: 400; color: var(--muted); }
.login-hint { font-size: 15px; color: var(--muted); margin-top: -10px; }
.login-error { font-size: 14.5px; font-weight: 600; min-height: 16px; }
.login-error:not(:empty) { color: var(--ink); }
.login-submit { justify-content: center; height: 40px; }

/* ---------- Выпадающий список ---------- */
.selectfield { display: inline-block; position: relative; }
.select-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  font-weight: 500;
  cursor: pointer;
}
.select-btn:hover { border-color: var(--faint); }
.select-btn svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.select-btn .select-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-btn.is-empty .select-text { color: var(--muted); font-weight: 500; }
.field .selectfield { width: 100%; }

.selectpop {
  position: fixed;
  z-index: 130;
  min-width: 200px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 5px;
  animation: pop .12s ease-out;
}
.sp-search {
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: none;
  padding: 8px 10px;
  margin: -5px -5px 5px;
  font-size: 15px;
  background: var(--paper);
  border-radius: var(--radius) var(--radius) 0 0;
}
.sp-search::placeholder { color: var(--faint); }
.sp-list { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.sp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  color: var(--ink-soft);
}
.sp-item .sp-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-item svg { width: 14px; height: 14px; flex: none; }
.sp-item.cur { background: var(--soft); color: var(--ink); }
.sp-item.sel { color: var(--ink); font-weight: 600; }
.sp-item.sel.cur { background: var(--soft); }

/* ---------- Поле даты ---------- */
.datefield { display: inline-block; position: relative; }
.date-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.date-btn:hover { border-color: var(--faint); }
.date-btn svg { width: 15px; height: 15px; color: var(--muted); stroke-width: 1.8; }
.date-btn.is-empty .date-text { color: var(--faint); font-weight: 400; }
.field .datefield { width: 100%; }

/* календарь */
.dp-overlay { position: fixed; inset: 0; z-index: 125; background: var(--overlay); animation: fade .12s ease-out; }
.datepop {
  position: fixed;
  z-index: 130;
  width: 280px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  animation: pop .12s ease-out;
}
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.dp-nav {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.dp-nav:hover { background: var(--soft); color: var(--ink); }
.dp-nav svg { width: 15px; height: 15px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--faint); text-align: center; padding-bottom: 6px;
}
.dp-day {
  height: 34px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  transition: background .12s, color .12s;
}
.dp-day:hover { background: var(--soft); color: var(--ink); }
.dp-day.we { color: var(--muted); }
.dp-day.out { color: var(--faint); font-weight: 500; }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--faint); }
.dp-day.sel, .dp-day.sel:hover { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.dp-foot {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.dp-foot .dp-clear { margin-left: auto; color: var(--muted); }

.seg { display: inline-flex; background: var(--soft); border-radius: 8px; padding: 3px; }
.seg button {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
}
/* в тёмной теме тень не видна, поэтому активную вкладку обводим тонким контуром */
.seg button.active { background: var(--paper); color: var(--ink); box-shadow: 0 0 0 1px var(--line), var(--shadow); }

/* ---------- Таблицы ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--ink); }
th .arrow { font-size: 11.5px; }
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: var(--bg); }
td .sub { color: var(--muted); font-size: 14px; }
/* Ячейка в одну строку: длинное обрезается многоточием, полный текст в title */
td .line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
/* ссылки (почта, ник) режутся так же — иначе колонка тянется под самый длинный ник */
td a.line { max-width: 190px; }
td .line.narrow { max-width: 160px; }
td.nowrap { white-space: nowrap; }
/* чип с длинным значением («Сайт …tilda.ws») режется, а не растягивает колонку */
.chip.clip { max-width: 170px; display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
td a.ext:hover { text-decoration: underline; }
.name-cell { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { text-align: right; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .big { font-size: 17px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }

/* ---------- Чипы ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper);
  white-space: nowrap;
}
.chip.solid { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chip.ghost { background: var(--soft); border-color: transparent; color: var(--muted); }
/* Метка проекта: цвет приходит из настроек через --pc. Фон — та же краска,
   разбавленная до подложки, поэтому чёрно-белая система не рассыпается. */
.chip.proj { background: var(--soft); border-color: transparent; color: var(--pc, var(--muted)); }
.chip.proj { background: color-mix(in srgb, var(--pc) 12%, transparent); }
.proj-colors { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.proj-color { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.proj-color input[type="color"] {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px; padding: 0; border: 1px solid var(--line);
  border-radius: 50%; background: none; cursor: pointer;
}
.proj-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.proj-color input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
.chip.lost { color: var(--muted); text-decoration: line-through; }
.chip.unfit { color: var(--muted); border-style: dashed; }
.chip-x { cursor: pointer; opacity: .5; font-weight: 700; }
.chip-x:hover { opacity: 1; }

/* ---------- Канбан ---------- */
.kanban {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 20px;
}
.kcol {
  flex: none;
  width: 272px;
  background: var(--soft);
  border-radius: var(--radius-lg);
  padding: 10px;
  max-height: calc(100vh - 200px);
  display: flex;
  flex-direction: column;
}
.kcol.terminal { background: transparent; border: 1px dashed var(--line); }
.kcol-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 6px 10px;
}
.kcol-head .kname { font-weight: 700; font-size: 15px; }
.kcol-head .kcount { color: var(--muted); font-size: 14px; font-weight: 600; }
.kcol-head .ksum { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; }
/* порядок карточек в колонке: иконка, а если не «вручную» — ещё и подпись */
.kcol-head .ksort {
  align-self: center; display: inline-flex; align-items: center; gap: 3px;
  height: 22px; padding: 0 5px; margin: -2px -4px -2px 0; border-radius: 6px;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.kcol-head .ksort svg { width: 13px; height: 13px; }
.kcol-head .ksort:hover { background: var(--paper); color: var(--ink); }
.kcol-head .ksort.on { color: var(--ink); }
.kcards { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 40px; flex: 1; }
.kcard {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.kcard:hover { border-color: var(--faint); }
.kcard.dragging { opacity: .35; }
.kcard .ktitle { font-weight: 700; font-size: 15.5px; line-height: 1.3; letter-spacing: -.01em; }
/* название сделки — пояснение под именем клиента, а не главный элемент */
.kcard .ksub { font-size: 14px; font-weight: 500; color: var(--muted); line-height: 1.3; margin-top: 2px; }
/* Свёрнутая карточка: заголовок с кнопкой «···», название в одну строку,
   контакт и длинный текст шага спрятаны. .open возвращает всё. */
.kcard .khead { display: flex; align-items: flex-start; gap: 6px; }
.kcard .khead .ktitle { flex: 1; min-width: 0; }
.kcard .kmore { flex: none; width: 22px; height: 22px; margin: -3px -6px 0 0; color: var(--faint); opacity: 0; transition: opacity .12s; }
.kcard:hover .kmore, .kcard.open .kmore { opacity: 1; }
.kcard .kmore:hover { color: var(--ink); }
.kcard:not(.open) .ksub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard:not(.open) .kmeta { display: none; }
@media (hover: none) { .kcard .kmore { opacity: 1; } }
.kcard .kamount { font-weight: 700; font-size: 16px; margin-top: 6px; }
.kcard .kmeta { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; flex-direction: column; gap: 1px; }
.kcard .kfoot { display: flex; gap: 6px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.kcard .age { margin-left: auto; font-size: 12px; color: var(--faint); font-weight: 600; }
/* следующий шаг на карточке; сделка без шага помечена полосой слева */
.kcard .kstep {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.35;
}
.kcard .kstep.warn { font-weight: 700; color: var(--ink); }
/* Заметка следующего шага: своя рамка, полный текст, без обрезки и стрелок */
.kcard .knote {
  margin-top: 8px;
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink-soft);
  background: var(--soft);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.kcard .knote .knote-when { display: block; margin-top: 3px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kcard.attention { border-left: 3px solid var(--faint); padding-left: 9px; }
.kcard.attention.sev2 { border-left-color: var(--ink-soft); }
.kcard.attention.sev3 { border-left-color: var(--ink); }
.kcol.dragover { outline: 2px solid var(--ink); outline-offset: -2px; }
.kadd {
  margin-top: 8px;
  padding: 7px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14.5px;
  text-align: center;
  border: 1px dashed var(--line);
  transition: color .15s, border-color .15s;
}
.kadd:hover { color: var(--ink); border-color: var(--faint); }

/* ---------- Дашборд ---------- */
.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.detail-cols > * { min-width: 0; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.kpi .value { font-size: 28.5px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; line-height: 1.2; }
.kpi .sub { font-size: 14px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.dash-cols { grid-template-columns: 1.2fr 1fr; align-items: start; }
.panel { padding: 18px; }
.panel h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; letter-spacing: -.01em; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.panel-head h3 { margin-bottom: 0; }
.panel-head .icon-btn { color: var(--muted); }
/* правка блока «Данные» на месте: те же поля, что в модалке */
.props-edit { display: flex; flex-direction: column; gap: 12px; }
.props-edit-foot { display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px; }
.props-edit-foot .left { margin-right: auto; }
/* контакты сделки: звезда — главный */
.contact-row { align-items: center; }
.contact-row .star { flex: none; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: var(--faint); border-radius: 6px; }
.contact-row .star svg { width: 15px; height: 15px; }
.contact-row .star:hover { color: var(--ink); background: var(--soft); }
.contact-row.primary .star { color: var(--ink); }
.contact-row.primary .star svg { fill: currentColor; }
.contact-row a.when:hover { text-decoration: underline; }
.panel h3 .hint { color: var(--muted); font-weight: 500; font-size: 14px; }
.stack > * + * { margin-top: 14px; }

/* воронка: один ряд на этап — трек, заливка, прямые подписи */
.funnel-row { display: grid; grid-template-columns: 150px 1fr 130px; gap: 10px; align-items: center; margin-bottom: 10px; }
.funnel-row .fname { font-size: 14.5px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel-row .track { height: 22px; background: var(--soft); border-radius: 4px 6px 6px 4px; overflow: hidden; }
.funnel-row .fill { height: 100%; background: var(--ink); border-radius: 0 4px 4px 0; min-width: 2px; transition: width .3s; }
.funnel-row .fval { font-size: 14px; font-weight: 600; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.mini-list { display: flex; flex-direction: column; }
.mini-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
}
.mini-row:last-child { border-bottom: 0; }
.mini-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .grow.wrap { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.4; }
.mini-row .when { color: var(--muted); font-size: 13px; white-space: nowrap; font-weight: 500; }
.mini-row a:hover { text-decoration: underline; }

/* ---------- Чекбоксы задач ---------- */
.check {
  width: 17px; height: 17px;
  border: 1.6px solid var(--faint);
  border-radius: 5px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  cursor: pointer;
  background: var(--paper);
}
.check:hover { border-color: var(--ink); }
.check.on { background: var(--ink); border-color: var(--ink); }
.check.on::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--on-ink); border-bottom: 2px solid var(--on-ink); transform: rotate(-45deg) translate(0, -1px); }

.task-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.task-row:last-child { border-bottom: 0; }
.task-row .t-title { font-weight: 500; cursor: pointer; }
.task-row.done .t-title { color: var(--muted); text-decoration: line-through; }
.task-row .t-links { color: var(--muted); font-size: 14px; }
.task-row .t-links a:hover { text-decoration: underline; }
.task-row .t-due { margin-left: auto; font-size: 14px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.task-row .t-due.overdue { color: var(--ink); font-weight: 700; }

.task-row .t-due.overdue::before { content: "! "; }
.prio { width: 4px; height: 22px; border-radius: 2px; flex: none; }
.prio.high { background: var(--ink); }
.prio.normal { background: var(--faint); }
.prio.low { background: var(--line); }

.group-title {
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin: 22px 2px 8px;
}
.group-title:first-child { margin-top: 0; }

/* ---------- Страница деталей ---------- */
.detail-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.detail-head .back {
  width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; background: var(--paper);
}
.detail-head .back:hover { background: var(--soft); }
.detail-head h2 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
.detail-head .subtitle { color: var(--muted); font-weight: 500; margin-top: 2px; }
.detail-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.detail-cols { display: grid; grid-template-columns: 400px 1fr; gap: 14px; align-items: start; }

.props { display: flex; flex-direction: column; }
.prop { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; }
.prop:last-child { border-bottom: 0; }
.prop .k { color: var(--muted); font-weight: 500; }
.prop .v { font-weight: 500; word-break: break-word; }
.prop .v a:hover { text-decoration: underline; }
.prop .v.empty-v { color: var(--faint); font-weight: 400; }

/* этапы сделки — степпер */
.stepper { display: flex; gap: 4px; margin: 4px 0 16px; flex-wrap: wrap; }
.step {
  flex: 1;
  min-width: 90px;
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  background: var(--soft);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.step:first-child { border-radius: 8px 0 0 8px; }
.step:last-child { border-radius: 0 8px 8px 0; }
.step:hover { color: var(--ink); }
.step.on { background: var(--ink); color: var(--on-ink); }
.step.passed { background: var(--ink-soft); color: var(--on-ink); }

/* ---------- Следующий шаг у сделки ---------- */
.nextstep {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
}
.nextstep.warn { border-color: var(--ink); }
.nextstep .ns-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.nextstep .ns-text { font-weight: 600; cursor: pointer; }
.nextstep .ns-text:hover { text-decoration: underline; }
.nextstep .ns-empty { color: var(--muted); font-weight: 500; }
.nextstep .ns-when { color: var(--muted); font-weight: 600; font-size: 14px; }
.nextstep .ns-when.overdue { color: var(--ink); }
.nextstep .ns-plan { margin-left: auto; }

/* маркер важности в списке «Требуют внимания» */
.sev { width: 3px; height: 20px; border-radius: 2px; flex: none; background: var(--faint); }
.sev.sev2 { background: var(--ink-soft); }
.sev.sev3 { background: var(--ink); }

/* быстрые действия над строкой записи */
.quick-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.quick-acts .btn:disabled { opacity: .5; cursor: wait; }

.stage-row .s-next {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 1px;
}

/* ---------- Таймлайн ---------- */
/* строка быстрого добавления: поле + дата + кнопка */
.quick-add {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
  max-width: 560px;
}
/* в узкой колонке (карточка сделки, контакта) поле переносится на свою строку */
.quick-add .qa-text { flex: 1 1 200px; min-width: 0; }
/* на широком экране в шапке раздела места хватает: держим форму одной строкой,
   а при нехватке переносится вся форма целиком, а не её кнопка.
   На телефоне остаётся перенос — иначе строка не помещается в экран. */
@media (min-width: 801px) {
  .toolbar .quick-add { flex: 1 1 560px; flex-wrap: nowrap; }
}
.quick-add .qa-add { flex: none; }

.composer { display: flex; gap: 8px; margin-bottom: 16px; align-items: flex-start; }
.composer textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  resize: vertical;
  min-height: 38px;
  outline: none;
  background: var(--paper);
}
.composer textarea:focus { border-color: var(--ink); }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.tl-item:last-child { border-bottom: 0; }
.tl-icon {
  width: 28px; height: 28px; flex: none;
  border: 1px solid var(--line); border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper);
}
.tl-icon svg { width: 13px; height: 13px; stroke-width: 2; }
.tl-item.system .tl-icon { border-style: dashed; }
.tl-body { flex: 1; min-width: 0; }
.tl-body .tl-text { font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.tl-item.system .tl-text { color: var(--muted); }
.tl-body .tl-meta { font-size: 13px; color: var(--faint); margin-top: 2px; font-weight: 500; }
.tl-del { opacity: 0; color: var(--faint); font-weight: 700; padding: 0 4px; }
.tl-item:hover .tl-del { opacity: 1; }
.tl-del:hover { color: var(--ink); }
/* на тач-экранах наведения нет — кнопка удаления должна быть видна сразу */
@media (hover: none) {
  .tl-del { opacity: .55; padding: 0 8px; }
}

/* ---------- Модалки ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--overlay);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 20px 20px;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 100%;
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: var(--shadow-pop);
  animation: pop .14s ease-out;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 0;
}
.modal-head h3 { font-size: 17.5px; font-weight: 700; letter-spacing: -.01em; }
.modal-close { color: var(--muted); font-size: 22px; line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 5px; }
.field .input, .field .select, .field textarea { width: 100%; }
.field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  min-height: 70px; resize: vertical; outline: none; background: var(--paper);
}
.field textarea:focus { border-color: var(--ink); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: end; }
.field-row > * { min-width: 0; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end; align-items: center;
  padding: 4px 20px 20px;
}
.modal-foot .left { margin-right: auto; }

/* ---------- Палитра (⌘K) ---------- */
.palette-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: var(--overlay);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 14vh 20px 20px;
  animation: fade .1s ease-out;
}
.palette {
  width: 560px; max-width: 100%;
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: pop .12s ease-out;
}
.palette input {
  width: 100%;
  border: 0; outline: none;
  padding: 16px 18px;
  font-size: 17px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.palette-results { max-height: 46vh; overflow-y: auto; padding: 6px; }
.p-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 15.5px;
}
.p-item .p-type {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); width: 74px; flex: none;
}
.p-item .p-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-item .p-sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-item.sel { background: var(--ink); color: var(--on-ink); }
.p-item.sel .p-type, .p-item.sel .p-sub { color: var(--on-ink-soft); }
.p-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 15px; }

/* ---------- Меню (выпадающее) ---------- */
.menu {
  position: fixed; z-index: 110;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 5px;
  min-width: 180px;
  animation: pop .1s ease-out;
}
.menu button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 7px;
  font-weight: 500; font-size: 15px;
}
.menu button:hover { background: var(--soft); }
.menu button svg { stroke-width: 1.8; color: var(--muted); }

/* ---------- Тосты ---------- */
#toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: var(--on-ink);
  padding: 9px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 600;
  box-shadow: var(--shadow-pop);
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
.toast.out { transition: opacity .3s, transform .3s; opacity: 0; transform: translateY(6px); }

/* ---------- Настройки ---------- */
/* Настройки: разделы сверху вниз, внутри раздела — пара карточек.
   Так короткие блоки не оставляют дыр, как это было в общей сетке. */
.settings-wrap { max-width: 980px; }
.settings-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }

/* строка справочника: слева название с пояснением, справа значения */
.ref-row {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 16px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.ref-row:first-child { padding-top: 0; }
.ref-row:last-child { padding-bottom: 0; border-bottom: 0; }
.ref-label { font-size: 15px; font-weight: 600; }
.ref-label span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-editor { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.stage-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft);
}
.stage-row:last-child { border-bottom: 0; }
.stage-row .s-name { flex: 1; font-weight: 600; }
.stage-row .icon-btn, .icon-btn {
  width: 26px; height: 26px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.icon-btn:hover { background: var(--soft); color: var(--ink); }
.icon-btn svg { width: 14px; height: 14px; stroke-width: 2; }
.settings-note { font-size: 14px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* ---------- Разное ---------- */
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 14px; }
.link-like { font-weight: 600; cursor: pointer; }
.link-like:hover { text-decoration: underline; }
tr.row-lost td .name-cell, tr.row-lost .name-cell { color: var(--muted); }

::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ---------- Мобильная навигация (нижний таб-бар) ---------- */
#mobile-nav { display: none; }

/* Плотная таблица: девять колонок контактов на ноутбуке не помещаются
   с обычными паддингами — их и режем, а не данные. */
table.dense td, table.dense th { padding-left: 10px; padding-right: 10px; }
table.dense td:first-child, table.dense th:first-child { padding-left: 14px; }
/* вторичные колонки прячем до широкого экрана */
@media (max-width: 1500px) { th.hide-l, td.hide-l { display: none; } }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-cols, .detail-cols, .settings-pair { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  #sidebar { display: none; }
  .ref-row { grid-template-columns: 1fr; gap: 8px; }
  #view { padding: 14px 14px calc(88px + env(safe-area-inset-bottom)); }

  /* топбар в одну строку: заголовок — пилюли проектов (скролл) — кнопки */
  /* padding-top учитывает «чёлку» при запуске с домашнего экрана */
  #topbar {
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    flex-wrap: nowrap;
    gap: 8px;
  }
  #page-title { font-size: 18.5px; flex: none; max-width: 38vw; overflow: hidden; text-overflow: ellipsis; }
  .topbar-right { flex: 1; min-width: 0; justify-content: flex-end; gap: 8px; flex-wrap: nowrap; }
  .pills {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .pills::-webkit-scrollbar { display: none; }
  #search-btn, #add-btn { flex: none; }
  .kbd { display: none; }
  #add-btn .add-label { display: none; }
  #add-btn { padding: 7px 10px; }

  /* нижний таб-бар */
  #mobile-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    background: color-mix(in srgb, var(--paper) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .mnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px 4px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    background: none;
    border: 0;
  }
  .mnav-item svg { width: 20px; height: 20px; stroke-width: 1.8; }
  .mnav-item.active { color: var(--ink); }

  /* таблицы: на телефоне показываем главные колонки, остальное — в карточке записи */
  th.hide-m, td.hide-m { display: none; }
  th, td { padding: 10px 10px; }

  /* канбан: колонка почти во всю ширину, перелистывание свайпом */
  .kanban { scroll-snap-type: x proximity; gap: 10px; }
  .kcol { width: 84vw; scroll-snap-align: start; max-height: calc(100vh - 260px); }

  /* формы — bottom sheet, поля в один столбец */
  .overlay { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; animation: sheet .18s ease-out; }
  .field-row { grid-template-columns: 1fr; }

  /* деталки */
  .detail-head h2 { font-size: 20px; }
  .detail-head .actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .stepper { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .step { flex: none; min-width: 110px; }

  /* палитра поиска */
  .palette-overlay { padding: 4vh 10px 10px; }

  /* Safari увеличивает страницу при фокусе, если текст в поле мельче 16px.
     Поэтому на телефоне все поля ввода — 16px и чуть выше для удобного нажатия. */
  .input, .select-btn, .date-btn, .field textarea, .composer textarea,
  .sp-search, .palette input, .modal input, .modal textarea {
    font-size: 17.5px;
  }
  .input, .select-btn, .date-btn { height: 40px; }
  .field textarea, .composer textarea { min-height: 84px; }
  .sp-item, .dp-day { font-size: 17px; }

  /* добавление задачи: поле на всю ширину, под ним дата и кнопка */
  .quick-add { flex-wrap: wrap; max-width: none; flex-basis: 100%; }
  .quick-add .qa-text { flex: 1 0 100%; }
  .quick-add .datefield { flex: 1; }
  .quick-add .qa-add { padding: 0 16px; height: 40px; }

  /* запись в историю: текст сверху, под ним тип и кнопка */
  .composer { flex-wrap: wrap; }
  .composer textarea { flex: 1 0 100%; order: -1; }
  .composer .selectfield { flex: 1; }
  .composer .btn-primary { flex: 1; justify-content: center; height: 40px; }

  /* списки на телефоне — по центру экрана, с крупными строками */
  .selectpop.sheet {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(340px, calc(100vw - 32px));
    max-height: 70vh;
    padding: 6px;
  }
  .selectpop.sheet .sp-item { padding: 12px 12px; font-size: 16px; }
  .selectpop.sheet .sp-search { padding: 11px 12px; margin: -6px -6px 6px; font-size: 17px; }

  /* календарь на телефоне — по центру экрана, с крупными днями */
  .datepop.sheet {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(320px, calc(100vw - 32px));
  }
  .datepop.sheet .dp-day { height: 40px; font-size: 16px; }

  /* панели и KPI компактнее */
  .panel { padding: 14px; }
  .kpi .value { font-size: 23px; }
  .funnel-row { grid-template-columns: 96px 1fr 110px; gap: 8px; }
}
@keyframes sheet { from { transform: translateY(24px); opacity: .6; } }

/* уведомления в настройках */
.push-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.push-row .btn:disabled { opacity: .5; cursor: not-allowed; }

/* место вставки при перетаскивании карточки */
.kdrop {
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  margin: 3px 2px;
}

/* две смысловые половины внутри одной карточки — без разрыва между блоками */
.settings-split { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.settings-split > div > h3:first-child { margin-bottom: 14px; }
@media (max-width: 800px) {
  .settings-split { grid-template-columns: 1fr; gap: 22px; }
}

/* ---------- Календарь задач ---------- */
.cal {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.cal-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.cal-head .cal-nav { flex: none; }
.cal-head #cal-today { margin-left: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-wd {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); text-align: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}
.cal-cell {
  min-height: 106px;
  padding: 6px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  min-width: 0;
  transition: background .12s;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: var(--bg); }
.cal-cell.out { background: var(--bg); }
.cal-cell.out .cal-day { color: var(--faint); }
.cal-daybar { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.cal-day {
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
  width: 21px; height: 21px;
  display: inline-flex; align-items: center; justify-content: center;
}
.cal-cell.today .cal-day { background: var(--ink); color: var(--on-ink); border-radius: 999px; }
.cal-count { display: none; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-items { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-task {
  display: flex; align-items: center; gap: 5px;
  width: 100%; text-align: left;
  font-size: 13px; font-weight: 500;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink-soft);
  min-width: 0; max-width: 100%;
  overflow: hidden;
}
/* первая буква имени ответственного — видно, чья задача */
.cal-who {
  flex: none;
  width: 15px; height: 15px;
  border-radius: 999px;
  background: var(--ink); color: var(--on-ink);
  font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.cal-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-task:hover { background: var(--line); color: var(--ink); }
.cal-task.done .cal-txt { color: var(--muted); text-decoration: line-through; }
.cal-task.done .cal-who { background: var(--faint); }
.cal-task.over { box-shadow: inset 2px 0 0 var(--ink); color: var(--ink); font-weight: 700; }
.cal-more { font-size: 12.5px; font-weight: 600; color: var(--muted); text-align: left; padding: 2px 6px; }
.cal-more:hover { color: var(--ink); }
.cal-week .cal-cell { min-height: 260px; }

@media (max-width: 800px) {
  /* месяц — обзор: день и число задач, тап открывает эту неделю */
  .cal-month .cal-cell { min-height: 58px; padding: 4px 2px; }
  .cal-month .cal-items { display: none; }
  .cal-month .cal-count { display: inline; }
  .cal-month .cal-daybar { flex-direction: column; gap: 2px; }
  /* неделя — семь дней в столбик, так задачи читаются целиком */
  .cal-week .cal-grid { grid-template-columns: 1fr; }
  .cal-week .cal-wd { display: none; }
  .cal-week .cal-cell { min-height: auto; border-right: 0; padding: 10px 12px; }
  .cal-week .cal-daybar::after {
    content: attr(data-wd);
    font-size: 12.5px; font-weight: 600; color: var(--muted);
  }
}

/* ============================== Чаты с сайтов ==============================
   Переписка приходит из korsa-api, здесь только показ и ответ оператора.
   Раскладка «список + переписка», как в почте: слева обращения, справа диалог. */

.chat-split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items: start;
}
.chat-list {
  max-height: calc(100dvh - 210px);
  overflow: auto;
}
.chat-item {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}
.chat-item:last-child { border-bottom: 0; }
.chat-item:hover { background: var(--soft); }
.chat-item.active { background: var(--soft); box-shadow: inset 3px 0 0 var(--ink); }
.chat-item-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.chat-brand { font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.chat-flag.human {
  font-size: 12px; padding: 1px 6px; border-radius: 20px;
  background: var(--ink); color: var(--on-ink);
}
.chat-unread {
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 20px;
  background: var(--ink); color: var(--on-ink);
  font-size: 12.5px; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums;
}
.chat-when { margin-left: auto; font-size: 12.5px; color: var(--faint); }
.chat-title {
  font-size: 16px; font-weight: 500; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chat-last {
  margin-top: 3px; font-size: 14.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.chat-pane { display: flex; flex-direction: column; min-height: 420px; height: calc(100dvh - 210px); }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
}
.chat-head .grow { flex: 1; min-width: 0; }
.chat-head b { display: block; font-weight: 500; }
.chat-head .muted { display: block; font-size: 14px; color: var(--muted); word-break: break-all; }
.chat-note {
  padding: 9px 16px; font-size: 14.5px; color: var(--muted);
  background: var(--soft); border-bottom: 1px solid var(--line-soft);
}
.chat-thread { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
/* Слева гость, справа мы — агент и оператор. Оператор смотрит на переписку
   со своей стороны, поэтому «наши» реплики там же, где в любом мессенджере. */
.chat-msg { margin-bottom: 12px; max-width: 78%; }
.chat-msg.guest { margin-right: auto; }
.chat-msg.bot, .chat-msg.op { margin-left: auto; }
.chat-who { display: block; font-size: 12.5px; color: var(--faint); margin-bottom: 3px; }
.chat-msg.bot .chat-who, .chat-msg.op .chat-who { text-align: right; }
.chat-bubble {
  padding: 9px 13px; border-radius: 14px; font-size: 16px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  background: var(--soft); color: var(--ink);
}
.chat-msg.guest .chat-bubble { border-bottom-left-radius: 5px; }
/* агент — заливкой, оператор — обводкой: видно, где отвечал человек */
.chat-msg.bot .chat-bubble { background: var(--ink); color: var(--on-ink); border-bottom-right-radius: 5px; }
.chat-msg.op .chat-bubble {
  border-bottom-right-radius: 5px;
  background: var(--paper); border: 1px solid var(--ink);
}
.chat-mark {
  display: inline-block; font-style: normal; font-size: 13px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 5px; padding: 1px 6px;
}
/* Вложения в переписке */
.chat-atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chat-att-img img { max-width: 200px; max-height: 200px; border-radius: 8px; display: block; }
.chat-att {
  display: inline-flex; align-items: center; gap: 6px; max-width: 220px;
  padding: 6px 10px; border-radius: 8px; text-decoration: none;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink); font-size: 15px;
}
.chat-msg.bot .chat-att { background: rgba(255, 255, 255, .12); border-color: transparent; color: var(--on-ink); }
.chat-att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-att svg { width: 14px; height: 14px; flex: 0 0 14px; }

/* Выбранные, но ещё не отправленные файлы */
.chat-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; }
.chat-file {
  display: inline-flex; align-items: center; gap: 6px; max-width: 200px;
  padding: 4px 8px; border-radius: 20px; background: var(--soft); font-size: 14.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-file button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); font-size: 15px; }
.chat-file button:hover { color: #d33; }

/* Скрепка */
.chat-clip {
  flex: 0 0 38px; width: 38px; height: 38px; display: inline-flex; align-items: center;
  justify-content: center; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--paper); color: var(--muted); cursor: pointer;
}
.chat-clip:hover { color: var(--ink); border-color: var(--ink); }
.chat-clip svg { width: 16px; height: 16px; }

.chat-composer {
  display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line-soft);
}
.chat-composer input {
  flex: 1; min-width: 0;
  /* ровно 16px: при меньшем размере Safari на iOS зумит страницу по фокусу */
  font: inherit; font-size: 17.5px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 12px; outline: none;
}
.chat-composer input:focus { border-color: var(--ink); }

/* кнопка «назад к списку» нужна только на узком экране */
.chat-back { display: none; align-items: center; gap: 6px; background: none; border: 0;
  padding: 0 4px 0 0; margin-right: 2px; color: var(--muted); cursor: pointer; font: inherit; }
.chat-back:hover { color: var(--ink); }

@media (max-width: 900px) {
  .chat-split { grid-template-columns: 1fr; }
  .chat-msg { max-width: 88%; }

  /* На телефоне показываем что-то одно: либо список обращений, либо диалог.
     Открытый диалог — окно фиксированной высоты с прокруткой внутри и полем
     ввода, прибитым к низу, как в мессенджере. Раньше панель росла по
     содержимому: лента тянулась на всю страницу, а поле ответа уезжало
     за экран, и ответить было нечем. */
  .chat-split.has-open .chat-list { display: none; }
  .chat-split.has-open .chat-pane { border: 0; border-radius: 0; }
  .chat-list { max-height: none; }

  /* Высоту панели считаем в JS по реальному положению: сверху липкая шапка,
     снизу фиксированный таб-бар, их размеры зависят от безопасных зон. */
  .chat-pane { min-height: 0; }
  .chat-thread { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .chat-composer { position: sticky; bottom: 0; background: var(--paper); }
  .chat-back { display: inline-flex; }
}

/* ---------- Просрочка: две ступени, поверх всех базовых правил ----------
   До порога «тишины» — жёлтый, дальше — красный. Блок в конце файла
   намеренно: он должен побеждать .sev3, .t-due.overdue и .cal-task.over. */
.kcard.attention.soon { border-left-color: var(--soon); }
.kcard.attention.late { border-left-color: var(--late); }
.kcard .kstep.warn.soon { color: var(--soon); }
.kcard .kstep.warn.late { color: var(--late); }
.task-row .t-due.overdue.soon, .mini-row .when.overdue.soon, .nextstep .ns-when.overdue.soon { color: var(--soon); }
.task-row .t-due.overdue.late, .mini-row .when.overdue.late, .nextstep .ns-when.overdue.late { color: var(--late); }
.nextstep.warn.soon { border-color: var(--soon); }
.nextstep.warn.late { border-color: var(--late); }
.sev.soon { background: var(--soon); }
.sev.late { background: var(--late); }
.cal-task.over.soon { box-shadow: inset 2px 0 0 var(--soon); color: var(--soon); background: var(--soon-bg); }
.cal-task.over.late { box-shadow: inset 2px 0 0 var(--late); color: var(--late); background: var(--late-bg); }

/* ============================== Продажи ============================== */
.sales-top { grid-template-columns: 1.2fr 1fr 1fr; margin-bottom: 14px; align-items: stretch; }
.sales-bottom { grid-template-columns: 1.2fr 1fr; margin-top: 14px; align-items: start; }
.goal { margin-bottom: 12px; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14.5px; font-weight: 600; margin-bottom: 5px; gap: 8px; }
.goal-top b { font-size: 17px; }
.sbar { height: 7px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.sbar .sfill { height: 100%; background: var(--ink); border-radius: 999px; transition: width .3s; }
.sbar.full .sfill { background: var(--good); }
.level { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.streak { font-size: 13px; font-weight: 700; color: var(--muted); padding: 3px 9px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.streak.on { color: var(--soon); background: var(--soon-bg); }
.qstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.qstats div { background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.qstats b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.qstats span { font-size: 13px; color: var(--muted); font-weight: 500; }
.sales-go { width: 100%; justify-content: center; padding: 10px; }
.achs { display: flex; flex-wrap: wrap; gap: 6px; }
.ach { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: var(--muted); border: 1px dashed var(--line); cursor: default; }
.ach i { font-style: normal; font-weight: 500; color: var(--faint); font-variant-numeric: tabular-nums; }
.ach svg { width: 12px; height: 12px; stroke-width: 3; }
.ach.ok { color: var(--good); background: var(--good-bg); border: 1px solid transparent; }
.sales-table td { vertical-align: middle; }
/* двенадцать колонок: поля поуже, иначе правые уезжают за край */
.sales-table th, .sales-table td { padding-left: 8px; padding-right: 8px; }
.sales-table th { letter-spacing: .02em; }
.sales-table tbody tr { cursor: default; }
.sales-table tr.me td { background: var(--bg); }
.sales-table .name-cell { white-space: nowrap; }
.cellbar { display: grid; grid-template-columns: auto auto 1fr; gap: 5px; align-items: baseline; min-width: 84px; }
.cellbar .sbar { grid-column: 1 / -1; height: 4px; margin-top: 2px; }
.cellbar .muted { font-size: 14px; }
.daychart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 16px; }
.daycol { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.daycol.off .daylab { color: var(--faint); }
.daynum { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 3px; min-height: 13px; }
.daystack { width: 100%; max-width: 30px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; min-height: 2px; background: var(--soft); }
.daylab { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 5px; }
.daystack i.p0, .legend i.p0 { background: var(--ink); }
.daystack i.p1, .legend i.p1 { background: var(--muted); }
.daystack i.p2, .legend i.p2 { background: var(--faint); }
.legend { display: flex; gap: 14px; margin-top: 12px; font-size: 14px; font-weight: 500; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.funnel-row .fill.tone-good { background: var(--good); }
.funnel-row .fill.tone-soon { background: var(--soon); }
.funnel-row .fill.tone-late { background: var(--late); }
.mt-h { margin-top: 22px; }
.medal { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; font-weight: 700;
  background: var(--soft); color: var(--muted); margin-right: 4px; }
.medal.m0 { background: var(--ink); color: var(--on-ink); }
table.norms { width: auto; }
table.norms th { text-align: left; padding: 0 8px 6px; }
table.norms td { padding: 4px 8px; border: 0; font-weight: 600; }
table.norms td:first-child { padding-left: 0; }
table.norms .input { width: 84px; }
table.norms tbody tr { cursor: default; }
table.norms tbody tr:hover { background: transparent; }

/* прозвон: очередь слева, карточка звонка справа */
.calls { display: grid; grid-template-columns: 384px minmax(0, 1fr); gap: 14px; align-items: start; }
.callq { overflow: hidden; position: sticky; top: 12px; }
.callq-tabs { display: flex; margin: 10px; overflow-x: auto; }
.callq-tabs button { flex: 1; padding-left: 4px; padding-right: 4px; white-space: nowrap; }
.callq-tabs i { font-style: normal; color: var(--faint); font-weight: 600; }
.callq-list { max-height: calc(100vh - 230px); overflow-y: auto; border-top: 1px solid var(--line-soft); }
.qrow { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.qrow:hover { background: var(--bg); }
.qrow.on { background: var(--soft); box-shadow: inset 3px 0 0 var(--ink); }
.qmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.qmain b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qmain span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qrow .when { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.qrow .when.overdue.soon { color: var(--soon); }
.qrow .when.overdue.late { color: var(--late); }
.call-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.call-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.call-head .subtitle { color: var(--muted); font-size: 15px; margin-top: 2px; }
.call-head .actions { display: flex; align-items: center; gap: 6px; flex: none; }
.call-phone { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0 12px; }
.call-phone .phone { display: inline-flex; align-items: center; gap: 9px; font-size: 26.5px; font-weight: 700; letter-spacing: -.01em;
  padding: 8px 16px; border-radius: 12px; background: var(--ink); color: var(--on-ink); }
.call-phone .phone svg { width: 18px; height: 18px; stroke-width: 2; }
.call-phone .phone:hover { background: var(--ink-hover); }
.call-phone .who { font-size: 15px; color: var(--ink-soft); }
.call-phone .alt { font-size: 14px; font-weight: 500; color: var(--muted); padding: 3px 9px; border-radius: 999px; background: var(--soft); }
.call-phone .alt:hover { color: var(--ink); }
.call-tries { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.call-tries.warn { color: var(--soon); }
.callcard .knote { margin: 0 0 10px; padding: 8px 10px; font-size: 14.5px; font-weight: 500; line-height: 1.4; background: var(--soft); border: 1px solid var(--line-soft); border-radius: 8px; }
.callcard .knote .knote-when { display: block; margin-top: 3px; font-size: 13px; font-weight: 600; color: var(--muted); }
.callcard .knote .knote-when.overdue.soon { color: var(--soon); }
.callcard .knote .knote-when.overdue.late { color: var(--late); }
.call-note { margin-bottom: 10px; }
.call-note .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 3px; }
.call-note .txt { font-size: 15px; line-height: 1.5; max-height: 132px; overflow-y: auto; overflow-wrap: anywhere; }
.call-note .hrow { font-size: 14.5px; line-height: 1.45; padding: 3px 0; overflow-wrap: anywhere; }
.call-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.call-form textarea { width: 100%; min-height: 62px; padding: 9px 11px; font: inherit; font-size: 15.5px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 9px; resize: vertical; }
.call-form textarea:focus { outline: none; border-color: var(--ink); }
.call-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 10px 0; }
.call-opts label { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; color: var(--muted); }
.call-opts .spacer { flex: 1; }
.outcomes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.outcome { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 11px 6px; border-radius: 10px; font-size: 15px; font-weight: 700;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); transition: background .12s, border-color .12s; }
.outcome kbd { font: inherit; font-size: 11.5px; font-weight: 700; color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; line-height: 16px; }
.outcome:hover { background: var(--soft); border-color: var(--faint); }
.outcome:disabled { opacity: .5; cursor: wait; }
.outcome.tone-good { color: var(--good); background: var(--good-bg); border-color: transparent; }
.outcome.tone-soon { color: var(--soon); background: var(--soon-bg); border-color: transparent; }
.outcome.tone-late { color: var(--late); background: var(--late-bg); border-color: transparent; }
.outcome.tone-good:hover, .outcome.tone-soon:hover, .outcome.tone-late:hover { filter: brightness(.96); }
@media (max-width: 1100px) {
  .sales-top, .sales-bottom { grid-template-columns: 1fr; }
  .calls { grid-template-columns: 1fr; }
  .callq { position: static; order: 2; }
  .callq-list { max-height: 320px; }
  .outcomes { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; }
}
@media (max-width: 800px) {
  .call-phone .phone { font-size: 23px; width: 100%; justify-content: center; }
  .call-head { flex-direction: column; }
  .outcome kbd { display: none; }
}

/* ============================== Лиды и путь лида ============================== */
/* три плитки пути: лиды → продажи → сделки */
.zonestrip { display: flex; align-items: stretch; gap: 8px; margin-bottom: 14px; }
.zonestrip .zone { flex: 1; min-width: 0; padding: 12px 16px; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline; transition: border-color .12s; }
.zonestrip .zone:hover { border-color: var(--faint); }
.zonestrip .zl { grid-column: 1 / -1; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.zonestrip .zone b { font-size: 26.5px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
.zonestrip .zs { font-size: 14px; color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zonestrip .zarrow { display: flex; align-items: center; color: var(--faint); }
.zonestrip .zarrow svg { width: 16px; height: 16px; }

/* полоса на карточке сделки: в каком она разделе и что с ней делать */
.zonebar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 15px; line-height: 1.45;
  background: var(--soft); border: 1px solid var(--line-soft); border-radius: 10px; }
.zonebar > span { flex: 1; min-width: 0; }
.zonebar .btn { flex: none; }

/* три отметки проверки точками */
.lmarks { display: inline-flex; gap: 3px; vertical-align: middle; flex: none; }
.lmarks i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.lmarks i.ok { background: var(--good); }
.lmarks i.bad { background: var(--late); }

.callq-list.tall { max-height: calc(100vh - 170px); border-top: 0; }
.callcard .lbl { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 6px; }
.callcard .lbl .btn, .callcard .lbl .icon-btn { text-transform: none; letter-spacing: 0; }
.callcard .lbl .icon-btn { width: 22px; height: 22px; }
.callcard .lbl .icon-btn svg { width: 13px; height: 13px; }
.lead-block { margin: 14px 0; }
.lfacts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 16px; }
.lfact { display: flex; flex-direction: column; min-width: 0; }
.lfact span { font-size: 13px; color: var(--muted); font-weight: 500; }
.lfact b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lfact b.empty-v { color: var(--faint); font-weight: 400; }
.lfact a { text-decoration: underline; text-underline-offset: 2px; }
.lead-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.lead-links a { padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--ink-soft); font-weight: 500; }
.lead-links a:hover { color: var(--ink); }
.lperson { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; }
.lperson:last-child { border-bottom: 0; }
.lperson .grow { flex: 1; min-width: 120px; }
.lperson .star { flex: none; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: var(--faint); border-radius: 6px; }
.lperson .star svg { width: 15px; height: 15px; }
.lperson .star:hover { color: var(--ink); background: var(--soft); }
.lperson.primary .star { color: var(--ink); }
.lperson.primary .star svg { fill: currentColor; }
.lphone { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lphone:hover, .lalt:hover { text-decoration: underline; }
.lalt { font-size: 14.5px; color: var(--ink-soft); white-space: nowrap; }
.lmsg { font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); }
.lmsg:hover { color: var(--ink); border-color: var(--faint); }
.p-empty.left { text-align: left; padding: 4px 0; }

.lchecks { display: grid; gap: 6px; margin-bottom: 10px; }
.lcheck { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.lcheck.ok { border-color: transparent; background: var(--good-bg); }
.lcheck.bad { border-color: transparent; background: var(--late-bg); }
.lc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lc-text b { font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.lc-text span { font-size: 14px; color: var(--muted); line-height: 1.35; }
.lc-text kbd { font: inherit; font-size: 11.5px; font-weight: 700; color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; line-height: 16px; }
.lcheck.ok .lc-text b { color: var(--good); }
.lcheck.bad .lc-text b { color: var(--late); }
.lc-btns { display: flex; gap: 4px; flex: none; }
.lc-btns button { min-width: 52px; padding: 7px 10px; border-radius: 8px; font-size: 15px; font-weight: 700; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.lc-btns button:hover { border-color: var(--faint); }
.lc-btns button.on[data-val="ok"] { background: var(--good); border-color: var(--good); color: #fff; }
.lc-btns button.on[data-val="bad"] { background: var(--late); border-color: var(--late); color: #fff; }
.verdicts { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.verdicts .outcome { padding: 13px 6px; font-size: 16px; }
.call-phone .nophone { font-size: 17px; font-weight: 700; color: var(--muted); }
.stage-row .s-next.s-zone { font-weight: 700; }
.stage-row .s-next.z-deal { color: var(--ink); }

@media (max-width: 800px) {
  .zonestrip { gap: 4px; }
  .zonestrip .zone { padding: 9px 10px; grid-template-columns: 1fr; }
  .zonestrip .zs { display: none; }
  .zonestrip .zarrow { display: none; }
  .zonebar { flex-direction: column; align-items: stretch; }
  .lc-text span { display: none; }
  .lc-text kbd { display: none; }
  .callq-list.tall { max-height: 320px; }
}

/* в сделках осталось несколько колонок — пусть делят ширину, а не уезжают за край */
@media (min-width: 801px) {
  .kcol { flex: 1 1 220px; width: auto; min-width: 220px; max-width: 420px; }
}

/* На телефоне задача в две строки: что сделать и срок, ниже — к чему относится.
   В одну строку название сжималось в столбик по слову. */
@media (max-width: 800px) {
  .task-row { flex-wrap: wrap; row-gap: 4px; }
  .task-row .t-title { flex: 1 1 0; min-width: 0; }
  .task-row .t-due { order: 1; }
  .task-row .t-links { order: 2; flex: 1 1 100%; padding-left: 46px; }
  .task-row .chip.proj { order: 3; margin-left: 46px; }
  .task-row .avatar { order: 3; }
  table.norms .input { width: 58px; padding-left: 8px; padding-right: 4px; }
  table.norms th, table.norms td { padding-left: 3px; padding-right: 3px; }
  table.norms th { letter-spacing: 0; font-size: 11.5px; }
}

/* пометка сети перед ником: IG, VK */
.soc { font-style: normal; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; color: var(--muted); }

/* ============================== Скрипты ============================== */
.seg.wrap { flex-wrap: wrap; }
.seg button i { font-style: normal; color: var(--faint); font-weight: 600; }
.script-hint { margin: -4px 0 14px; }
.script-hint code, .modal code { font: inherit; font-weight: 600; color: var(--ink-soft); background: var(--soft); border-radius: 5px; padding: 1px 5px; }
.scripts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; margin-bottom: 6px; }
.script { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.script.hl { border-color: var(--ink); }
.script-head { display: flex; align-items: center; gap: 8px; }
.script-head b { font-size: 16px; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.script-head .spacer, .script-foot .spacer { flex: 1; }
.script-head .icon-btn { flex: none; }
/* текст скрипта читают и произносят: держим абзацы и переносы как набрано */
.script-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.55; color: var(--ink-soft); }
.script-body.clamp { max-height: 11.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 78%, transparent); mask-image: linear-gradient(#000 78%, transparent); }
.script-foot { display: flex; align-items: center; gap: 8px; }
.modal.wide { width: 720px; }
.modal.wide textarea { min-height: 300px; line-height: 1.5; }

/* скрипты в карточке звонка */
.cscripts .lbl { flex-wrap: wrap; }
.seg.sm { padding: 2px; flex-wrap: wrap; }
.seg.sm button { padding: 3px 9px; font-size: 12.5px; text-transform: none; letter-spacing: 0; }
.cs-titles { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-title { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 14px; font-weight: 500; color: var(--ink-soft); }
.cs-title:hover { border-color: var(--faint); color: var(--ink); }
.cs-title.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.cs-text { margin-top: 10px; padding: 12px 14px; background: var(--soft); border: 1px solid var(--line-soft); border-radius: 10px; }
.cs-text .script-body { color: var(--ink); max-height: 300px; overflow-y: auto; }
.cs-text .script-foot { margin-top: 8px; }

@media (max-width: 1100px) {
  .scripts-grid { grid-template-columns: 1fr; }
}

/* план контакта — инструкция: читается целиком */
.call-note .txt.plan { max-height: none; font-weight: 500; }
.callcard .knote .knote-when.inline { display: inline; margin: 0; }

/* история действий: кто что сделал, по дням */
.hist-bar { flex-wrap: wrap; row-gap: 8px; }
.sales-table tr.hist-link { cursor: pointer; }
.sales-table tr.hist-link:hover td { background: var(--bg); }
.hist { padding: 4px 0; }
.hist-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line-soft); color: inherit; font-size: 14.5px; }
.hist-row:last-child { border-bottom: 0; }
a.hist-row[href]:hover { background: var(--bg); }
.hist-row .when { flex: none; width: 44px; font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist-row .hwho { flex: none; font-weight: 600; width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-row .hkind { flex: none; }
.hist-row .hco { flex: 0 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.hist-row .htext { flex: 1; min-width: 0; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.hkind.tone-good { color: var(--good); background: var(--good-bg); }
.chip.hkind.tone-soon { color: var(--soon); background: var(--soon-bg); }
.chip.hkind.tone-late { color: var(--late); background: var(--late-bg); }
@media (max-width: 800px) {
  .hist-row { flex-wrap: wrap; row-gap: 4px; }
  .hist-row .hco { max-width: none; flex: 1 1 100%; padding-left: 54px; }
  .hist-row .htext { flex: 1 1 100%; white-space: normal; padding-left: 54px; }
}
