/* Радар — дизайн-система «Next». */

@font-face {
  font-family: "Inter";
  src: url("fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Нейтральная шкала: 1–2 фон, 3–5 заливки, 6–8 рамки, 9–10 иконки, 11–12 текст */
  --gray-1: #fcfcfd;
  --gray-2: #f9f9fb;
  --gray-3: #f0f0f3;
  --gray-4: #e8e8ec;
  --gray-5: #e0e1e6;
  --gray-6: #d9d9e0;
  --gray-7: #cdced6;
  --gray-8: #b9bbc6;
  --gray-9: #8b8d98;
  --gray-10: #80838d;
  --gray-11: #60646c;
  --gray-12: #1c2024;

  /* Акцент: индиго */
  --accent-2: #f8faff;
  --accent-3: #edf2fe;
  --accent-4: #e1e9ff;
  --accent-5: #d2deff;
  --accent-7: #abbdf9;
  --accent-8: #8da4ef;
  --accent-9: #3e63dd;
  --accent-10: #3358d4;
  --accent-11: #3a5bc7;
  --accent-12: #1f2d5c;

  /* Смысловые цвета */
  --green-3: #e6f6eb; --green-9: #30a46c; --green-11: #218358;
  --amber-3: #fff7c2; --amber-9: #ffc53d; --amber-11: #ab6400;
  --red-3: #feebec;   --red-9: #e5484d;   --red-11: #ce2c31;
  --violet-3: #f4f0fe; --violet-9: #6e56cf; --violet-11: #6550b9;
  --cyan-3: #e7f9fb;  --cyan-9: #00a2c7;  --cyan-11: #107d98;
  --orange-3: #ffefd6; --orange-9: #f76b15; --orange-11: #cc4e00;

  --bg: #fff;
  --surface: #fff;
  --sidebar: var(--gray-2);
  --text: var(--gray-12);
  --text-2: var(--gray-11);
  --text-3: var(--gray-10);
  --line: var(--gray-5);
  --line-soft: var(--gray-4);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-16: 16px; --fs-20: 20px; --fs-24: 24px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-12: 48px;
  --r-1: 6px; --r-2: 8px; --r-3: 12px; --r-full: 999px;
  --h-control: 32px;
  --h-control-lg: 40px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-3: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .06);
  --focus: 0 0 0 2px #fff, 0 0 0 4px var(--accent-8);
  --ease: cubic-bezier(.2, 0, 0, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 var(--fs-14)/1.45 var(--font);
  font-feature-settings: "cv05" 1, "ss03" 1;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.num, td.num, .money { font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
a.link { color: var(--accent-11); }
a.link:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-1); }
.icon { width: 16px; height: 16px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Каркас: «перевёрнутая L» — сайдбар + шапка страницы ── */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-3) var(--s-2);
  background: var(--sidebar);
  border-right: 1px solid var(--line-soft);
}
.ws { display: flex; align-items: center; gap: var(--s-2); height: 36px; padding: 0 var(--s-2); border-radius: var(--r-2); font-weight: 600; }
.logo {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent-9), #6e56cf); color: #fff; font-size: 12px; font-weight: 700;
}
.side-search {
  display: flex; align-items: center; gap: var(--s-2); height: 32px; margin: var(--s-1) 0 var(--s-2);
  padding: 0 var(--s-2); border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface);
  color: var(--text-3); font-size: var(--fs-13);
}
.side-search kbd { margin-left: auto; font: 500 11px/1 var(--font); color: var(--text-3); border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: var(--s-4) var(--s-2) var(--s-1); font-size: var(--fs-12); font-weight: 500; color: var(--text-3); }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 var(--s-2);
  border-radius: var(--r-1); color: var(--text-2); font-weight: 500;
}
.nav a .icon { color: var(--gray-10); }
.nav a:hover { background: var(--gray-4); color: var(--text); }
.nav a.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
.nav a.is-on .icon { color: var(--accent-9); }
.nav .count { margin-left: auto; font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav .count.hot { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full); background: var(--accent-9); color: #fff; display: grid; place-items: center; font-weight: 600; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2); border-radius: var(--r-2); }
.side-foot:hover { background: var(--gray-4); }
.side-foot .who { display: flex; flex-direction: column; line-height: 1.2; }
.side-foot .who small { color: var(--text-3); font-size: var(--fs-12); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 100dvh; }
.page-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--s-3);
  height: 56px; padding: 0 var(--s-6);
  background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.page-head h1 { margin: 0; font-size: var(--fs-16); font-weight: 600; letter-spacing: -.01em; }
.page-head .count { color: var(--text-3); font-variant-numeric: tabular-nums; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); }
.crumbs a:hover { color: var(--text); }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }

.filterbar {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  min-height: 48px; padding: var(--s-2) var(--s-6);
  border-bottom: 1px solid var(--line-soft);
}
.filterbar .search { margin-left: auto; }
.content { padding: var(--s-5) var(--s-6) var(--s-8); }
.content-narrow { max-width: 880px; }

/* ── Кнопки ── */
.btn, .btn-ghost, .btn-secondary, .btn-icon, .btn-danger, .btn-danger-ghost, button:not([class]) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--h-control); padding: 0 var(--s-3);
  border: 1px solid transparent; border-radius: var(--r-2);
  font: 500 var(--fs-13)/1 var(--font); white-space: nowrap; cursor: pointer;
  transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.btn-primary { background: var(--accent-9); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.12), var(--shadow-1); }
.btn-primary:hover { background: var(--accent-10); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--shadow-1); }
.btn-secondary:hover { background: var(--gray-2); border-color: var(--gray-7); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--gray-3); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--red-11); }
.btn-danger-ghost:hover { background: var(--red-3); }
.btn-icon { width: var(--h-control); padding: 0; }
.btn-lg { height: var(--h-control-lg); font-size: var(--fs-14); padding: 0 var(--s-4); }
.btn-block { width: 100%; }
.btn kbd { font: 500 11px/1 var(--font); opacity: .7; margin-left: 2px; }

