/* ============================================================
   Личный CRM — дизайн-система (порт прототипа Claude Design).
   Тема: только переменные Telegram + наши свежести/тост.
   ПРАВИЛО: hex-цвета — ТОЛЬКО в :root (светлая) и в :root внутри
   @media (prefers-color-scheme: dark). В правилах компонентов —
   только var()/color-mix()/hsl()/rgba(), без hex.
   ============================================================ */
:root {
  /* слоты темы Telegram → семантические токены с hex-fallback (светлая) */
  --bg:           var(--tg-theme-bg-color, #ffffff);
  --text:         var(--tg-theme-text-color, #000000);
  --hint:         var(--tg-theme-hint-color, #8b97a3);
  --link:         var(--tg-theme-link-color, #2481cc);
  --button:       var(--tg-theme-button-color, #2481cc);
  --button-text:  var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f1f4f7);
  --section-bg:   var(--tg-theme-section-bg-color, #ffffff);
  --header-bg:    var(--tg-theme-header-bg-color, #ffffff);
  --hair:         var(--tg-theme-section-separator-color, #e7ebef);
  /* свежесть контакта (наши) */
  --fresh-color:  #2ca24d;
  --mid-color:    #b9a13a;
  --stale-color:  #e0443a;
  /* тост — контрастная «таблетка», фикс. для читаемости в обеих темах */
  --toast-bg:     #1f2730;
  --toast-text:   #ffffff;
  --toast-act:    #5ab0ff;
  /* служебные фикс-цвета */
  --sw-knob:      #ffffff;
  --on-button:    #ffffff;
  --seg-on-bg:    var(--section-bg);
  --seg-on-text:  var(--text);
}

/* Браузерный fallback тёмной темы. Внутри Telegram сами --tg-theme-*
   придут от клиента и победят эти hex-fallback'и. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           var(--tg-theme-bg-color, #17212b);
    --text:         var(--tg-theme-text-color, #ffffff);
    --hint:         var(--tg-theme-hint-color, #708499);
    --link:         var(--tg-theme-link-color, #6ab3f3);
    --button:       var(--tg-theme-button-color, #5288c1);
    --button-text:  var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #232e3c);
    --section-bg:   var(--tg-theme-section-bg-color, #1d2733);
    --header-bg:    var(--tg-theme-header-bg-color, #17212b);
    --hair:         var(--tg-theme-section-separator-color, #2a3643);
    --fresh-color:  #4fc56e;
    --mid-color:    #d8bd54;
    --stale-color:  #ff6b62;
    --toast-bg:     #e9eef3;
    --toast-text:   #17212b;
    --toast-act:    #2481cc;
    --seg-on-bg:    #3a4a5c;
    --seg-on-text:  #ffffff;
  }
}

/* производные — color-mix от семантических токенов (без hex) */
:root {
  --press:       color-mix(in srgb, var(--text) 7%, transparent);
  --chip-bg:     color-mix(in srgb, var(--text) 6%, transparent);
  --accent-soft: color-mix(in srgb, var(--link) 14%, transparent);
  --fresh-soft:  color-mix(in srgb, var(--fresh-color) 16%, transparent);
  --stale-soft:  color-mix(in srgb, var(--stale-color) 16%, transparent);
  --mid-soft:    color-mix(in srgb, var(--mid-color) 18%, transparent);
  --r: 12px;
  --pad: 16px;
}

/* ============================================================ База */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; width: 100%; max-width: 100%; overflow-x: hidden; }
body {
  background: var(--secondary-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px; line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }
/* font-size ≥16px на ВСЕХ полях: iOS зумит при фокусе всё, что меньше 16px */
input, textarea, select { font: inherit; color: inherit; font-size: 16px; }
.hint { color: var(--hint); }
.tnum { font-variant-numeric: tabular-nums; }
.i { display: inline-flex; }
.i svg { width: 20px; height: 20px; display: block; }
svg { stroke: currentColor; }

/* ============================================================ Каркас */
.app {
  position: relative;
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  width: 100%; max-width: 640px; margin: 0 auto;   /* центр-колонка: телефон — на всю ширину, десктоп — 640px */
  background: var(--secondary-bg);
  overflow-x: hidden; overflow-y: hidden;           /* контент не «ездит» по горизонтали */
}
.app__body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.app__body.fullbleed { overflow: hidden; }
.app__scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; padding-bottom: 8px; width: 100%; max-width: 100%;
}
.app__scroll::-webkit-scrollbar { width: 0; }

/* верхняя шапка */
.topbar {
  display: flex; align-items: center; gap: 10px; z-index: 20;
  padding: 10px var(--pad); padding-top: max(10px, env(safe-area-inset-top));
  background: var(--header-bg); border-bottom: 1px solid var(--hair);
  min-height: 52px; flex: none;
}
.topbar__title { font-size: 20px; font-weight: 700; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sub { font-size: 12.5px; margin-top: 1px; }
.topbar__spacer { flex: 1; }
.topbar__btn { width: 36px; height: 36px; border-radius: 50%; display: grid;
  place-items: center; color: var(--link); flex: none; }
.topbar__btn:active { background: var(--press); }
.topbar__btn svg { width: 22px; height: 22px; }
.iconbtn-back { color: var(--link); font-size: 17px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 2px; padding: 6px 6px 6px 0; flex: none; }
.iconbtn-back svg { width: 21px; height: 21px; }

/* ============================================================ Нижняя навигация */
.tabbar {
  display: grid; grid-template-columns: repeat(4, 1fr); z-index: 30; flex: none;
  background: var(--header-bg); border-top: 1px solid var(--hair);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 0 8px; color: var(--hint); font-size: 10.5px; font-weight: 500; position: relative; }
.tab svg { width: 25px; height: 25px; }
.tab.is-active { color: var(--link); }
.tab__badge { position: absolute; top: 3px; left: calc(50% + 7px);
  min-width: 16px; height: 16px; padding: 0 4px; background: var(--stale-color);
  color: var(--on-button); border-radius: 9px; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; line-height: 1; }

/* FAB */
.fab {
  position: absolute; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 50%; z-index: 35;
  background: var(--button); color: var(--button-text); display: grid; place-items: center;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--button) 45%, transparent);
  transition: transform .12s;
}
.fab:active { transform: scale(.92); }
.fab svg { width: 26px; height: 26px; }

/* ============================================================ Аватар-инициалы */
.av {
  --s: 40px; width: var(--s); height: var(--s); border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 600;
  font-size: calc(var(--s) * .38); letter-spacing: .01em;
  background: hsl(var(--h) 58% 50% / .15); color: hsl(var(--h) 52% 40%); position: relative;
}
@media (prefers-color-scheme: dark) {
  .av { background: hsl(var(--h) 40% 58% / .22); color: hsl(var(--h) 60% 74%); }
}
.av__dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px;
  border-radius: 50%; border: 2.5px solid var(--section-bg); }
.dot-fresh { background: var(--fresh-color); }
.dot-mid   { background: var(--mid-color); }
.dot-stale { background: var(--stale-color); }
.dot-muted { background: var(--hint); }

/* ============================================================ Группы-секции */
.group { background: var(--section-bg); margin: 0 0 10px; }
.group--card { background: var(--section-bg); margin: 10px var(--pad); border-radius: var(--r); overflow: hidden; }
.group__title { font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .03em; color: var(--hint); padding: 16px var(--pad) 7px; }

/* ============================================================ Строка списка */
.row { display: flex; align-items: center; gap: 12px; padding: 9px var(--pad);
  background: var(--section-bg); position: relative; min-height: 56px; width: 100%; text-align: left; }
.row:active { background: var(--press); }
.row + .row::before { content: ''; position: absolute; top: 0; left: 68px; right: 0;
  border-top: 1px solid var(--hair); }
.row__main { flex: 1; min-width: 0; }
.row__name { font-size: 16px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__name.task { font-weight: 500; font-size: 15px; }
.row__name.done { text-decoration: line-through; opacity: .5; }
.row__sub { font-size: 13px; color: var(--hint); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__meta { text-align: right; flex: none; display: flex; flex-direction: column;
  align-items: flex-end; gap: 4px; }
.row__ago { font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ago-fresh { color: var(--fresh-color); }
.ago-mid   { color: var(--hint); }
.ago-stale { color: var(--stale-color); }
.row__chev { color: var(--hint); opacity: .55; flex: none; }
.row__chev svg { width: 18px; height: 18px; }
.row.leaving { opacity: 0; transform: translateX(40px); transition: opacity .26s, transform .26s; }

/* чек задачи */
.taskcheck { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--hint);
  flex: none; display: grid; place-items: center; background: none; color: transparent;
  transition: border-color .15s, background .15s; }
.taskcheck.is-done { background: var(--fresh-color); border-color: var(--fresh-color); color: var(--on-button); }
.taskcheck svg { width: 15px; height: 15px; }

/* подсказка «скоро ДР» */
.soon-line { font-size: 12.5px; padding: 4px var(--pad) 2px; margin-top: -6px; }

/* ============================================================ Чипы-фильтры */
.chiprow { display: flex; gap: 8px; overflow-x: auto; padding: 10px var(--pad);
  scrollbar-width: none; background: var(--header-bg); }
.chiprow::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 18px; background: var(--chip-bg);
  color: var(--text); font-size: 13.5px; font-weight: 500; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: background .12s; }
.chip.is-active { background: var(--button); color: var(--button-text); }
.chip__count { font-size: 11.5px; opacity: .65; font-variant-numeric: tabular-nums; }
.chip.is-active .chip__count { opacity: .8; }
.chiprow--over { position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  background: color-mix(in srgb, var(--header-bg) 82%, transparent); backdrop-filter: blur(8px); }

/* теги-круги (мелкие пилюли) */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px;
  border-radius: 12px; font-size: 12.5px; font-weight: 500;
  background: var(--accent-soft); color: var(--link); }
.tag--muted { background: var(--chip-bg); color: var(--hint); }

/* ============================================================ Поиск */
.search { display: flex; align-items: center; gap: 8px; margin: 8px var(--pad);
  padding: 8px 12px; border-radius: 10px; background: var(--chip-bg); color: var(--hint); }
.search svg { width: 19px; height: 19px; flex: none; }
.search input { flex: 1; border: none; background: none; outline: none;
  color: var(--text); font-size: 16px; }
.search input::placeholder { color: var(--hint); }

/* ============================================================ Кнопки-действия */
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 14px var(--pad); }
.act { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 11px 4px;
  border-radius: var(--r); background: var(--section-bg); color: var(--link); font-size: 12px; font-weight: 500; }
.act:active { background: var(--press); }
.act svg { width: 22px; height: 22px; }
.act--accent { background: var(--button); color: var(--button-text); }

/* большая кнопка */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 14px; border-radius: var(--r); font-size: 16px; font-weight: 600;
  background: var(--button); color: var(--button-text); }
.btn:active { filter: brightness(.94); }
.btn:disabled { opacity: .45; }
.btn svg { width: 20px; height: 20px; }
.btn--ghost { background: var(--chip-bg); color: var(--link); }
.btn--danger { background: var(--stale-soft); color: var(--stale-color); }
.btn--block { margin: 8px var(--pad); width: auto; }

/* пилюля «пообщались/поздравить» в списке */
.pill { flex: none; padding: 7px 12px; border-radius: 18px; font-size: 13px; font-weight: 600;
  background: var(--accent-soft); color: var(--link); display: inline-flex; align-items: center; gap: 5px; }
.pill:active { filter: brightness(.95); }
.pill svg { width: 15px; height: 15px; }
.pill.is-done { background: var(--fresh-soft); color: var(--fresh-color); }

/* ============================================================ Факт (прототип) */
.fact { display: flex; gap: 11px; padding: 11px var(--pad); background: var(--section-bg);
  position: relative; width: 100%; text-align: left; }
.fact + .fact::before { content:''; position:absolute; top:0; left:46px; right:0; border-top:1px solid var(--hair); }
.fact__ic { width: 22px; flex: none; text-align: center; font-size: 17px; line-height: 1.3; }
.fact__body { flex: 1; min-width: 0; }
.fact__text { font-size: 15px; }
.fact__meta { font-size: 12px; color: var(--hint); margin-top: 2px; }

/* ============================================================ Инфо-строки */
.line { display: flex; align-items: center; gap: 12px; padding: 12px var(--pad);
  background: var(--section-bg); position: relative; width: 100%; text-align: left; min-height: 48px; }
.line + .line::before { content:''; position:absolute; top:0; left:var(--pad); right:0; border-top:1px solid var(--hair); }
.line--btn:active { background: var(--press); }
.line__ic { width: 26px; flex: none; color: var(--link); display:grid; place-items:center; }
.line__ic svg { width: 22px; height: 22px; }
.line__main { flex: 1; min-width: 0; }
.line__label { font-size: 16px; }
.line__hint { font-size: 13px; color: var(--hint); margin-top: 1px; }
.line__val { font-size: 15px; color: var(--hint); margin-left: auto; }
.line__chev { color: var(--hint); opacity: .5; }
.line__chev svg { width: 18px; height: 18px; }

/* переключатель iOS */
.sw { width: 46px; height: 28px; border-radius: 16px; background: var(--chip-bg);
  position: relative; flex: none; transition: background .18s; }
.sw::after { content:''; position:absolute; top:2px; left:2px; width:24px; height:24px;
  border-radius:50%; background: var(--sw-knob); transition:transform .18s; box-shadow:0 1px 3px rgba(0,0,0,.25); }
.sw.on { background: var(--fresh-color); }
.sw.on::after { transform: translateX(18px); }

/* сегментированный переключатель */
.seg { display: inline-flex; background: var(--chip-bg); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { padding: 6px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--hint); }
.seg button.on { background: var(--seg-on-bg); color: var(--seg-on-text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
@media (prefers-color-scheme: dark) { .seg button.on { box-shadow: none; } }

/* ============================================================ Календарь */
.cal-seg-wrap { display: flex; justify-content: center; padding: 8px 0 6px; background: var(--header-bg); }
.cal { padding: 6px var(--pad) 0; }
.cal__head { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 12px; }
.cal__month { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.cal__nav { display: flex; gap: 4px; align-items: center; }
.cal__nav button { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--link); }
.cal__nav button:active { background: var(--press); }
.cal__nav button svg { width: 20px; height: 20px; }
.cal__nav .cal__today-btn { width: auto; padding: 0 10px; font-size: 13px; font-weight: 600; }
.cal__dow { display: grid; grid-template-columns: repeat(7,1fr); margin-bottom: 4px; }
.cal__dow span { text-align: center; font-size: 11px; font-weight: 600; color: var(--hint); text-transform: uppercase; }
.cal__grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.cal-legend { display: flex; gap: 16px; justify-content: center; padding: 14px 0 4px; font-size: 12.5px; }
.cal-legend span { display: flex; align-items: center; gap: 6px; }
.daygroup__h { font-size: 13px; font-weight: 600; color: var(--hint); padding: 14px var(--pad) 6px; }
.daysheet__date { font-size: 13px; color: var(--hint); padding: 0 var(--pad) 4px; }
.psearch { display: flex; flex-direction: column; gap: 0; max-height: 200px; overflow-y: auto;
  border: 1px solid var(--hair); border-radius: 10px; margin: 6px 0 0; }
.psearch__item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; width: 100%; text-align: left; background: var(--section-bg); }
.psearch__item + .psearch__item { border-top: 1px solid var(--hair); }
.psearch__item:active { background: var(--press); }
.cell { aspect-ratio: 1 / 1.06; border-radius: 9px; padding: 5px 0 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  position: relative; font-variant-numeric: tabular-nums; }
.cell:active { background: var(--press); }
.cell.is-out { color: color-mix(in srgb, var(--hint) 55%, transparent); }
.cell__n { font-size: 14px; font-weight: 500; }
.cell.is-today .cell__n { background: var(--button); color: var(--button-text);
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; margin-top: -2px; }
.cell.is-sel { background: var(--accent-soft); }
.cell__dots { display: flex; gap: 3px; height: 6px; align-items: center; }
.cdot { width: 6px; height: 6px; border-radius: 50%; }
.cdot--bday { background: var(--mid-color); }
.cdot--task { background: var(--link); }

/* событие (ДР / задача) */
.evrow { display:flex; align-items:center; gap:11px; padding:11px var(--pad);
  background: var(--section-bg); position:relative; width:100%; text-align:left; }
.evrow + .evrow::before { content:''; position:absolute; top:0; left:52px; right:0; border-top:1px solid var(--hair); }
.evrow__ic { width:30px; height:30px; border-radius:8px; flex:none; display:grid; place-items:center; font-size:16px; }
.evrow__ic svg { width: 18px; height: 18px; }
.evrow__ic--bday { background: var(--mid-soft); }
.evrow__ic--task { background: var(--accent-soft); }
.evrow__main { flex:1; min-width:0; }
.evrow__t { font-size:15px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.evrow__s { font-size:12.5px; color: var(--hint); margin-top:1px; }
.evrow__when { font-size:12.5px; color: var(--hint); flex:none; font-variant-numeric:tabular-nums; }

/* ============================================================ Граф */
.graphwrap { position: relative; flex: 1; overflow: hidden; background: var(--secondary-bg); }
.graphwrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.graph__legend { position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 5px;
  background: color-mix(in srgb, var(--section-bg) 88%, transparent); backdrop-filter: blur(8px);
  padding: 9px 11px; border-radius: 10px; font-size: 12px; border: 1px solid var(--hair); }
.graph__legend div { display: flex; align-items: center; gap: 7px; }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; }
.graph__tools { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; }
.graph__tool { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--section-bg); border: 1px solid var(--hair); color: var(--link); }
.graph__tool:active { background: var(--press); }
.graph__tool svg { width: 22px; height: 22px; }
.graph__hint { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 4;
  color: var(--hint); background: color-mix(in srgb, var(--section-bg) 88%, transparent);
  padding: 8px 14px; border-radius: 12px; font-size: 13px; text-align: center; max-width: 88%; pointer-events: none; }

/* карточка узла графа */
.node-card { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 6;
  background: var(--section-bg); border-radius: var(--r); border: 1px solid var(--hair);
  padding: 12px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.18);
  max-height: 52%; overflow-y: auto;
  transform: translateY(160%); transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.node-card.show { transform: translateY(0); }
.node-card__head { display: flex; gap: 12px; align-items: center; }
.node-card__main { flex: 1; min-width: 0; }
.node-card__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-card__sub { font-size: 13px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-card__btn { width: auto; padding: 9px 16px; font-size: 14px; flex: none; }
.node-card__body { display: flex; flex-direction: column; gap: 8px; }
.node-card__body:empty { display: none; }
.node-card__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.node-card__rels { display: flex; flex-direction: column; gap: 5px; }
.node-card__rel { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.node-card__rel-ic { color: var(--link); flex: none; display: inline-flex; }
.node-card__rel-ic svg { width: 15px; height: 15px; }

/* ============================================================ Bottom sheet */
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.4); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .22s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--bg);
  border-radius: 16px 16px 0 0; transform: translateY(100%);
  transition: transform .26s cubic-bezier(.2,.8,.2,1); max-height: 90%; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom); }
