/* ============================================================
   CRM каналов — оформление «Студия»: тёплый светлый фон, пастельные плитки, Unbounded для заголовков и цифр,
   Manrope для текста, большие скругления, один коралловый акцент. Тёмная тема — «чернильная» с теми же пастелями.
   Все цвета — переменные ниже; компоненты берут только их.
   ============================================================ */

@import url('/fonts/fonts.css'); /* Unbounded и Manrope, свои файлы (CSP: font-src 'self') */

:root {
  color-scheme: light;
  --bg: #F2F3F8;
  --surface: #FFFFFF;
  --surface-2: #EEF0F6;
  --surface-3: #E3E6EF;
  --border: #E4E7EF;
  --border-strong: #D3D7E3;
  --text: #1E1B2E;
  --text-2: #5E5A70;
  --text-3: #68637A;
  --grid: #E8EBF2;
  --baseline: #CBD0DD;
  --accent: #FF5A36;
  --accent-hover: #F24E2A;
  --accent-press: #C93E1F;
  --accent-text: #B42F18;
  --accent-soft: rgba(255, 90, 54, 0.12);
  --ink: #1E1B2E;
  --on-ink: #FFFFFF;
  --highlight: #B9A8FF;   /* сиреневый вместо жёлтого: бейджи, активный пункт меню */
  --on-highlight: #2A1F66;
  --good-text: #0F6B3D;
  --bad-text: #B42F18;
  --warn-text: #9A6400;
  --st-good: #2DB36F;
  --st-warning: #F5B700;
  --st-critical: #E5484D;
  /* насыщенные — графики и точки этапов (ключи прежние, чтобы не трогать данные этапов) */
  --c-blue: #2E9BFF;
  --c-orange: #FF5A36;
  --c-aqua: #1FB5A5;
  --c-yellow: #F5B700;
  --c-magenta: #FF6FAE;
  --c-green: #2DB36F;
  --c-violet: #8C6CFF;
  --c-red: #E5484D;
  --c-gray: #9C97A8;
  --f1: #8C6CFF;
  --f2: #FF5A36;
  --f3: #2DB36F;
  /* пастели: заливка и текст на ней (контраст ≥ 4.5) */
  --p-mint: #C9F2D9;   --p-mint-text: #0E5E36;
  --p-lilac: #E3DBFF;  --p-lilac-text: #43308F;
  --p-peach: #FFE4D6;  --p-peach-text: #8A3A0E;
  --p-sky: #D6EEFF;    --p-sky-text: #0D4F80;
  --p-butter: #D4F1EE; --p-butter-text: #0B5753; /* бывший жёлтый — бирюзовый */
  --p-rose: #FFD6CC;   --p-rose-text: #8F2410;
  --p-sand: #E9EBF2;   --p-sand-text: #4F4B60;
  --shadow: 0 1px 2px rgba(30, 27, 46, 0.04), 0 6px 20px rgba(30, 27, 46, 0.06);
  --shadow-lg: 0 18px 50px rgba(30, 27, 46, 0.18);
  --radius: 24px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --radius-xs: 10px;
  --sidebar-w: 236px;
  --font: 'Manrope', "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: 'Unbounded', 'Manrope', "Segoe UI", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15131F;
  --surface: #1E1B2E;
  --surface-2: #252237;
  --surface-3: #2E2A44;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #F6F3FF;
  --text-2: #BDB7D3;
  --text-3: #9C96B6;
  --grid: #2E2A44;
  --baseline: #3A3552;
  --accent: #FF6A4A;
  --accent-hover: #FF7C5F;
  --accent-press: #B83A1E;
  --accent-text: #FF8E73;
  --accent-soft: rgba(255, 106, 74, 0.16);
  --ink: #F6F3FF;
  --on-ink: #1E1B2E;
  --highlight: #B9A8FF;
  --on-highlight: #1E1B2E;
  --good-text: #5FD99A;
  --bad-text: #FF8A73;
  --warn-text: #FFD166;
  --c-blue: #4DAAFF;
  --c-orange: #FF6A4A;
  --c-aqua: #36CDBC;
  --c-yellow: #FFC93C;
  --c-magenta: #FF85BC;
  --c-green: #3FCB83;
  --c-violet: #A28BFF;
  --c-red: #FF6B6F;
  --c-gray: #8F89A8;
  --f1: #A28BFF;
  --f2: #FF6A4A;
  --f3: #3FCB83;
  --p-mint: #173B2A;   --p-mint-text: #8EE6B4;
  --p-lilac: #2A2350;  --p-lilac-text: #C5B8FF;
  --p-peach: #3D2618;  --p-peach-text: #FFC29A;
  --p-sky: #14304A;    --p-sky-text: #9FD3FF;
  --p-butter: #133836; --p-butter-text: #8FE3DA;
  --p-rose: #3E1E1A;   --p-rose-text: #FFB3A3;
  --p-sand: #2E2A44;   --p-sand-text: #CFC9E3;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--p-butter); color: var(--p-butter-text); }
a { color: var(--accent-text); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { flex-shrink: 0; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
h1 { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 16px; line-height: 1.3; font-weight: 500; }
h3 { font-size: 14.5px; font-weight: 500; }
p { text-wrap: pretty; }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.good { color: var(--good-text); }
.bad { color: var(--bad-text); }
.warn { color: var(--warn-text); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
:is(.table-wrap, .kanban, .menu, .modal-body) { scrollbar-width: thin; }

/* ---------------- каркас ---------------- */
/* --zoom — размер интерфейса (CSS zoom): высоты «во весь экран» делим на него, иначе при 125 % низ панели уезжал бы за экран. */
.app { position: relative; z-index: 1; display: flex; min-height: calc(100vh / var(--zoom, 1)); }
/* фон с деталями: мелкая точечная сетка, сходящая на нет к низу экрана */
body::before { content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgba(30, 27, 46, .1) 1px, transparent 1.3px); background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, rgba(0, 0, 0, .5) 50%, rgba(0, 0, 0, .35) 100%);
  mask-image: linear-gradient(to bottom, #000 0, rgba(0, 0, 0, .5) 50%, rgba(0, 0, 0, .35) 100%); }
:root[data-theme="dark"] body::before { background-image: radial-gradient(rgba(255, 255, 255, .06) 1px, transparent 1.3px); }
.sidebar {
  position: sticky; top: 0; height: calc(100vh / var(--zoom, 1));
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  display: flex; flex-direction: column; gap: 6px;
  padding: 24px 16px 18px; background: transparent;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 22px; font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand-logo { width: 36px; height: 36px; border-radius: 12px; background: #1E1B2E; display: grid; place-items: center; color: var(--highlight); }
:root[data-theme="dark"] .brand-logo { background: var(--surface-3); }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text b { font-size: 17px; font-weight: 700; }
.brand-text small { margin-top: 4px; font-family: var(--font); font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.nav { position: relative; display: flex; flex-direction: column; gap: 3px; }
.nav a {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-radius: var(--radius-md);
  color: var(--text-2); font-weight: 650; text-decoration: none; transition: background-color 140ms ease, color 140ms ease;
}
.nav a svg { color: var(--text-3); transition: color 140ms ease; }
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--ink); color: var(--on-ink); }
.nav a.active svg { color: var(--highlight); }
:root[data-theme="dark"] .nav a.active svg { color: var(--accent); }
.nav .count {
  margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 10px; text-align: center;
  background: var(--highlight); color: var(--on-highlight); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
/* Бегунок активного раздела (motion.js): тёмная «таблетка» переезжает к новому пункту. */
.nav-ind { position: absolute; left: 0; right: 0; top: 0; z-index: 0; border-radius: var(--radius-md); background: var(--ink); transition: transform 240ms var(--ease-in-out); }
.nav.has-ind a.active, .nav.has-ind a.active:hover { background: transparent; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 2px; }
.sync-box, .user-box { font-size: 12.5px; color: var(--text-3); padding: 12px 13px; border-radius: var(--radius-md); background: var(--surface); border: 2px solid var(--border); line-height: 1.45; }
.sync-box b { color: var(--text); font-weight: 700; }
.sync-box .bad { display: block; margin-top: 4px; }
.theme-switch { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-3); }
.theme-switch button {
  flex: 1; display: grid; place-items: center; height: 30px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-3); cursor: pointer; transition: background-color 140ms ease, color 140ms ease;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(30, 27, 46, .12); }

.main { flex: 1; min-width: 0; padding: 28px 32px 56px 12px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--text-2); margin-top: 6px; font-weight: 600; }

/* «Экран»: заголовок страницы — тёмно-синяя светящаяся шапка с точками; на дашборде, в экономике и монетизации
   плитки заходят на неё снизу. Шапка — фон самого блока, поэтому подстраивается под высоту на любой странице. */
.page-head, .ch-head {
  position: relative; isolation: isolate; overflow: hidden;
  padding: 26px 28px 24px; border-radius: 28px; color: #fff;
  background:
    radial-gradient(60% 140% at 8% 0%, rgba(140, 108, 255, .55), transparent 62%),
    radial-gradient(50% 140% at 96% 0%, rgba(46, 155, 255, .42), transparent 60%),
    radial-gradient(45% 110% at 62% 128%, rgba(31, 181, 165, .32), transparent 62%),
    linear-gradient(135deg, #1B1840 0%, #231E57 55%, #19284F 100%);
  box-shadow: 0 18px 44px rgba(27, 24, 64, .22);
}
.page-head::before, .ch-head::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .17) 1px, transparent 1.3px); background-size: 18px 18px;
  -webkit-mask-image: linear-gradient(100deg, #000 0%, rgba(0, 0, 0, .3) 55%, #000 100%);
  mask-image: linear-gradient(100deg, #000 0%, rgba(0, 0, 0, .3) 55%, #000 100%);
}
.page-head h1, .ch-head h1 { color: #fff; }
.page-head .sub, .ch-head .muted, .ch-head .ch-head-meta { color: rgba(255, 255, 255, .76); }
.ch-head .ch-head-meta a { color: #fff; }
:is(.page-head, .ch-head) .btn:not(.btn-primary) { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .26); color: #fff; }
:is(.page-head, .ch-head) .btn:not(.btn-primary):hover { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .4); }
:is(.page-head, .ch-head) .segmented { background: rgba(255, 255, 255, .12); }
:is(.page-head, .ch-head) .segmented button { color: rgba(255, 255, 255, .82); }
:is(.page-head, .ch-head) .segmented button:hover { color: #fff; }
:is(.page-head, .ch-head) .segmented button.on { background: #fff; color: #1E1B2E; }
:is(.page-head, .ch-head) :focus-visible { outline-color: #fff; }
.page-head:has(+ .tiles) { padding-bottom: 72px; margin-bottom: 0; }
.page-head + .tiles { position: relative; z-index: 1; margin-top: -54px; padding: 0 20px; }
:root[data-theme="dark"] :is(.page-head, .ch-head) { box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 18px 44px rgba(0, 0, 0, .4); }
@media (max-width: 640px) {
  .page-head, .ch-head { padding: 20px 18px; border-radius: 22px; }
  .page-head:has(+ .tiles) { padding-bottom: 62px; }
  .page-head + .tiles { margin-top: -46px; padding: 0 10px; }
}
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------- карточки и сетка ---------------- */
.card {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 28px; }
.card-head .hint { font-size: 12.5px; color: var(--text-3); font-weight: 600; }
/* Телефон: заголовок и переключатель не сжимают друг друга — переключатель уходит строкой ниже и прокручивается */
@media (max-width: 560px) {
  .card-head { flex-wrap: wrap; }
  .card-head > .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
}
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
@media (max-width: 1180px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
}

/* ---------------- плитки KPI: пастель по порядку ---------------- */
/* Колонок столько, сколько влезает плиток не уже 160px: от ширины самой страницы, а не окна —
   так крупный масштаб интерфейса (CSS zoom) тоже даёт меньше колонок, и цифры не обрезаются. */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 14px; margin-bottom: 16px; }
.tile {
  --tile: var(--p-mint); --tile-text: var(--p-mint-text);
  position: relative; overflow: hidden; background: var(--tile); color: var(--tile-text);
  border-radius: var(--radius); padding: 16px 18px 18px; min-width: 0; container-type: inline-size;
}
.tiles > .tile:nth-child(6n+2) { --tile: var(--p-lilac); --tile-text: var(--p-lilac-text); }
.tiles > .tile:nth-child(6n+3) { --tile: var(--p-peach); --tile-text: var(--p-peach-text); }
.tiles > .tile:nth-child(6n+4) { --tile: var(--p-sky); --tile-text: var(--p-sky-text); }
.tiles > .tile:nth-child(6n+5) { --tile: var(--p-butter); --tile-text: var(--p-butter-text); }
.tiles > .tile:nth-child(6n+6) { --tile: var(--p-rose); --tile-text: var(--p-rose-text); }
.tile-label { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
/* Unbounded широкий: крупная цифра уменьшается под ширину плитки, а не обрезается */
.tile-value {
  font-family: var(--font-display); font-size: clamp(18px, 15cqi, 30px); font-weight: 700; letter-spacing: -0.035em;
  margin-top: 6px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tile-delta { font-size: 12.5px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.tile-sub { font-size: 12.5px; margin-top: 3px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; opacity: .9; }
.tile .muted { color: inherit; opacity: .85; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.delta.up-good, .delta.down-good { color: var(--good-text); }
.delta.up-bad, .delta.down-bad { color: var(--bad-text); }
.delta.flat { color: var(--text-3); }

/* ---------------- кнопки ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: var(--radius-md); border: 2px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background-color 140ms ease, border-color 140ms ease, transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.btn:hover { background: var(--surface-2); border-color: var(--baseline); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-press); margin-bottom: 4px; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-press); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--bad-text); }
.btn-danger-fill { background: var(--st-critical); border-color: var(--st-critical); color: #fff; }
.btn-danger-fill:hover { background: #cf3a3f; border-color: #cf3a3f; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-sm.btn-primary { box-shadow: 0 3px 0 var(--accent-press); margin-bottom: 3px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn .spin, .spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--surface-3); }
.btn-group .btn { height: 32px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); }
.btn-group .btn:hover { color: var(--text); background: transparent; }
.btn-group .btn.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(30, 27, 46, .12); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-text); cursor: pointer; font-weight: 700; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------------- поля ввода ---------------- */
.input, .select, .textarea {
  height: 40px; width: 100%; padding: 0 13px; border-radius: var(--radius-md);
  border: 2px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.textarea { height: auto; min-height: 84px; padding: 9px 13px; resize: vertical; line-height: 1.5; font-weight: 500; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: .8; font-weight: 500; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--baseline); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.num-input { text-align: right; font-variant-numeric: tabular-nums; }
.select { padding-right: 32px; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 37px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field .help { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.input-affix { position: relative; }
.input-affix .affix { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; font-size: 13px; font-weight: 700; }
.input-affix .input { padding-right: 30px; }

/* ---------------- бейджи, чипы ---------------- */
/* Бейдж этапа: заливка — светлый тон цвета этапа, текст — тёмный (в тёмной теме — светлый) того же цвета. */
.badge {
  --dot: var(--c-gray);
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
  padding: 3px 11px 3px 9px; border-radius: var(--radius-xs); font-size: 12.5px; font-weight: 700; line-height: 20px;
  background: color-mix(in srgb, var(--dot) 18%, var(--surface)); color: color-mix(in srgb, var(--dot) 30%, var(--text)); white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--dot); flex: 0 0 8px; }
button.badge { border: 0; cursor: pointer; transition: background-color 140ms ease; }
button.badge:hover { background: color-mix(in srgb, var(--dot) 30%, var(--surface)); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--dot, var(--c-gray)); flex: 0 0 9px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  --dot: transparent;
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; font-weight: 700; font-size: 13px;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip .n { color: var(--text-3); font-variant-numeric: tabular-nums; font-weight: 700; }
.chip.on .n { color: var(--highlight); }
:root[data-theme="dark"] .chip.on .n { color: var(--accent-press); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 8px; background: var(--p-sand); color: var(--p-sand-text); font-size: 12px; font-weight: 700; }
.kind { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; }
.kind svg { color: var(--text-3); }

/* ---------------- аватары ---------------- */
.avatar {
  display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 34%; overflow: hidden;
  background: var(--p-lilac); color: var(--p-lilac-text); font-weight: 800; text-transform: uppercase; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ch-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.ch-cell .ch-name { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-cell .ch-meta { font-size: 12px; color: var(--text-3); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-cell .ch-text { min-width: 0; display: flex; flex-direction: column; }
a.ch-cell:hover { text-decoration: none; }
a.ch-cell:hover .ch-name { color: var(--accent-text); }

/* ---------------- таблицы ---------------- */
.table-wrap { overflow-x: auto; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 700; font-size: 12.5px;
  color: var(--text-3); padding: 13px 14px 11px; border-bottom: 2px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { border-top: 2px solid var(--border); border-bottom: 0; font-weight: 800; background: var(--surface-2); }
.table .r { text-align: right; }
.table .c { text-align: center; }
.table tbody tr { transition: background-color 120ms ease; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td, .table tbody tr.selected td { background: var(--surface-2); }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ic { display: inline-block; vertical-align: -2px; margin-left: 2px; opacity: .9; }
.table .sub-line { display: block; font-size: 12px; color: var(--text-3); line-height: 1.35; font-weight: 600; }
.table .col-check { width: 36px; padding-right: 0; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .12s; }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }
.table.compact td { padding: 9px 12px; }
.table.compact th { padding: 10px 12px 9px; }
.card .table-wrap { border: 0; border-radius: 0; margin: 0 -22px -20px; background: transparent; }
.card .table th { background: var(--surface); }
.card .table th:first-child, .card .table td:first-child { padding-left: 22px; }
.card .table th:last-child, .card .table td:last-child { padding-right: 22px; }

/* ---------------- пустые состояния, плашки ---------------- */
.empty { text-align: center; padding: 40px 16px; color: var(--text-2); font-weight: 500; }
.empty .empty-ic { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; background: var(--p-peach); color: var(--p-peach-text); }
.empty h3 { font-size: 17px; color: var(--text); margin-bottom: 8px; font-weight: 600; }
.empty p { margin: 0 auto 18px; max-width: 460px; }
.empty .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.empty.small { padding: 22px 12px; }
.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 13px 16px; margin-bottom: 16px; font-weight: 600;
  border-radius: 18px; border: 0; background: var(--p-sand); color: var(--p-sand-text);
}
.banner.info { background: var(--p-sky); color: var(--p-sky-text); }
.banner.warn { background: var(--p-butter); color: var(--p-butter-text); }
.banner.error { background: var(--p-rose); color: var(--p-rose-text); }
.banner b { color: inherit; }
.banner .grow { flex: 1; min-width: 200px; }
.banner svg.lead { color: inherit; }
.banner .btn:not(.btn-primary) { background: rgba(255, 255, 255, .7); border-color: transparent; color: var(--text); }
:root[data-theme="dark"] .banner .btn:not(.btn-primary) { background: rgba(255, 255, 255, .08); }

/* ---------------- всплывающие меню ---------------- */
.menu {
  position: fixed; z-index: 1000; min-width: 200px; max-width: 320px; max-height: min(420px, calc(70vh / var(--zoom, 1))); overflow: auto;
  padding: 6px; border-radius: 18px; border: 2px solid var(--border); background: var(--surface); box-shadow: var(--shadow-lg);
  animation: pop-in 150ms var(--ease-out);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); text-align: left; cursor: pointer; font-size: 13.5px; font-weight: 600;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.danger { color: var(--bad-text); }
.menu-item .check-ic { margin-left: auto; color: var(--accent-text); }
.menu-item svg:first-child { color: var(--text-3); }
.menu-sep { height: 2px; background: var(--border); margin: 5px 4px; }
.menu-title { padding: 7px 11px 4px; font-size: 12px; color: var(--text-3); font-weight: 700; }
.menu-body { padding: 6px 8px 8px; }

/* ---------------- модальные окна ---------------- */
dialog.modal {
  width: min(560px, calc(100vw / var(--zoom, 1) - 32px)); max-height: calc(100vh / var(--zoom, 1) - 48px); padding: 0; border: 0;
  max-height: calc(100dvh / var(--zoom, 1) - 48px); /* на телефоне — по видимой части экрана, без панелей браузера */
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; animation: pop-in 180ms var(--ease-out);
}
dialog.modal:not([open]) { display: none; }
dialog.modal.wide { width: min(1240px, calc(100vw / var(--zoom, 1) - 32px)); }
dialog.modal.mid { width: min(760px, calc(100vw / var(--zoom, 1) - 32px)); }
dialog.modal::backdrop { background: rgba(30, 27, 46, 0.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 12px; }
.modal-head h2 { font-size: 18px; font-weight: 600; }
/* flex: 1 1 auto, а не flex: 1 — в Safari середина окна с основой 0 % сжималась до нуля (видны только заголовок и низ окна) */
.modal-body { padding: 4px 24px 18px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 24px 18px; border-top: 2px solid var(--border); }
.modal-foot .left { margin-right: auto; }
@media (max-width: 560px) {
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
}
.modal-error { color: var(--bad-text); font-size: 13px; font-weight: 700; margin-top: 10px; }
.modal-error:empty { display: none; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--surface-3); }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text-2); font-weight: 700; cursor: pointer; transition: background-color 140ms ease, color 140ms ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(30, 27, 46, .12); }

/* ---------------- уведомления ---------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; max-width: 440px; padding: 12px 16px;
  border-radius: 16px; background: #1E1B2E; color: #fff; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 600;
  animation: toast-in .2s var(--ease-out);
}
:root[data-theme="dark"] .toast { background: #F6F3FF; color: #1E1B2E; }
.toast svg { margin-top: 1px; }
.toast.success svg { color: #5FD99A; }
.toast.error svg { color: #FF8A73; }
.toast.info svg { color: #9FD3FF; }
:root[data-theme="dark"] .toast.success svg { color: #13804A; }
:root[data-theme="dark"] .toast.error svg { color: #D63A1E; }
:root[data-theme="dark"] .toast.info svg { color: #0D4F80; }
.toast button { margin-left: 6px; border: 0; background: var(--highlight); color: #1E1B2E; font-weight: 800; cursor: pointer; padding: 2px 9px; border-radius: 8px; }
.toast.leaving { opacity: 0; transform: translateY(100%); pointer-events: none; transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------------- подсказка графиков ---------------- */
.tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; padding: 10px 12px; border-radius: 14px;
  background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow); font-size: 12.5px; font-weight: 600;
}
.tip-title { color: var(--text-3); margin-bottom: 5px; font-size: 12px; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.65; }
.tip-row .key { width: 12px; height: 4px; border-radius: 2px; background: var(--k); }
.tip-row b { font-weight: 800; font-variant-numeric: tabular-nums; }
.tip-row .lbl { color: var(--text-2); }
.tip-row.total { border-top: 2px solid var(--border); margin-top: 4px; padding-top: 4px; }

/* ---------------- появление страницы (motion.js ставит .enter только при переходе) ---------------- */
.main.enter :is(.page-head, .ch-head, .back-link, .toolbar, .status-chips, .info-chips, .tiles > *, .kanban, .settings > section, .grid > *, .help > *, .banner) {
  animation: rise 420ms var(--ease-out) both;
}
.main.enter .tiles > :nth-child(2) { animation-delay: 40ms; }
.main.enter .tiles > :nth-child(3) { animation-delay: 80ms; }
.main.enter .tiles > :nth-child(4) { animation-delay: 120ms; }
.main.enter .tiles > :nth-child(5) { animation-delay: 160ms; }
.main.enter .tiles > :nth-child(6) { animation-delay: 200ms; }
.main.enter .grid > :nth-child(n+2) { animation-delay: 120ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

/* ---------------- адаптив ---------------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    position: sticky; top: 0; z-index: 50; height: auto; width: 100%; flex: none; flex-direction: row; align-items: center;
    padding: 8px 12px; border-bottom: 2px solid var(--border); overflow-x: auto; background: var(--bg);
  }
  .brand { padding: 0 8px 0 0; }
  .brand span, .brand-text { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 8px 12px; }
  .nav .count { display: none; }
  .nav-ind { display: none; }
  .nav.has-ind a.active, .nav.has-ind a.active:hover { background: var(--ink); }
  .sidebar-foot { display: none; }
  .main { padding: 18px 16px 40px; }
  h1 { font-size: 24px; }
}