/* ── Поля ввода ── */
.input, .select {
  display: flex; align-items: center; gap: var(--s-2);
  height: var(--h-control); padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface);
  font: 400 var(--fs-13)/1 var(--font); color: var(--text); box-shadow: var(--shadow-1);
}
.input input { border: 0; outline: 0; background: transparent; font: inherit; color: inherit; width: 100%; padding: 0; }
.input::placeholder, .input input::placeholder { color: var(--text-3); }
.input:focus-within { border-color: var(--accent-8); box-shadow: 0 0 0 3px var(--accent-4); }
.input .icon { color: var(--gray-9); }
.input-lg { height: var(--h-control-lg); font-size: var(--fs-14); }
.select { justify-content: space-between; cursor: pointer; }
.select .icon { color: var(--gray-9); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: var(--fs-13); font-weight: 500; color: var(--text); }
.field > small { font-size: var(--fs-12); color: var(--text-3); }
.search { width: 260px; }
.search kbd { margin-left: auto; font: 500 11px/1 var(--font); color: var(--text-3); }
textarea.input { height: auto; min-height: 72px; padding: 8px 10px; line-height: 1.5; resize: vertical; width: 100%; }

/* ── Фильтр-чипы и сегменты ── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-full); background: var(--surface);
  font-size: var(--fs-13); color: var(--text-2); white-space: nowrap; cursor: pointer;
}
.chip b { color: var(--text); font-weight: 500; }
.chip:hover { background: var(--gray-2); }
.chip.is-set { border-color: var(--accent-7); background: var(--accent-3); color: var(--accent-11); }
.chip.is-set b { color: var(--accent-12); }
.chip-add { border-style: dashed; color: var(--text-3); }
.seg { display: inline-flex; padding: 2px; border-radius: var(--r-2); background: var(--gray-3); }
.seg a { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 6px; font-size: var(--fs-13); font-weight: 500; color: var(--text-2); }
.seg a.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
.tabs { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--line-soft); }
.tabs a { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; font-weight: 500; color: var(--text-2); }
.tabs a:hover { color: var(--text); }
.tabs a.is-on { color: var(--text); }
.tabs a.is-on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); }
.tabs .count { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ── Бейджи, статусы, аватары ── */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--r-full); background: var(--gray-3); color: var(--text-2);
  font-size: var(--fs-12); font-weight: 500; white-space: nowrap;
}
.pill .dot, .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--gray-9)); flex: 0 0 auto; }
.pill-green { background: var(--green-3); color: var(--green-11); }
.pill-amber { background: var(--amber-3); color: var(--amber-11); }
.pill-red { background: var(--red-3); color: var(--red-11); }
.pill-accent { background: var(--accent-3); color: var(--accent-11); }
.src { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-2); }
.src::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--gray-8)); }
.src-avito { --c: #00aaff; }
.src-kwork { --c: #1db954; }
.src-fl { --c: #f76b15; }
.src-upwork { --c: #14a800; }
.src-onclancer { --c: #6e56cf; }
.src-okdesk { --c: #3e63dd; }
.src-none { --c: var(--gray-7); }
.av {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--av, var(--gray-4)); color: var(--av-fg, var(--gray-12));
  font-size: 10px; font-weight: 600; letter-spacing: -.02em;
}
.av-lg { width: 40px; height: 40px; font-size: 15px; border-radius: 10px; }
.av-md { width: 28px; height: 28px; font-size: 12px; }
.av-1 { --av: #e1e9ff; --av-fg: #3a5bc7; }
.av-2 { --av: #e6f6eb; --av-fg: #218358; }
.av-3 { --av: #ffefd6; --av-fg: #cc4e00; }
.av-4 { --av: #f4f0fe; --av-fg: #6550b9; }
.av-5 { --av: #e7f9fb; --av-fg: #107d98; }
.kbd { font: 500 11px/1 var(--font); border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; color: var(--text-3); }

/* ── Канбан ── */
.board { display: flex; gap: var(--s-3); padding: var(--s-4) var(--s-6) var(--s-6); overflow-x: auto; align-items: flex-start; flex: 1; }
.col { flex: 0 0 296px; display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-2); border-radius: var(--r-3); background: var(--gray-2); }
.col-head { display: flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-1) 0 6px; }
.col-head h2 { margin: 0; font-size: var(--fs-13); font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-head .n { color: var(--text-3); font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
.col-head .sum { margin-left: auto; white-space: nowrap; color: var(--text-2); font-size: var(--fs-12); font-weight: 500; font-variant-numeric: tabular-nums; }
.col-head .btn-icon { width: 24px; height: 24px; color: var(--gray-9); }
.card {
  display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3);
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; box-shadow: var(--shadow-1);
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.card:hover { border-color: var(--gray-7); box-shadow: var(--shadow-2); }
.card.is-on { border-color: var(--accent-8); box-shadow: 0 0 0 3px var(--accent-4); }
.card-title { font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-client { display: flex; align-items: center; gap: 6px; font-size: var(--fs-13); color: var(--text-2); min-width: 0; }
.card-client span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-12); color: var(--text-3); }
.card-foot .money { color: var(--text); font-size: var(--fs-13); font-weight: 600; }
.card-foot .when { margin-left: auto; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.col-add { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s-2); border-radius: var(--r-2); color: var(--text-3); font-size: var(--fs-13); }
.col-add:hover { background: var(--gray-4); color: var(--text); }
.stage-tabs { display: none; }

/* ── Таблица ── */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  position: sticky; top: 56px; z-index: 1;
  height: 36px; padding: 0 var(--s-3); text-align: left;
  font-size: var(--fs-12); font-weight: 500; color: var(--text-3);
  background: var(--bg); border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
.table th:first-child, .table td:first-child { padding-left: var(--s-6); }
.table th:last-child, .table td:last-child { padding-right: var(--s-6); }
.table th.num, .table td.num { text-align: right; }
.table th .icon { vertical-align: -3px; }
.table td { height: 44px; padding: 0 var(--s-3); border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--gray-2); }
.table tbody tr.is-on td { background: var(--accent-2); }
.table .t-title { font-weight: 500; color: var(--text); }
.table .t-sub { color: var(--text-3); font-size: var(--fs-12); }
.table .cell-flex { display: flex; align-items: center; gap: var(--s-2); }
.table .check { width: 16px; height: 16px; border: 1px solid var(--gray-7); border-radius: 4px; background: var(--surface); }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: var(--s-3) var(--s-6); color: var(--text-3); font-size: var(--fs-13); }

/* ── Боковая панель (drawer) ── */
.scrim { position: fixed; inset: 0; background: rgba(16, 24, 40, .24); z-index: 20; }
.drawer {
  position: fixed; top: 8px; right: 8px; bottom: 8px; z-index: 21; width: 560px;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 14px; box-shadow: var(--shadow-3);
  overflow: hidden;
}
.drawer-bar { display: flex; align-items: center; gap: var(--s-2); height: 52px; padding: 0 var(--s-3) 0 var(--s-5); border-bottom: 1px solid var(--line-soft); }
.drawer-bar .crumbs { font-size: var(--fs-13); }
.drawer-bar .head-actions .btn-icon { color: var(--gray-10); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s-5); }
.drawer-foot { display: flex; gap: var(--s-2); justify-content: flex-end; padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line-soft); background: var(--gray-1); }

/* ── Карточка сущности ── */
.entity-head { display: flex; align-items: flex-start; gap: var(--s-3); }
.entity-head h2, .entity-head h1 { margin: 0; font-size: var(--fs-20); font-weight: 600; letter-spacing: -.015em; line-height: 1.3; }
.entity-head .sub { display: flex; align-items: center; gap: var(--s-2); margin-top: 6px; flex-wrap: wrap; font-size: var(--fs-13); color: var(--text-2); }
.amount { font-size: var(--fs-24); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stepper { display: flex; gap: 3px; margin: var(--s-4) 0 var(--s-2); }
.stepper span { flex: 1; height: 6px; border-radius: 3px; background: var(--gray-4); }
.stepper span.done { background: var(--c, var(--accent-9)); }
.stepper-labels { display: flex; justify-content: space-between; font-size: var(--fs-12); color: var(--text-3); }
.stepper-labels b { color: var(--text); font-weight: 500; }
.props { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: center; row-gap: 2px; margin: var(--s-4) 0; }
.props dt { font-size: var(--fs-13); color: var(--text-3); display: flex; align-items: center; gap: 8px; height: 34px; }
.props dt .icon { color: var(--gray-9); }
.props dd {
  margin: 0; min-height: 34px; display: flex; align-items: center; gap: 6px;
  padding: 0 8px; margin-left: -8px; border-radius: var(--r-1); min-width: 0;
}
.props dd:hover { background: var(--gray-3); }
.props dd .empty { color: var(--text-3); }
.section { margin-top: var(--s-6); }
.section-head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.section-head h3 { margin: 0; font-size: var(--fs-13); font-weight: 600; }
.section-head .count { color: var(--text-3); font-size: var(--fs-13); }
.section-head .btn { margin-left: auto; }
.divider { height: 1px; background: var(--line-soft); margin: var(--s-5) 0; }

.feed { position: relative; display: flex; flex-direction: column; gap: var(--s-4); margin: 0; padding: 0; list-style: none; }
.feed::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 1px; background: var(--line-soft); }
.feed li { position: relative; display: flex; gap: var(--s-3); font-size: var(--fs-13); }
.feed .ic { flex: 0 0 auto; position: relative; z-index: 1; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); color: var(--gray-10); }
.feed .ic .icon { width: 11px; height: 11px; }
.feed b { font-weight: 500; }
.feed time { color: var(--text-3); margin-left: 6px; }
.note { padding: var(--s-3); border: 1px solid var(--line-soft); border-radius: var(--r-2); background: var(--gray-1); line-height: 1.5; }
.composer-mini { display: flex; gap: var(--s-2); align-items: center; padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: var(--r-2); color: var(--text-3); box-shadow: var(--shadow-1); }
.composer-mini .btn { margin-left: auto; }

/* ── Страница клиента ── */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: calc(100dvh - 56px); }
.split-main { padding: var(--s-6); min-width: 0; }
.split-side { border-left: 1px solid var(--line-soft); padding: var(--s-5); background: var(--gray-1); }
.split-side h3 { margin: 0 0 var(--s-2); font-size: var(--fs-12); font-weight: 500; color: var(--text-3); }
.rows { border: 1px solid var(--line-soft); border-radius: var(--r-3); overflow: hidden; }
.row { display: flex; align-items: center; gap: var(--s-3); min-height: 52px; padding: var(--s-2) var(--s-4); border-top: 1px solid var(--line-soft); }
.row:first-child { border-top: 0; }
.row:hover { background: var(--gray-2); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; }
.row .meta { font-size: var(--fs-12); color: var(--text-3); }
.row .trail { display: flex; align-items: center; gap: var(--s-3); color: var(--text-2); font-size: var(--fs-13); }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; letter-spacing: .1em; color: var(--text-2); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); margin: var(--s-5) 0; }
.kpi { padding: var(--s-3) var(--s-4); border: 1px solid var(--line-soft); border-radius: var(--r-3); }
.kpi small { display: block; font-size: var(--fs-12); color: var(--text-3); }
.kpi strong { display: block; margin-top: 2px; font-size: var(--fs-20); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ── Сообщения ── */
.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; height: 100dvh; }
.inbox-list { display: flex; flex-direction: column; border-right: 1px solid var(--line-soft); min-height: 0; }
.inbox-top { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border-bottom: 1px solid var(--line-soft); }
.inbox-top h1 { margin: 0; font-size: var(--fs-16); font-weight: 600; display: flex; align-items: center; gap: var(--s-2); }
.inbox-items { overflow-y: auto; padding: var(--s-1) var(--s-2); }
.conv { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 2px var(--s-3); padding: 10px var(--s-2); border-radius: var(--r-2); }
.conv:hover { background: var(--gray-3); }
.conv.is-on { background: var(--accent-3); }
.conv .av { grid-row: span 2; width: 32px; height: 32px; font-size: 12px; align-self: center; }
.conv .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .time { font-size: var(--fs-12); color: var(--text-3); text-align: right; }
.conv .prev { font-size: var(--fs-13); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .unread { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-9); justify-self: end; align-self: center; }
.conv.is-unread .name, .conv.is-unread .prev { color: var(--text); }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: var(--s-3); height: 60px; padding: 0 var(--s-5); border-bottom: 1px solid var(--line-soft); }
.thread-head .who { line-height: 1.25; min-width: 0; }
.thread-head .who small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .who small { display: block; color: var(--text-3); font-size: var(--fs-12); }
.thread-log { flex: 1; overflow-y: auto; padding: var(--s-5) var(--s-6); display: flex; flex-direction: column; gap: var(--s-2); background: var(--gray-1); }
.day { align-self: center; margin: var(--s-2) 0; font-size: var(--fs-12); color: var(--text-3); background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-full); padding: 2px 10px; }
.msg { max-width: 68%; padding: 8px 12px; border-radius: 16px; line-height: 1.45; background: var(--surface); border: 1px solid var(--line-soft); box-shadow: var(--shadow-1); }
.msg time { display: block; margin-top: 2px; font-size: 11px; color: var(--text-3); text-align: right; }
.msg.me { align-self: flex-end; background: var(--accent-9); color: #fff; border-color: transparent; border-bottom-right-radius: 6px; }
.msg.me time { color: rgba(255, 255, 255, .72); }
.msg.them { border-bottom-left-radius: 6px; }
.composer { padding: var(--s-3) var(--s-5) var(--s-4); border-top: 1px solid var(--line-soft); background: var(--surface); }
.composer-box { border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--shadow-1); }
.composer-box:focus-within { border-color: var(--accent-8); box-shadow: 0 0 0 3px var(--accent-4); }
.composer-box textarea { display: block; width: 100%; min-height: 84px; padding: 10px 12px 0; border: 0; outline: 0; resize: none; font: inherit; background: transparent; }
.composer-tools { display: flex; align-items: center; gap: var(--s-1); padding: 6px; }
.composer-tools .btn-primary { margin-left: auto; }
.ai { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-full); background: linear-gradient(135deg, var(--accent-3), var(--violet-3)); color: var(--violet-11); font-size: var(--fs-12); font-weight: 500; }
.context { border-left: 1px solid var(--line-soft); padding: var(--s-5); overflow-y: auto; }
.context h3 { margin: 0 0 var(--s-3); font-size: var(--fs-12); font-weight: 500; color: var(--text-3); }
.mini-card { display: flex; flex-direction: column; gap: 6px; padding: var(--s-3); border: 1px solid var(--line-soft); border-radius: var(--r-2); }
.mini-card + .mini-card { margin-top: var(--s-2); }