.sheet.show { transform: translateY(0); }
.sheet__grip { width: 36px; height: 5px; border-radius: 3px; background: var(--hint);
  opacity: .4; margin: 8px auto 4px; flex: none; }
.sheet__head { display: flex; align-items: center; padding: 6px var(--pad) 10px; gap: 10px; }
.sheet__title { font-size: 18px; font-weight: 700; flex: 1; }
.sheet__close { color: var(--link); font-size: 15px; font-weight: 500; flex: none; }
.sheet__body { overflow-y: auto; padding-bottom: 14px; }

/* ============================================================ Тост */
.toast-host { position: absolute; left: 0; right: 0; bottom: calc(82px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 70; pointer-events: none; }
.toast { background: var(--toast-bg); color: var(--toast-text); padding: 11px 16px; border-radius: 22px;
  font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 9px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); transform: translateY(20px); opacity: 0;
  transition: .26s cubic-bezier(.2,.8,.2,1); max-width: 88%; pointer-events: auto; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast__act { color: var(--toast-act); font-weight: 700; }

/* ============================================================ Пусто / загрузка */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 56px 32px; gap: 6px; }
.empty__ic { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft);
  color: var(--link); display: grid; place-items: center; margin-bottom: 10px; }
.empty__ic svg { width: 32px; height: 32px; }
.empty__t { font-size: 18px; font-weight: 700; }
.empty__s { font-size: 14px; color: var(--hint); max-width: 280px; }
.empty .btn { margin-top: 16px; width: auto; padding: 12px 22px; }
.empty-inline { padding: 40px 28px; }