/* ── Настройки ── */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100dvh - 56px); }
.settings-nav { padding: var(--s-4) var(--s-3); border-right: 1px solid var(--line-soft); }
.settings-nav .nav-label { margin-left: var(--s-2); }
.settings-nav a { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 var(--s-2); border-radius: var(--r-1); color: var(--text-2); font-size: var(--fs-13); font-weight: 500; }
.settings-nav a:hover { background: var(--gray-3); color: var(--text); }
.settings-nav a.is-on { background: var(--gray-3); color: var(--text); }
.settings-body { padding: var(--s-8) var(--s-8) var(--s-12); max-width: 840px; }
.settings-body > h2 { margin: 0; font-size: var(--fs-20); font-weight: 600; letter-spacing: -.015em; }
.settings-body > p.lead { margin: 6px 0 var(--s-6); color: var(--text-2); }
.panel { border: 1px solid var(--line-soft); border-radius: var(--r-3); background: var(--surface); }
.panel + .panel { margin-top: var(--s-5); }
.panel-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line-soft); }
.panel-head h3 { margin: 0; font-size: var(--fs-14); font-weight: 600; }
.panel-head p { margin: 2px 0 0; font-size: var(--fs-13); color: var(--text-3); }
.panel-head .btn { margin-left: auto; }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--s-6); align-items: center; padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line-soft); }
.setting:first-child { border-top: 0; }
.setting b { display: block; font-weight: 500; }
.setting small { display: block; color: var(--text-3); font-size: var(--fs-13); margin-top: 2px; }
.stage { display: flex; align-items: center; gap: var(--s-3); height: 48px; padding: 0 var(--s-4) 0 var(--s-5); border-top: 1px solid var(--line-soft); }
.stage:first-child { border-top: 0; }
.stage .grip { color: var(--gray-8); cursor: grab; }
.stage .swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.stage .name { flex: 1; font-weight: 500; }
.stage .n { color: var(--text-3); font-size: var(--fs-13); font-variant-numeric: tabular-nums; width: 84px; text-align: right; }
.stage .btn-icon { color: var(--gray-9); width: 28px; height: 28px; }
.toggle { position: relative; width: 32px; height: 18px; border-radius: 999px; background: var(--gray-6); flex: 0 0 auto; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-2); }
.toggle.on { background: var(--accent-9); }
.toggle.on::after { left: 16px; }
.field-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 140px 120px 32px; align-items: center; gap: var(--s-3); height: 48px; padding: 0 var(--s-4); border-top: 1px solid var(--line-soft); }
.field-row:first-child { border-top: 0; }
.type-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-1); background: var(--gray-3); color: var(--gray-11); }

/* ── Пустое состояние, вход, тосты ── */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-2); padding: 72px var(--s-6); }
.empty-state .ic { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--gray-3); color: var(--gray-11); margin-bottom: var(--s-2); }
.empty-state .ic .icon { width: 22px; height: 22px; }
.empty-state h2 { margin: 0; font-size: var(--fs-16); font-weight: 600; }
.empty-state p { margin: 0 0 var(--s-3); max-width: 360px; color: var(--text-2); }
.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6); background:
  radial-gradient(1200px 600px at 50% -10%, var(--accent-3), transparent 60%), var(--gray-1); }
.auth-card { width: 100%; max-width: 380px; padding: var(--s-8); background: var(--surface); border: 1px solid var(--line-soft); border-radius: 16px; box-shadow: var(--shadow-3); }
.auth-card .logo { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; margin-bottom: var(--s-5); }
.auth-card h1 { margin: 0; font-size: var(--fs-20); font-weight: 600; letter-spacing: -.015em; }
.auth-card p { margin: 4px 0 var(--s-6); color: var(--text-2); }
.auth-card form { display: flex; flex-direction: column; gap: var(--s-4); }
.auth-foot { margin-top: var(--s-6); text-align: center; color: var(--text-3); font-size: var(--fs-12); }
.toast { position: fixed; right: var(--s-6); bottom: var(--s-6); z-index: 30; display: flex; align-items: center; gap: var(--s-2); padding: 10px 14px; border-radius: var(--r-2); background: var(--gray-12); color: #fff; box-shadow: var(--shadow-3); font-size: var(--fs-13); }
.toast .icon { color: #6ee7b7; }

/* ── Мобильная версия ── */
.m-top, .tabbar { display: none; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; padding-bottom: 64px; }
  .side { display: none; }
  .m-top {
    position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: var(--s-2);
    height: 52px; padding: 0 var(--s-3) 0 var(--s-4);
    background: rgba(255,255,255,.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-soft);
  }
  .m-top h1 { margin: 0; font-size: 17px; font-weight: 600; }
  .m-top .head-actions .btn-icon { width: 36px; height: 36px; }
  .page-head { display: none; }
  .filterbar { padding: var(--s-2) var(--s-4); }
  .filterbar .search { display: none; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
    height: 64px; padding-bottom: env(safe-area-inset-bottom, 0);
    background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-top: 1px solid var(--line-soft);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--text-3); position: relative; }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a.is-on { color: var(--accent-9); }
  .tabbar .badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--red-9); color: #fff; font-size: 10px; display: grid; place-items: center; }
  .board { flex-direction: column; padding: var(--s-3) var(--s-4) var(--s-6); overflow: visible; }
  .col { flex: none; width: 100%; background: transparent; padding: 0; }
  .col:not(:first-of-type) { display: none; }
  .col-head { display: none; }
  .stage-tabs { display: flex; gap: 6px; padding: var(--s-3) var(--s-4) 0; overflow-x: auto; scrollbar-width: none; }
  .stage-tabs a { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--gray-3); color: var(--text-2); font-size: var(--fs-13); font-weight: 500; white-space: nowrap; }
  .stage-tabs a.is-on { background: var(--gray-12); color: #fff; }
  .stage-tabs a .n { opacity: .7; font-variant-numeric: tabular-nums; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line-soft); }
  .table td { height: auto; padding: 0 !important; border: 0; }
  .table td.hide-m { display: none; }
  .table td.num { position: absolute; top: var(--s-3); right: var(--s-4); }
  .table tr { position: relative; }
  .table td + td { margin-top: 4px; }
  .drawer { inset: 0; width: auto; border-radius: 0; border: 0; }
  .drawer-bar { padding-left: var(--s-4); }
  .drawer-body { padding: var(--s-4); }
  .scrim { display: none; }
  .split { grid-template-columns: 1fr; }
  .split-side { border-left: 0; border-top: 1px solid var(--line-soft); }
  .split-main { padding: var(--s-4); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
  .kpi { padding: var(--s-2) var(--s-3); }
  .kpi strong { font-size: var(--fs-16); }
  .inbox { grid-template-columns: 1fr; height: calc(100dvh - 64px - 52px); }
  .inbox .context, .inbox .inbox-list { display: none; }
  .inbox.list-mode .inbox-list { display: flex; }
  .inbox.list-mode .thread { display: none; }
  .thread-head { display: none; }
  .composer-box textarea { min-height: 60px; }
  .thread-log { padding: var(--s-4) var(--s-3); }
  .msg { max-width: 84%; }
  .composer { padding: var(--s-2) var(--s-3) var(--s-3); }
  .settings { grid-template-columns: 1fr; }
  .settings-nav { display: flex; gap: 4px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line-soft); padding: var(--s-2) var(--s-3); scrollbar-width: none; }
  .settings-nav .nav-label { display: none; }
  .settings-nav a { flex: 0 0 auto; }
  .settings-body { padding: var(--s-5) var(--s-4) var(--s-12); }
  .setting { grid-template-columns: 1fr; gap: var(--s-2); }
  .field-row { grid-template-columns: 28px minmax(0, 1fr) 32px; }
  .field-row .hide-m { display: none; }
  .stage .n { display: none; }
  .hide-m { display: none !important; }
  .toast { left: var(--s-4); right: var(--s-4); bottom: 76px; }
  .props { grid-template-columns: 112px minmax(0, 1fr); }
  .search { width: 100%; }
  .content { padding: var(--s-4); }
  .table-foot { padding: var(--s-3) var(--s-4); }
}