.sk { background: linear-gradient(90deg, var(--chip-bg) 25%, color-mix(in srgb, var(--text) 11%, transparent) 37%, var(--chip-bg) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite linear; border-radius: 7px; }
@keyframes shimmer { 0%{background-position:100% 0} 100%{background-position:-100% 0} }
.sk-row { display: flex; align-items: center; gap: 12px; padding: 11px var(--pad); }
.sk-circle { width: 40px; height: 40px; border-radius: 50%; flex: none; }

/* утилиты */
.spacer { height: 12px; }
.spacer-lg { height: 28px; }
.count-line { text-align: center; padding: 6px 0 16px; font-size: 12.5px; }
.scn { animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity:1; transform:none; } }

/* ============================================================ Карточка человека (стадия 24) */
.card-top { padding: 16px var(--pad) 12px; }
.card-hd { display: flex; align-items: center; gap: 14px; }
.card-hd__txt { min-width: 0; flex: 1; }
.card-hd__name { font-size: 21px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-hd__sub { font-size: 14px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fact__acts { display: flex; gap: 8px; align-items: center; flex: none; }
.evrow__t.done { text-decoration: line-through; opacity: .5; }
.add-line .line__ic, .add-line .line__label { color: var(--link); }
.add-line:not(:first-child) { border-top: 1px solid var(--hair); }
.chips-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-pick .chip { cursor: pointer; }

/* ============================================================ Формы и общие (сохранённые) классы */
.screen-pad { padding: 12px 16px; animation: fadein 140ms ease; }
h2 { font-size: 20px; margin: 6px 0 12px; }
h3 { font-size: 12px; color: var(--hint); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .06em; }

.input { width: 100%; padding: 11px 12px; margin: 6px 0; border: 1px solid transparent;
  border-radius: 10px; background: var(--secondary-bg); color: var(--text); font-size: 16px; outline: none; }
.input:focus { border-color: var(--link); }
.input::placeholder { color: var(--hint); }
textarea.input { min-height: 84px; resize: vertical; }
select.input { appearance: none; -webkit-appearance: none; }
.input--req { border-color: color-mix(in srgb, var(--stale-color) 50%, transparent); }
.form-label { font-size: 13px; color: var(--hint); margin: 10px 2px 0; }
.bd-row { display: flex; gap: 8px; }
.bd-field { flex: 1; }
.bd-label { font-size: 11px; color: var(--hint); margin: 0 2px 3px; }
.sheet-form { padding: 0 var(--pad); }

/* теги на карточке (.tag-чипы + поле ввода) */
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 0; }
.tag-x { border: none; background: transparent; color: var(--link); font-size: 16px; line-height: 1; cursor: pointer; padding: 0; opacity: .7; }
.tag-input { border: none; border-radius: 20px; background: var(--secondary-bg); color: var(--text); padding: 5px 12px; font-size: 16px; min-width: 92px; }
.tag-input::placeholder { color: var(--hint); }

/* тег-редактор: мультиселект (чипы) + ввод с автодополнением */
.tags-card { padding: 12px var(--pad) 14px; }
.tageditor { display: flex; flex-direction: column; gap: 8px; }
.tageditor__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tageditor__chips:empty { display: none; }
.tageditor__field { position: relative; }
.tageditor__field .tag-input { width: 100%; min-width: 0; padding: 9px 13px; font-size: 16px; border-radius: 12px; }
.tag-suggest:empty { display: none; }
.tag-suggest .psearch { margin: 6px 0 0; }
.tag-suggest .psearch__item { justify-content: space-between; gap: 8px; }
.tag-suggest__count { font-size: 12px; color: var(--hint); font-variant-numeric: tabular-nums; }
.tag-suggest__new { color: var(--link); }
.tag-suggest__new svg { width: 15px; height: 15px; }

/* заголовок секции со знаком «?» (объяснение тегов) */
.gt-help { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }   /* отступ, чтобы «?» не наезжал на чипы */
.gt-help > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.help-btn { width: 18px; height: 18px; border-radius: 50%; background: var(--chip-bg);
  color: var(--hint); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.help-btn:active { background: var(--press); }
.tags-help { padding-top: 4px; }
.tags-help p { font-size: 15px; line-height: 1.5; margin: 0 0 12px; }
.tags-help b { font-weight: 600; }
.fact-act { background: transparent; font-size: 15px; cursor: pointer; padding: 2px; opacity: .75; }
.hint-text { color: var(--hint); padding: 6px 0; font-size: 14px; }

/* ============================================================ Дашборд «Сегодня» */
/* width:auto (не 100%): .group--card даёт горизонтальный margin var(--pad);
   при width:100% кнопка вылезала за вьюпорт на 2×pad (число и стрелка уезжали). */
.dash-cta { display: block; width: auto; text-align: left; padding: 14px var(--pad); }
.dash-cta__row { display: flex; align-items: center; gap: 12px; }
.dash-cta__ic { width: 40px; height: 40px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--link); }
.dash-cta__ic svg { width: 22px; height: 22px; }
.dash-cta__main { flex: 1; min-width: 0; }
.dash-cta__title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-cta__sub { font-size: 13px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-cta__count { font-size: 20px; font-weight: 700; color: var(--link); font-variant-numeric: tabular-nums; flex: none; }
.dash-cta .line__chev { flex: none; }
.dash-cta .progressbar { margin-top: 12px; }

.progressbar { height: 8px; border-radius: 6px; background: var(--chip-bg); overflow: hidden; }
.progressbar__fill { height: 100%; background: var(--fresh-color); border-radius: 6px; transition: width .3s; }

.stat { padding: 14px var(--pad); }
.stat__label { font-size: 12px; color: var(--hint); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.stat__row { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.stat__num { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat__delta { font-size: 12.5px; color: var(--fresh-color); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 42px; margin-top: 12px; }
.spark__bar { flex: 1; min-height: 2px; border-radius: 2px 2px 0 0; background: var(--accent-soft); }
.spark__bar.is-last { background: var(--link); }

.stackbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--chip-bg); margin-top: 10px; }
.stackbar > span { display: block; height: 100%; }
.legrow { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.legrow > div { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.leg-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.cbar { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.cbar__name { font-size: 13px; width: 88px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbar__track { flex: 1; height: 8px; border-radius: 5px; background: var(--chip-bg); overflow: hidden; }
.cbar__fill { height: 100%; background: var(--link); border-radius: 5px; }
.cbar__fill.muted { background: var(--hint); opacity: .5; }
.cbar__val { font-size: 12.5px; color: var(--hint); width: 30px; text-align: right; flex: none; font-variant-numeric: tabular-nums; }

/* чип-переключатель (архив) */
.chip--toggle.is-active { background: var(--accent-soft); color: var(--link); }
.chip--toggle svg { width: 15px; height: 15px; }

/* ============================================================ Режим «Разбор» */
.triage { padding-top: 8px; }
.triage-skipped-note { text-align: center; font-size: 13px; color: var(--hint);
  background: var(--chip-bg); border-radius: 10px; margin: 0 var(--pad) 10px; padding: 8px 12px; }
.triage-person { padding: 18px var(--pad); }
.triage-hd { display: flex; align-items: center; gap: 14px; }
.triage-name { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.triage-meta { font-size: 15px; margin-top: 10px; }
.triage-facts { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.triage-fact { display: flex; gap: 8px; font-size: 14px; align-items: flex-start; }
.triage-enrich { padding: 12px var(--pad); }
.triage-enrich .input { margin: 6px 0 0; }
.triage-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px var(--pad) 0; }
.triage-actions .btn { padding: 16px; }
.triage-keep { background: var(--fresh-color); color: var(--on-button); }
.triage-skip { display: flex; align-items: center; justify-content: center; gap: 6px; width: auto;
  margin: 10px auto 0; padding: 10px 18px; color: var(--hint); font-size: 14px; font-weight: 500; }
.triage-skip svg { width: 18px; height: 18px; }

/* ============================================================ Карточка: фото/оператор/соцсети */
.card-av { position: relative; overflow: visible; }
.av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.av.has-photo { color: transparent; }
.av-cam { position: absolute; top: -2px; right: -2px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--button); color: var(--button-text); display: grid; place-items: center; border: 2px solid var(--section-bg); }
.av-cam svg { width: 13px; height: 13px; }
.op-hint { color: var(--hint); font-size: 13px; font-weight: 400; }
.social-row { align-items: center; }
.social-val { margin-left: auto; color: var(--link); font-size: 15px; max-width: 56%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; text-decoration: none; }
.social-add { margin-left: auto; color: var(--hint); font-size: 14px; opacity: .8; }

/* ============================================================ Связи / как познакомились */
.card-howmet { font-size: 13px; margin-top: 4px; cursor: pointer; line-height: 1.3; }
.card-howmet.is-set { color: var(--hint); }
.card-howmet--add { color: var(--link); opacity: .85; }
.rel-del { background: transparent; color: var(--hint); padding: 6px; flex: none; opacity: .6; }
.rel-del svg { width: 18px; height: 18px; }
.rel-del:active { opacity: 1; }
.rel-chosen { font-size: 13px; color: var(--hint); padding: 8px 2px 2px; }
.rel-chosen.is-set { color: var(--fresh-color); font-weight: 500; }
/* легенда рёбер графа: сплошная (связь) vs пунктир (по компании/тегу) */
.lg-sep { margin-top: 4px; }
.lg-line { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--link); flex: none; }
.lg-line--dash { border-top: 2px dashed var(--hint); }