/* ── Приложение: кнопки, формы, диалоги, прежние классы ── */
.btn:not(.btn-ghost):not(.btn-secondary):not(.btn-icon):not(.btn-text):not(.btn-danger):not(.btn-danger-ghost),
button:not([class]) {
  background: var(--accent-9);
  color: #fff;
  border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), var(--shadow-1);
}
.btn:not(.btn-ghost):not(.btn-secondary):not(.btn-icon):not(.btn-text):not(.btn-danger):not(.btn-danger-ghost):hover,
button:not([class]):hover { background: var(--accent-10); }
.btn-danger { background: var(--red-9); color: #fff; border-color: transparent; }
.btn-danger:hover { background: var(--red-11); }
.skip-link {
  position: absolute; left: 8px; top: -40px; z-index: 50;
  background: var(--gray-12); color: #fff; padding: 6px 10px; border-radius: var(--r-1);
}
.skip-link:focus { top: 8px; }
.main-fill { min-height: 100dvh; }
.main-fill .board { flex: 1; }

input[type="text"], input[type="password"], input[type="email"], input[type="url"],
input[type="number"], input[type="date"], input[type="search"], input:not([type]),
select, textarea {
  font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--line); border-radius: var(--r-2);
  height: var(--h-control); padding: 0 10px; box-shadow: var(--shadow-1); width: 100%;
}
textarea { height: auto; min-height: 72px; padding: 8px 10px; line-height: 1.45; }
input[type="checkbox"], input[type="radio"], input[type="color"], input[type="hidden"] {
  width: auto; height: auto; padding: 0; box-shadow: none; border: 0; background: transparent;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-8); box-shadow: 0 0 0 3px var(--accent-4); }
.input input, .composer-box textarea { border: 0; box-shadow: none; height: auto; background: transparent; }
label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-13); font-weight: 500; }
label.radio, .radio { flex-direction: row; align-items: center; font-weight: 400; gap: 8px; }
.filters, .toolbar { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.field-filters { display: grid; gap: var(--s-2); margin: 0; }
.field-filters label { min-width: 0; }

details.chip { position: relative; height: auto; padding: 0; }
details.chip > summary { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; list-style: none; cursor: pointer; }
details.chip > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 200px;
  display: flex; flex-direction: column; gap: 2px; padding: 4px;
  background: #fff; border: 1px solid var(--line-soft); border-radius: var(--r-2); box-shadow: var(--shadow-3);
}
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; text-align: left; background: transparent; color: var(--text); border: 0; box-shadow: none; font-weight: 400; height: auto; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--gray-3); }
.menu-pop-wide { width: 280px; padding: var(--s-3); }

dialog.slider {
  margin: 8px 8px 8px auto; padding: 0; border: 1px solid var(--line-soft);
  border-radius: 14px; width: min(560px, calc(100vw - 16px)); max-width: none;
  height: calc(100dvh - 16px); max-height: calc(100dvh - 16px);
  box-shadow: var(--shadow-3); color: var(--text);
}
dialog.slider::backdrop { background: rgba(16, 24, 40, .24); }
dialog.slider .drawer-body, dialog.slider .slider-pane { overflow-y: auto; padding: var(--s-5); flex: 1; }
dialog.slider { display: none; flex-direction: column; }
dialog.slider[open] { display: flex; }
dialog.slider .create-card, dialog.slider .card-block { margin: 0; border: 0; box-shadow: none; padding: 0; }

.card-block, .create-card {
  background: #fff; border: 1px solid var(--line-soft); border-radius: var(--r-3);
  padding: var(--s-4); margin: 0 0 var(--s-4); display: grid; gap: var(--s-3);
}
.card-block h2, .create-card h2 { margin: 0; font-size: var(--fs-16); }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
table.grid th {
  height: 36px; padding: 0 var(--s-3); text-align: left; font-size: var(--fs-12); font-weight: 500;
  color: var(--text-3); border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
table.grid td { height: 44px; padding: 0 var(--s-3); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tbody tr:hover td { background: var(--gray-2); }
table.grid a { color: inherit; }
.table-wrap { overflow-x: auto; }

.flash {
  position: fixed; right: var(--s-6); bottom: var(--s-6); z-index: 40;
  padding: 10px 14px; border-radius: var(--r-2); background: var(--gray-12); color: #fff;
  box-shadow: var(--shadow-3); font-size: var(--fs-13);
}
.flash-error { background: var(--red-11); }
.htmx-indicator { display: none; position: fixed; top: 12px; right: 12px; z-index: 40; font-size: 12px; color: var(--text-3); }
.htmx-request .htmx-indicator, .htmx-indicator.htmx-request { display: block; }
.error { color: var(--red-11); }
.prose { white-space: pre-wrap; line-height: 1.5; }
pre { white-space: pre-wrap; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--gray-2); padding: var(--s-3); border-radius: var(--r-2); }
.inline { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.row-main { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.facts { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 4px 12px; margin: var(--s-3) 0; }
.facts dt { color: var(--text-3); font-size: var(--fs-13); }
.facts dd { margin: 0; }
.count { color: var(--text-3); font-weight: 400; }
.secret { -webkit-text-security: disc; }
ol.timeline, ul.feed { margin: var(--s-3) 0; }
.user-pop {
  position: fixed; z-index: 40; left: 12px; bottom: 64px; width: 220px;
  background: #fff; border: 1px solid var(--line-soft); border-radius: var(--r-2); box-shadow: var(--shadow-3); padding: 4px;
}
.user-pop[hidden] { display: none; }
.user-pop .menu-item {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; padding: 0 8px;
  text-align: left; background: transparent; color: var(--text); border: 0; box-shadow: none;
  height: 32px; border-radius: 6px; font-weight: 400;
}
.user-pop .menu-item .icon { width: 16px; height: 16px; color: var(--text-3); }
.user-pop .menu-item:hover { background: var(--gray-3); }
.user-pop .nav-logout { margin: 0; }
.user-pop .menu-item + .nav-logout { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line-soft); }
.side-foot { width: 100%; background: transparent; border: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.settings { align-items: start; }
.settings-body .tabs { margin-bottom: var(--s-4); }
.stage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-2); align-items: center; padding: var(--s-2) 0; border-top: 1px solid var(--line-soft); }
.stage-edit { display: flex; gap: var(--s-2); align-items: center; }
.stage-edit input[name="st_title"], .stage-edit input[name="new_title"] { flex: 1 1 160px; width: auto; min-width: 0; }
.login-card, .auth-card form label { font-weight: 500; }
.inbox { grid-template-columns: 320px minmax(0, 1fr); height: 100dvh; }
.acct { position: relative; }
.acct > summary {
  display: flex; align-items: center; gap: 6px; height: var(--h-control); padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); box-shadow: var(--shadow-1);
  list-style: none; cursor: pointer; font-size: var(--fs-13);
}
.acct > summary::-webkit-details-marker { display: none; }
.acct > summary:hover { border-color: var(--gray-7); }
.acct-label { color: var(--text-3); flex: none; }
.acct > summary b { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .menu-pop { left: 0; right: 0; }
.acct .menu-pop a { justify-content: space-between; }
.acct .menu-pop a.is-on { font-weight: 500; }
.acct .menu-pop a .icon { color: var(--accent-9); }
.inbox-list { overflow-y: auto; }
.inbox-list .conv { margin: 0 var(--s-2); }
.inbox-list .inbox-top + .conv { margin-top: var(--s-2); }
.chat-empty { flex: 1; justify-content: center; background: var(--gray-1); }
.chat-head { display: flex; align-items: center; gap: var(--s-3); min-height: 60px; padding: var(--s-2) var(--s-5); border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.chat-head .av { width: 32px; height: 32px; font-size: 12px; flex: none; }
.chat-head-main { flex: 1; min-width: 0; line-height: 1.3; }
.chat-head-main strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-main small { display: block; color: var(--text-3); font-size: var(--fs-12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-links { display: flex; align-items: center; gap: var(--s-1); flex: none; }
.chat-head-links .btn { gap: 6px; }
.chat-head .chat-back { display: none; }
.msg .prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .bubble-meta, .msg .bubble-note { margin-top: 2px; font-size: 11px; color: var(--text-3); text-align: right; }
.msg.me .bubble-meta, .msg.me .bubble-note { color: rgba(255, 255, 255, .72); }
.composer-tools .btn:last-child { margin-left: auto; }
.composer-tools .ai { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-12); color: var(--accent-11); }
@media (max-width: 800px) {
  .chat-head { padding: var(--s-2) var(--s-3); }
  .chat-head .chat-back { display: inline-flex; }
}
.col { background: var(--gray-3); }
button.col-add {
  width: 100%; justify-content: flex-start; background: transparent; color: var(--text-3);
  border: 0; box-shadow: none; font-weight: 400;
}
button.col-add:hover { background: var(--gray-4); color: var(--text); }
label.input { flex-direction: row; align-items: center; font-weight: 400; }
article.detail h1 { margin: 0 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -.015em; }
article.detail .deal-price { margin: 0 0 8px; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
article.detail .stage-form { display: grid; gap: 8px; margin: 8px 0; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--gray-3); font-size: 12px; font-weight: 500; }
.auth { width: 100%; }
@media (max-width: 800px) {
  .user-pop { bottom: 76px; }
  .flash { left: var(--s-4); right: var(--s-4); bottom: 76px; }
  dialog.slider, dialog.modal, dialog.modal.spa-panel { margin: 0; width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  table.grid thead { display: none; }
}

/* ── Отступы страниц и формы без новой разметки ── */
.main > :is(.tabs, .toolbar, .table-wrap, .chips, p, h2, section, form, .card-block, .create-card, .empty) { margin-inline: var(--s-6); }
.main > .registry-tabs { margin: 0; padding: 0 var(--s-6); }
.main > .table-wrap { margin-top: var(--s-2); margin-bottom: var(--s-8); }
.main > article.detail { padding: var(--s-6) var(--s-6) var(--s-12); max-width: 820px; }
.filterbar .chips { display: contents; }
.filterbar .chips .chip a { margin-left: 4px; color: var(--text-3); }
.filterbar .filters { margin-left: auto; }
.filterbar .search { width: 240px; }
details.chip { flex: none; width: max-content; }
details.chip-add .menu-pop { right: auto; }
.menu-pop-wide .field-filters { display: grid; gap: var(--s-3); }
table.grid td form { display: inline; margin: 0; }
table.grid td:last-child:not([colspan]) { text-align: right; }
table.grid .btn-ghost, .row-main .btn-ghost { height: 28px; padding: 0 8px; font-size: var(--fs-12); }
.row-main form { margin: 0 0 0 auto; }

label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
  flex-direction: row; align-items: center; gap: 8px; font-weight: 400;
}
label:has(> input[type="checkbox"]) > input, label:has(> input[type="radio"]) > input { order: -1; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent-9); }
input[type="color"] { width: 32px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-2); cursor: pointer; }

.drawer-bar > span, .slider-bar > span { flex: 1; font-weight: 600; }
dialog.modal {
  margin: 8px 8px 8px auto; padding: 0; border: 1px solid var(--line-soft);
  border-radius: 14px; width: min(560px, calc(100vw - 16px)); max-width: none;
  height: calc(100dvh - 16px); max-height: calc(100dvh - 16px);
  box-shadow: var(--shadow-3); color: var(--text); display: none; flex-direction: column;
}
dialog.modal[open] { display: flex; }
dialog.modal::backdrop { background: rgba(16, 24, 40, .24); }
.slider-bar { display: flex; justify-content: flex-end; align-items: center; height: 48px; padding: 0 var(--s-3); border-bottom: 1px solid var(--line-soft); flex: none; }
dialog.modal .slider-pane { overflow-y: auto; padding: var(--s-5); flex: 1; display: grid; gap: var(--s-3); align-content: start; }
dialog.modal .slider-pane > h2 { margin: 0; font-size: var(--fs-20); font-weight: 600; }
.detail-close { width: var(--h-control); padding: 0; font-size: 20px; }
.spa-nav { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--line-soft); }
.spa-nav button {
  height: 36px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  color: var(--text-2); font-weight: 500; position: relative;
}
.spa-nav button:hover { background: transparent; color: var(--text); }
.spa-nav button.is-on { color: var(--text); }
.spa-nav button.is-on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); }
[data-spa-panel]:not([hidden]) { display: grid; gap: var(--s-3); align-content: start; }
:where(dialog .drawer-body, dialog .slider-pane) form:where(:not(.inline, .stage-delete, .stage-row, .card-foot, .chip, .stage-form)) { display: grid; gap: var(--s-3); align-content: start; }
:where(dialog .drawer-body, dialog .slider-pane) form > :where(button, .btn, .btn-ghost, .btn-secondary, .btn-danger) { justify-self: start; }
dialog.modal.spa-panel { width: min(880px, calc(100vw - 16px)); }
.pane-foot, .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.pane-foot form, .form-actions form { display: contents; }
.pane-foot form > button:last-child, .form-actions form > button:last-child { margin-left: auto; }
[data-spa-panel] > * { margin: 0; }
.pane-meta { display: flex; align-items: center; gap: var(--s-3); }
.spa-tools { display: flex; gap: var(--s-2); margin-bottom: var(--s-4); }
.crumb { background: transparent; border: 0; padding: 0; color: var(--accent-11); cursor: pointer; font: inherit; }

.empty-state h1 { margin: 0 0 var(--s-3); font-size: var(--fs-20); font-weight: 600; }

/* ── Формы настроек ── */
form.inline { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
form.inline > input:not([type="hidden"]), form.inline > select { flex: 1 1 160px; width: auto; min-width: 0; }
table.grid td form.inline { display: flex; flex-wrap: nowrap; }
.card-block form:not(.inline):not(.chip), .create-card { display: grid; gap: var(--s-3); }
:is(.card-block, .create-card, .stage-form, .card-block form) > :is(button, .btn, .btn-ghost, .btn-danger) { justify-self: start; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-2) var(--s-4); }
fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: var(--s-2); }
legend { padding: 0; margin-bottom: var(--s-2); font-size: var(--fs-13); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
form.chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 10px; }
.chip-x { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); cursor: pointer; font-size: 14px; line-height: 1; }
.chip-x:hover { background: var(--gray-4); color: var(--text); }
details.add-new { margin-bottom: var(--s-4); }
details.add-new > summary { list-style: none; width: max-content; }
details.add-new > summary::-webkit-details-marker { display: none; }
details.add-new[open] > summary { margin-bottom: var(--s-3); }
.settings-body .stage-form { display: grid; gap: var(--s-3); max-width: 560px; }
.settings-body > h2, .settings-body > p { margin: var(--s-5) 0 var(--s-2); }
.settings-body > p:first-child { margin-top: 0; }
.stage-row .stage-edit input[type="color"] { flex: none; }
.stage-row .stage-edit select { width: 140px; flex: none; }
.stage-grip {
  flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-3); cursor: grab; touch-action: none;
}
.stage-grip:hover { background: var(--gray-3); color: var(--text); }
.stage-grip:active, .stage-row.is-dragging .stage-grip { cursor: grabbing; }
.stage-row.is-dragging { opacity: .45; }
.stage-delete { display: flex; align-items: center; gap: var(--s-2); justify-content: flex-end; }
.stage-delete select { flex: 1; width: auto; min-width: 0; }
form.card-foot { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--line-soft); }
form.card-foot select { width: 220px; }
.stage-row { grid-template-columns: minmax(0, 1fr) 300px; }
table.grid tr.group-row th { height: 32px; background: var(--gray-2); color: var(--text-2); font-weight: 600; }
table.grid code { font-size: var(--fs-12); color: var(--text-2); background: var(--gray-3); padding: 2px 6px; border-radius: 4px; }

/* ── Карточка сделки / клиента ── */
article.detail { display: flex; flex-direction: column; gap: var(--s-2); }
article.detail > p { margin: 0; }
article.detail > h2 {
  margin: var(--s-5) 0 0; padding-top: var(--s-4); border-top: 1px solid var(--line-soft);
  font-size: var(--fs-14); font-weight: 600; display: flex; align-items: center; gap: 6px;
}
article.detail .stage-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-2);
  margin: var(--s-2) 0 0; padding: var(--s-3); border: 1px solid var(--line-soft); border-radius: var(--r-3); background: var(--gray-1);
}
article.detail .stage-form label { flex: 1 1 180px; min-width: 0; }
article.detail .stage-form .btn, article.detail .stage-form .btn-ghost { flex: none; }
article.detail .stage-form .btn-ghost, article.detail form > .btn-ghost:last-child {
  background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--shadow-1);
}
article.detail form[action="/custom-fields/values"] {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-3); align-items: end;
}
article.detail form[action="/custom-fields/values"] > .btn-ghost { justify-self: start; grid-column: 1 / -1; }
article.detail .company-meta, article.detail .company-reach { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
article.detail .facts { margin: var(--s-2) 0 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--line-soft); border-radius: var(--r-3); }
article.detail .plain-list { gap: 0; border: 1px solid var(--line-soft); border-radius: var(--r-3); }
article.detail .plain-list > li { padding: var(--s-2) var(--s-3); }
article.detail .plain-list > li + li { border-top: 1px solid var(--line-soft); }
article.detail .plain-list p { margin: 4px 0 0; }
details.fold > summary {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; margin-top: var(--s-1);
  border: 1px dashed var(--line); border-radius: var(--r-2); color: var(--text-2); cursor: pointer; list-style: none; font-size: var(--fs-13);
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold[open] > summary { margin-bottom: var(--s-2); }
table.grid td details.fold { position: relative; display: inline-block; }
table.grid td details.fold[open] > summary { margin-bottom: 0; }
table.grid td details.fold[open] > :not(summary) {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 320px;
  display: grid; gap: var(--s-3); padding: var(--s-4); text-align: left;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-3); box-shadow: var(--shadow-3);
}
table.grid td details.fold form { display: grid; gap: var(--s-3); }
table.grid td details.fold form > button { justify-self: start; }
.table-wrap:has(details.fold[open]) { overflow: visible; }
article.detail .card { margin-top: var(--s-2); }
article.detail ol.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
article.detail ol.timeline li { display: flex; gap: var(--s-3); font-size: var(--fs-13); }
article.detail ol.timeline li .muted { flex: none; width: 120px; color: var(--text-3); font-variant-numeric: tabular-nums; }
article.detail form.inline { margin-top: var(--s-2); }
article.detail form.inline input { flex: 1; }
@media (max-width: 800px) {
  .main > :is(.tabs, .toolbar, .table-wrap, .chips, p, h2, section, form, .card-block, .create-card, .empty) { margin-inline: var(--s-4); }
  .main > .registry-tabs { padding: 0 var(--s-4); overflow-x: auto; }
  .main > article.detail { padding: var(--s-4) var(--s-4) var(--s-12); }
  .filterbar .filters, .filterbar .search { width: 100%; margin-left: 0; }
  .filterbar .search { display: flex; }
  .main:has(> .page-head) > .m-top { display: none; }
  .page-head { display: flex; position: sticky; top: 0; height: 52px; padding: 0 var(--s-3) 0 var(--s-4); }
  .page-head h1 { font-size: 17px; }
  .page-head .crumbs { min-width: 0; }
  .page-head .crumbs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .registry-tabs a { white-space: nowrap; flex: none; }
  .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: transparent; box-shadow: none; height: auto; padding: 0;
    font-size: 11px; font-weight: 500; color: var(--text-3);
  }
  .tabbar button .icon { width: 22px; height: 22px; }
  .settings { align-content: start; }
  .stage-row { grid-template-columns: 1fr; }
  .stage-delete { justify-content: flex-start; }
  .stage-edit { flex-wrap: wrap; }
  .stage-row .stage-edit select { flex: 1 1 120px; width: auto; min-width: 0; }
  table.grid td details.fold[open] > :not(summary) { position: fixed; top: auto; left: var(--s-3); right: var(--s-3); bottom: var(--s-3); width: auto; }
  .stage-edit input[name="st_title"], .stage-edit input[name="new_title"] { flex-basis: 200px; }
  dialog.modal.spa-panel { width: 100vw; }
}
