/* ==========================================================================
   Горизонт CRM — интерфейс на дизайн-токенах сайта okna-gorizont.ru
   (tokens.css и fonts.css скопированы с сайта без изменений).
   Плотнее, чем сайт: рабочий инструмент, а не витрина.
   ========================================================================== */

:root {
  --sidebar-w: 248px;
  --topbar-h: 68px;
  --warn-bg: #fdf3dc;
  --warn-ink: #7a5310;
  --danger-bg: #fbe6e1;
  --ok-bg: #e3f1ea;
  --canvas: var(--sand-50);
  --ok-ink: #2d6a4f;
  --danger-ink: #8a3420;
  --violet-bg: #efe7f7;
  --violet-ink: #5e3d86;
  --topbar-bg: rgba(250, 248, 245, .88);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--navy-700); }
p { margin: 0; }
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h1 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.125rem); letter-spacing: -0.03em; }
h2 { font-size: 1.125rem; }
h3 { font-size: 0.9375rem; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-200); color: var(--ink); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, .money, td.money, th.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.money, th.money { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.ink { color: var(--ink); }
.danger-text { color: var(--danger); }
.ok-text { color: var(--success); }
.nowrap { white-space: nowrap; }

.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- Подпись в скобках, как на сайте: [ РАБОЧИЙ СТОЛ ] ------------------ */
.eyebrow {
  display: inline-flex; align-items: center; gap: .5em;
  font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-600);
}
.eyebrow::before { content: "["; font-weight: 400; color: var(--accent-400); }
.eyebrow::after { content: "]"; font-weight: 400; color: var(--accent-400); }
.on-dark .eyebrow { color: var(--accent-400); }

/* --- Каркас ------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px 18px;
  background: var(--grad-navy);
  color: var(--on-dark);
  overflow-y: auto;
  z-index: 40;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 6px; }
.sidebar__brand img { width: 150px; height: auto; }
.sidebar__tag { font-size: .6875rem; letter-spacing: .14em; text-transform: uppercase; color: var(--on-dark-muted); padding: 0 10px; margin-top: -14px; }
.nav { display: grid; gap: 2px; }
.nav__link {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--on-dark-muted); font-weight: 500;
  transition: background-color .2s, color .2s;
}
.nav__link .icon { width: 20px; height: 20px; }
.nav__link:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav__link[aria-current="page"] { color: #fff; background: rgba(255,255,255,.09); }
.nav__link[aria-current="page"]::before {
  content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--grad-accent);
}
.nav__link[aria-current="page"] .icon { color: var(--accent-400); }
.nav__badge {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-pill);
  display: inline-grid; place-items: center; font-size: .75rem; font-weight: 600;
  background: var(--accent-600); color: #fff;
}
.nav__badge--soft { background: rgba(255,255,255,.14); }
.nav__sep { height: 1px; background: var(--line-dark); margin: 6px 10px; }
.sidebar__user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px 0; border-top: 1px solid var(--line-dark); }
.sidebar__user b { display: block; color: #fff; font-weight: 600; font-size: .875rem; }
.sidebar__user a { color: var(--on-dark-muted); font-size: .8125rem; }
.sidebar__user a:hover { color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  min-height: var(--topbar-h); padding: 12px clamp(16px, 2.4vw, 32px);
  background: var(--topbar-bg); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-warm);
}
.btn.topbar__burger { display: none; }
.search { position: relative; flex: 1; max-width: 560px; }
.search .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input {
  width: 100%; height: 44px; padding: 0 18px 0 44px;
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}
.search input:focus { outline: none; border-color: var(--blue-300); box-shadow: 0 0 0 4px var(--blue-100); }
.topbar__actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.content { padding: clamp(18px, 2.4vw, 32px); width: 100%; max-width: 1680px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head__title { display: grid; gap: 8px; }
.page-head__title p { color: var(--muted); }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --- Кнопки (как на сайте: «таблетки») ------------------------------------ */
.btn {
  --h: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--h); padding: 0 20px; border-radius: var(--r-pill);
  border: 1px solid transparent; background: none; cursor: pointer;
  font-weight: 600; font-size: .9rem; line-height: 1.1; white-space: nowrap; text-decoration: none;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background-color .2s, color .2s, border-color .2s;
}
.btn .icon { width: 18px; height: 18px; }
.btn--accent { background: var(--grad-accent); color: #fff; box-shadow: var(--shadow-accent); }
.btn--accent:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(208,101,61,.65); }
.btn--navy { background: var(--navy-900); color: #fff; }
.btn--navy:hover { background: var(--navy-700); color: #fff; }
.btn--outline { border-color: var(--line); background: var(--surface); color: var(--ink); }
.btn--outline:hover { border-color: var(--ink); color: var(--ink); }
.btn--soft { background: var(--blue-50); color: var(--blue-600); }
.btn--soft:hover { background: var(--blue-100); color: var(--navy-700); }
.btn--danger { border-color: var(--line); background: var(--surface); color: var(--danger); }
.btn--danger:hover { border-color: var(--danger); color: var(--danger); }
.btn--ghost { border-color: rgba(255,255,255,.3); color: #fff; background: rgba(255,255,255,.06); }
.btn--ghost:hover { background: rgba(255,255,255,.14); color: #fff; }
.btn--link { --h: auto; padding: 0; color: var(--blue-600); font-weight: 600; }
.btn--link:hover { color: var(--navy-700); }
.btn--sm { --h: 36px; padding: 0 14px; font-size: .8125rem; }
.btn--xs { --h: 30px; padding: 0 11px; font-size: .75rem; }
.btn--icon { padding: 0; width: var(--h); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* --- Панели ------------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); min-width: 0; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.panel__body { padding: 16px 20px 20px; }
.panel__body--flush { padding: 8px 0 0; }
.panel--warm { background: var(--sand-100); border-color: var(--line-warm); box-shadow: none; }
.panel + .panel { margin-top: 16px; }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr); gap: 20px; align-items: start; }

/* --- Чипы и бейджи ------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 2px 10px;
  border-radius: var(--r-pill); font-size: .75rem; font-weight: 600; line-height: 1.3; white-space: nowrap;
  background: var(--blue-100); color: var(--navy-700);
}
.chip--accent { background: var(--accent-100); color: var(--accent-700); }
.chip--green { background: var(--ok-bg); color: var(--ok-ink); }
.chip--amber { background: var(--warn-bg); color: var(--warn-ink); }
.chip--violet { background: var(--violet-bg); color: var(--violet-ink); }
.chip--gray { background: var(--sand-200); color: var(--text); }
.chip--danger { background: var(--danger-bg); color: var(--danger-ink); }
.chip--outline { background: transparent; border: 1px solid var(--line); color: var(--text); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.avatar {
  --c: var(--blue-600);
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: var(--c);
  font-size: .6875rem; font-weight: 700; letter-spacing: .02em;
}
.avatar--lg { width: 38px; height: 38px; font-size: .8125rem; }
.sidebar .avatar { background: rgba(255,255,255,.12); color: #fff; }

/* --- Формы ---------------------------------------------------------------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field__label { font-size: .8125rem; font-weight: 600; color: var(--ink); }
.field__hint { font-size: .75rem; color: var(--muted); }
.field__error { font-size: .8125rem; color: var(--danger); font-weight: 500; }
.input, .select, .textarea, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  transition: border-color .2s, box-shadow .2s;
}
.field textarea, .textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue-300); box-shadow: 0 0 0 4px var(--blue-100);
}
.field--error input, .field--error select, .field--error textarea { border-color: var(--danger); }
.input--sm, .select--sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row > .field { flex: 1 1 140px; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.check { display: inline-flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: .875rem; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent-600); flex: none; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 36px; }
.input-suffix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.form-errors { padding: 12px 16px; border-radius: var(--r-sm); background: var(--danger-bg); color: var(--danger-ink); font-size: .875rem; margin-bottom: 14px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-sm); font-size: .875rem; background: var(--blue-50); color: var(--navy-700); }
.notice .icon { margin-top: 1px; }
.notice--warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice--danger { background: var(--danger-bg); color: var(--danger-ink); }
.notice--ok { background: var(--ok-bg); color: var(--ok-ink); }
.notice + .notice { margin-top: 8px; }

/* --- Сегменты и вкладки --------------------------------------------------- */
.segmented { display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--r-pill); background: var(--sand-200); }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 14px; border-radius: var(--r-pill);
  border: 0; background: none; cursor: pointer; font-size: .8125rem; font-weight: 600; color: var(--text); white-space: nowrap;
}
.segmented .icon { width: 16px; height: 16px; }
.segmented [aria-current="true"], .segmented [aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.on-dark .segmented { background: rgba(255,255,255,.08); }
.on-dark .segmented a { color: var(--on-dark-muted); }
.on-dark .segmented [aria-current="true"] { background: rgba(255,255,255,.95); color: var(--navy-900); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button, .tabs a {
  position: relative; min-height: 44px; padding: 0 14px; border: 0; background: none; cursor: pointer;
  font-weight: 600; font-size: .875rem; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.tabs [aria-selected="true"] { color: var(--ink); }
.tabs [aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--grad-accent); }

/* --- Фильтры ------------------------------------------------------------ */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 10px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.toolbar .input, .toolbar .select { min-height: 38px; padding: 6px 12px; font-size: .875rem; width: auto; }
.toolbar .input[type=search] { flex: 1 1 200px; min-width: 160px; }
.toolbar__spacer { flex: 1; }
.toolbar details { position: relative; }
.toolbar summary { list-style: none; }
.toolbar summary::-webkit-details-marker { display: none; }
.dropdown {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 260px; max-height: 340px; overflow: auto;
  padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-md);
  display: grid; gap: 6px;
}

/* --- Таблицы -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  text-align: left; padding: 10px 14px; font-size: .75rem; font-weight: 600; letter-spacing: .02em; color: var(--muted);
  background: var(--sand-50); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:hover td { background: var(--sand-50); }
.table tfoot td { font-weight: 600; color: var(--ink); background: var(--sand-100); border-bottom: 0; }
.table .row-link { color: var(--ink); font-weight: 600; }
.table .row-link:hover { color: var(--blue-600); }
.table--compact td { padding: 8px 12px; }
.table tr.is-reversed td { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(98,112,130,.5); }
.table tr.is-reversal td { color: var(--muted); }

/* --- Канбан --------------------------------------------------------------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(272px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: start; scroll-snap-type: x proximity; }
.lane { display: flex; flex-direction: column; min-height: 220px; scroll-snap-align: start; }
.lane__head { padding: 2px 4px 10px; margin-bottom: 10px; border-bottom: 3px solid var(--stage, var(--blue-300)); }
.lane__title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lane__title h2 { font-size: 1rem; }
.lane__count { font-size: .8125rem; color: var(--muted); font-weight: 600; }
.lane__sum { font-size: .8125rem; color: var(--muted); margin-top: 2px; }
.lane__body { display: grid; gap: 8px; min-height: 120px; padding: 2px; border-radius: var(--r-sm); align-content: start; }
.lane__body.is-over { background: var(--blue-50); }
.lane--closed .lane__body { opacity: .92; }
.lane__more { text-align: center; font-size: .8125rem; padding: 6px; }

.card {
  position: relative; display: grid; gap: 6px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm); cursor: grab;
  transition: border-color .2s, box-shadow .2s, transform .2s var(--ease);
}
.card:hover { border-color: var(--blue-300); box-shadow: var(--shadow-md); }
.card.sortable-ghost { opacity: .35; }
.card.sortable-chosen { cursor: grabbing; }
.card__top { display: flex; justify-content: space-between; gap: 8px; font-size: .8125rem; color: var(--muted); }
.card__client { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__title { color: var(--blue-600); font-weight: 500; line-height: 1.35; }
.card__title::after { content: ""; position: absolute; inset: 0; }
.card__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .8125rem; }
.card__price { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.card__idle { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .75rem; }
.card__idle::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.card__idle--warn::before { background: var(--star); }
.card__idle--bad { color: var(--danger); }
.card__idle--bad::before { background: var(--danger); }
.card__when { display: inline-flex; gap: 5px; align-items: center; font-size: .75rem; color: var(--accent-700); font-weight: 600; }
.card__when .icon { width: 14px; height: 14px; }
.card .chips { position: relative; z-index: 1; }

.quick-add { padding: 12px; border: 1px dashed var(--blue-300); border-radius: var(--r-sm); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.quick-add summary { cursor: pointer; list-style: none; font-weight: 600; color: var(--blue-600); font-size: .875rem; display: flex; justify-content: center; align-items: center; gap: 6px; }
.quick-add summary .icon { width: 16px; height: 16px; }
.quick-add summary::-webkit-details-marker { display: none; }
.quick-add form { display: grid; gap: 8px; margin-top: 10px; }
.quick-add .input, .quick-add .select { min-height: 38px; padding: 6px 12px; font-size: .875rem; }

/* --- Рабочий стол: тёмная панель с фото, как первый экран сайта ------------ */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  border-radius: var(--r-lg); padding: clamp(22px, 3vw, 34px); margin-bottom: 20px;
  color: var(--on-dark); background: var(--navy-950);
}
.hero__media { position: absolute; inset: 0; z-index: -2; background: url("../img/hero.1587632b7e73.webp") center 40% / cover no-repeat; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(15,29,46,.94) 0%, rgba(15,29,46,.78) 50%, rgba(15,29,46,.5) 100%),
              linear-gradient(0deg, rgba(15,29,46,.8) 0%, transparent 60%);
}
.hero__top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.hero h1 { color: #fff; margin-top: 8px; }
.hero h1 em { font-style: normal; color: var(--accent-400); }
.hero__lead { color: var(--on-dark-muted); margin-top: 6px; }
.stages { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(112px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.stage-tile {
  display: grid; gap: 2px; padding: 14px 14px 12px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.06); border: 1px solid var(--line-dark); color: var(--on-dark);
  backdrop-filter: blur(6px); transition: background-color .2s, border-color .2s;
  border-top: 3px solid var(--stage, var(--blue-300));
}
.stage-tile:hover { background: rgba(255,255,255,.12); color: #fff; }
.stage-tile__name { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--on-dark-muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-tile__count { font-family: var(--font-head); font-size: 1.625rem; font-weight: 600; color: #fff; line-height: 1.15; }
.stage-tile__sum { font-size: .8125rem; color: var(--on-dark-muted); font-variant-numeric: tabular-nums; }
.stage-tile__new { font-size: .75rem; color: var(--accent-400); font-weight: 600; }

.widgets { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.w-3 { grid-column: span 3; } .w-4 { grid-column: span 4; } .w-5 { grid-column: span 5; } .w-6 { grid-column: span 6; } .w-7 { grid-column: span 7; } .w-8 { grid-column: span 8; } .w-12 { grid-column: span 12; }
.widget { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; }
.widget__title { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.widget__title a { text-transform: none; letter-spacing: 0; font-size: .8125rem; }
.widget__value { font-family: var(--font-head); font-weight: 600; font-size: clamp(1.75rem, 1.3rem + 1.2vw, 2.4rem); color: var(--ink); line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.widget__value--accent { color: var(--accent-600); }
.widget__value--danger { color: var(--danger); }
.widget__value--ok { color: var(--success); }
.widget__sub { font-size: .8125rem; color: var(--muted); }
.bars { display: grid; gap: 10px; }
.bar { display: grid; gap: 4px; }
.bar__row { display: flex; justify-content: space-between; gap: 8px; font-size: .875rem; }
.bar__row b { color: var(--ink); font-weight: 600; }
.bar__track { height: 6px; border-radius: 6px; background: var(--sand-200); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 6px; background: var(--grad-accent); }
.bar__fill--blue { background: linear-gradient(90deg, var(--blue-300), var(--blue-600)); }
.list { display: grid; }
.list__item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list__item:last-child { border-bottom: 0; }
.list__main { min-width: 0; flex: 1; display: grid; gap: 2px; }
.list__main a { font-weight: 600; color: var(--ink); }
.list__main a:hover { color: var(--blue-600); }
.list__aside { text-align: right; font-size: .8125rem; color: var(--muted); white-space: nowrap; }
.date-badge { display: grid; place-items: center; width: 44px; flex: none; padding: 4px 0; border-radius: 10px; background: var(--accent-100); color: var(--accent-700); line-height: 1.1; }
.date-badge b { font-family: var(--font-head); font-size: 1.125rem; }
.date-badge span { font-size: .625rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.empty { padding: 26px 12px; text-align: center; color: var(--muted); font-size: .875rem; display: grid; gap: 8px; justify-items: center; }
.empty .icon { width: 28px; height: 28px; color: var(--blue-300); }

/* --- Сделка --------------------------------------------------------------- */
.deal-head { display: grid; gap: 10px; margin-bottom: 18px; }
.deal-head__row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.deal-head__meta { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .875rem; }
.pipeline { display: flex; gap: 4px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
.pipeline form { display: contents; }
.pipeline button {
  flex: 1 0 auto; min-height: 38px; padding: 0 14px; border: 0; cursor: pointer;
  background: var(--sand-200); color: var(--text); font-size: .8125rem; font-weight: 600; white-space: nowrap;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
  transition: background-color .2s, color .2s;
}
.pipeline button:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: 10px 0 0 10px; }
.pipeline button:hover { background: var(--blue-100); color: var(--navy-700); }
.pipeline button.is-done { background: color-mix(in srgb, var(--stage) 22%, var(--surface)); color: var(--ink); }
.pipeline button.is-current { background: var(--stage); color: #fff; }
.pipeline button.is-lost { background: var(--sand-200); }
.props { display: grid; grid-template-columns: minmax(130px, .7fr) minmax(0, 1fr); gap: 10px 16px; font-size: .9rem; }
.props dt { color: var(--muted); }
.props dd { margin: 0; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.props dd.empty-val { color: var(--muted); font-weight: 400; }
.feed { display: grid; gap: 0; }
.feed__item { position: relative; display: grid; gap: 3px; padding: 0 0 16px 22px; }
.feed__item::before { content: ""; position: absolute; left: 5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.feed__item:last-child::before { display: none; }
.feed__dot { position: absolute; left: 0; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--blue-300); box-shadow: 0 0 0 3px var(--surface); }
.feed__item--comment .feed__dot { background: var(--accent-500); }
.feed__item--money .feed__dot { background: var(--success); }
.feed__item--task .feed__dot { background: var(--star); }
.feed__meta { font-size: .75rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.feed__meta b { color: var(--ink); font-weight: 600; }
.feed__body { color: var(--ink); white-space: pre-line; overflow-wrap: anywhere; }
.feed__item--comment .feed__body { background: var(--sand-50); border: 1px solid var(--line-warm); border-radius: 4px 12px 12px 12px; padding: 10px 12px; margin-top: 4px; }

.task-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-row form { display: contents; }
.task-check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 7px; border: 2px solid var(--blue-300); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: transparent; padding: 0;
}
.task-check:hover { border-color: var(--success); color: var(--success); }
.task-check .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.task-row.is-done .task-check { background: var(--success); border-color: var(--success); color: #fff; }
.task-row.is-done .task-row__title { text-decoration: line-through; color: var(--muted); }
.task-row__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.task-row__title { color: var(--ink); font-weight: 500; }
.task-row__meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); align-items: center; }
.task-row__meta .is-overdue { color: var(--danger); font-weight: 600; }
.task-row__meta .is-today { color: var(--accent-700); font-weight: 600; }

.money-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.money-tile { padding: 12px 14px; border-radius: var(--r-sm); background: var(--sand-50); border: 1px solid var(--line-warm); }
.money-tile span { display: block; font-size: .75rem; color: var(--muted); font-weight: 500; }
.money-tile b { display: block; font-family: var(--font-head); font-size: 1.25rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: 2px; }
.money-tile small { font-size: .75rem; color: var(--muted); }
.money-tile--profit { background: var(--navy-900); border-color: var(--navy-900); }
.money-tile--profit span, .money-tile--profit small { color: var(--on-dark-muted); }
.money-tile--profit b { color: #fff; }
.money-tile--debt b { color: var(--danger); }
.money-tile--ok b { color: var(--success); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.section-title h3 { font-size: 1rem; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: var(--r-pill); }
.status--due { background: var(--accent-100); color: var(--accent-700); }
.status--paid { background: var(--ok-bg); color: var(--ok-ink); }
.status--over { background: var(--danger-bg); color: var(--danger-ink); }
.status--forecast { background: var(--blue-100); color: var(--navy-700); }
details.inline-form > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.inline-form > summary::-webkit-details-marker { display: none; }
details.inline-form[open] > summary { display: none; }
.inline-form__box { padding: 14px; margin-top: 8px; border-radius: var(--r-sm); background: var(--sand-50); border: 1px solid var(--line-warm); }

/* --- Календарь ---------------------------------------------------------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--line); border-top: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.cal__dow { padding: 8px 10px; font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; background: var(--sand-50); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal__day { min-height: 118px; padding: 6px 6px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; align-content: start; gap: 4px; }
.cal__day--other { background: var(--sand-50); }
.cal__day--other .cal__num { color: var(--blue-300); }
.cal__num { font-size: .8125rem; font-weight: 600; color: var(--ink); padding: 2px 4px; }
.cal__day--today .cal__num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--grad-accent); color: #fff; padding: 0; }
.cal__ev { display: block; padding: 3px 7px; border-radius: 6px; font-size: .75rem; line-height: 1.3; color: var(--ink); background: var(--blue-50); border-left: 3px solid var(--blue-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal__ev:hover { background: var(--blue-100); color: var(--ink); }
.cal__ev--measure { background: color-mix(in srgb, var(--blue-600) 9%, var(--surface)); border-color: var(--blue-600); }
.cal__ev--delivery { background: var(--accent-100); border-color: var(--accent-500); }
.cal__ev--install { background: color-mix(in srgb, var(--accent-600) 18%, var(--surface)); border-color: var(--accent-700); }
.cal__ev--manufacture { background: var(--sand-100); border-color: var(--line-warm); }
.cal__ev--task { background: var(--warn-bg); border-color: var(--star); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8125rem; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* --- Диалог --------------------------------------------------------------- */
dialog.modal { width: min(560px, calc(100vw - 24px)); border: 0; padding: 0; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-lg); color: var(--text); }
dialog.modal::backdrop { background: rgba(15, 29, 46, .55); backdrop-filter: blur(2px); }
.modal__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 18px 20px 0; }
.modal__body { padding: 16px 20px 20px; }

/* --- Сообщения ------------------------------------------------------------ */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-sm); background: var(--navy-900); color: #fff; box-shadow: var(--shadow-lg); font-size: .875rem; animation: toast-in .3s var(--ease); }
.toast--error { background: #8a3420; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* --- Вход ----------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); background: var(--surface); }
.auth__visual { position: relative; isolation: isolate; overflow: hidden; margin: 12px; border-radius: var(--r-lg); padding: clamp(28px, 4vw, 56px); display: flex; flex-direction: column; justify-content: space-between; color: var(--on-dark); background: var(--navy-950); }
.auth__visual::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(15,29,46,.92) 0%, rgba(15,29,46,.55) 60%, rgba(15,29,46,.25) 100%), linear-gradient(0deg, rgba(15,29,46,.75) 0%, transparent 50%); }
.auth__visual .hero__media { z-index: -2; }
.auth__visual h1 { color: #fff; font-size: clamp(2rem, 1.2rem + 2.6vw, 3.4rem); line-height: 1.05; max-width: 14ch; }
.auth__visual h1 em { font-style: normal; color: var(--accent-400); }
.auth__visual p { color: var(--on-dark-muted); max-width: 46ch; margin-top: 14px; }
.auth__form { display: grid; align-content: center; justify-items: center; padding: 40px clamp(20px, 4vw, 64px); }
.auth__card { width: min(400px, 100%); display: grid; gap: 18px; }
.auth__card h2 { font-size: 1.75rem; }

/* --- Адаптив -------------------------------------------------------------- */
@media (max-width: 1280px) {
  .w-3 { grid-column: span 6; } .w-4 { grid-column: span 6; } .w-5, .w-7 { grid-column: span 12; } .w-8 { grid-column: span 12; }
  .split { grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr); }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .3s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 35; background: rgba(15,29,46,.45); }
  .btn.topbar__burger { display: inline-flex; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth__visual { min-height: 260px; }
}
@media (max-width: 760px) {
  body { font-size: .9375rem; }
  .topbar { gap: 8px; padding: 10px 16px; }
  .topbar .btn--accent span { display: none; }
  .topbar .btn--accent { padding: 0; width: 44px; }
  .content { padding: 16px; }
  .widgets { grid-template-columns: minmax(0, 1fr); }
  .widgets > * { grid-column: auto !important; }
  .grid-2, .grid-3, .grid-4, .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .props { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .props dt { margin-top: 8px; font-size: .8125rem; }
  .board { grid-auto-columns: minmax(84vw, 1fr); }
  .cal { grid-template-columns: minmax(0, 1fr); border-radius: var(--r-sm); }
  .cal__dow { display: none; }
  .cal__day { min-height: 0; }
  .cal__day--empty { display: none; }
  .cal__num::after { content: attr(data-dow); margin-left: 6px; color: var(--muted); font-weight: 500; }
  .hero { border-radius: var(--r-md); }
  .table--stack thead { display: none; }
  .table--stack tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table--stack td { border: 0; padding: 2px 0; }
  .table--stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .75rem; }
  .page-head { margin-bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Поправки после проверки в браузере ----------------------------------- */
.btn--link { justify-self: start; justify-content: flex-start; }
.deal-head__meta > a, .deal-head__meta > span { display: inline-flex; align-items: center; gap: 6px; }
.deal-head__meta .icon { width: 16px; height: 16px; }
.cell-person { min-width: 210px; }
.cell-person .small { display: block; max-width: 260px; }
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
@media (max-width: 760px) {
  .cal__day--empty-m:not(.cal__day--today) { display: none; }
}

/* --- Задачи колонками по датам (как в amoCRM) ----------------------------- */
.board--tasks { grid-auto-columns: minmax(260px, 1fr); }
.lane--danger .lane__head { border-bottom-color: var(--danger); }
.lane--ok .lane__head { border-bottom-color: var(--success); }
.lane--info .lane__head { border-bottom-color: var(--blue-500); }
.lane--muted .lane__head { border-bottom-color: var(--blue-300); }
.lane--done .lane__head { border-bottom-color: var(--line); }
.lane__head h2 { font-size: .9375rem; }
.lane__empty { padding: 18px 8px; text-align: center; color: var(--muted); font-size: .8125rem; border: 1px dashed var(--line); border-radius: var(--r-sm); }
.lane__body:has(.card) .lane__empty { display: none; }
.tcard { cursor: pointer; }
.board--tasks .lane__body[data-task-lane] .tcard { cursor: grab; }
.tcard--overdue { border-left: 3px solid var(--danger); }
.tcard--done { opacity: .7; }
.tcard--done .card__title { text-decoration: line-through; color: var(--muted); }
.tcard__check { position: relative; z-index: 2; width: 22px; height: 22px; margin: -2px -2px 0 0; }
.tcard__when { font-size: .8125rem; color: var(--muted); }
.tcard__when.is-overdue { color: var(--danger); font-weight: 600; }
.tcard__text { display: flex; gap: 6px; align-items: flex-start; font-size: .8125rem; color: var(--text); line-height: 1.4; }
.tcard__text .icon { width: 15px; height: 15px; margin-top: 1px; color: var(--blue-500); }
.tcard__text b { color: var(--ink); font-weight: 600; }
#tasks { scroll-margin-top: calc(var(--topbar-h) + 16px); }

/* --- Фильтры под кнопкой: быстрая плавная анимация ------------------------- */
.filter-panel { display: grid; grid-template-rows: 0fr; opacity: 0; transform: translateY(-6px); margin-bottom: 0;
  transition: grid-template-rows .22s var(--ease), opacity .18s var(--ease), transform .22s var(--ease), margin-bottom .22s var(--ease); }
.filter-panel.is-open { grid-template-rows: 1fr; opacity: 1; transform: none; margin-bottom: 18px; }
.filter-panel__clip { min-height: 0; overflow: hidden; }
.filter-panel.is-shown .filter-panel__clip { overflow: visible; }
.filter-panel .toolbar { margin-bottom: 0; }
.filter-panel:not(.is-open) .toolbar { visibility: hidden; }
.filter-toggle[aria-expanded="true"] { border-color: var(--ink); background: var(--sand-100); }
.filter-toggle__count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--grad-accent); color: #fff; font-size: .6875rem; }

/* --- Финансы: лёгкая сводка ---------------------------------------------- */
.accent-text { color: var(--accent-600); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.kpi { display: grid; gap: 2px; padding: 14px 20px; border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi span { font-size: .75rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.kpi b { font-family: var(--font-head); font-size: 1.375rem; font-weight: 600; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi small { font-size: .75rem; color: var(--muted); }
/* Строка целиком открывает сделку (обработчик в app.js). Растянутая ссылка через ::after не годится:
   в Safari строка таблицы не ограничивает её, и ссылка последней строки накрывала всю страницу. */
.table tbody tr[data-href] { cursor: pointer; }
.people__row { display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(0, 1.6fr) auto 20px; gap: 20px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); color: var(--text); }
.people__row:last-child { border-bottom: 0; }
.people__row:hover { background: var(--sand-50); color: var(--text); }
.people__who { display: flex; gap: 12px; align-items: center; }
.people__who b { display: block; color: var(--ink); }
.people__who small, .people__bar small { color: var(--muted); font-size: .8125rem; }
.people__bar { display: grid; gap: 6px; }
.people__due { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .people__row { grid-template-columns: minmax(0, 1fr) 20px; }
  .people__bar, .people__due { grid-column: 1; justify-content: flex-start; }
}

/* --- Свои теги ------------------------------------------------------------ */
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 44px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: text; transition: border-color .2s, box-shadow .2s; }
.tag-input:focus-within { border-color: var(--blue-300); box-shadow: 0 0 0 4px var(--blue-100); }
.tag-input .chip { gap: 4px; padding-right: 4px; }
.chip__x { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; opacity: .7; }
.chip__x:hover { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); }
.tag-input__entry { flex: 1 1 140px; min-width: 120px; border: 0; outline: 0; padding: 4px 6px; background: transparent; color: var(--ink); }
.field .tag-input input.tag-input__entry { min-height: 0; border: 0; box-shadow: none; padding: 4px 6px; }
.tag-input:not([data-ready]) .tag-input__raw { border: 0; min-height: 0; padding: 4px 6px; box-shadow: none; }

/* --- Кнопка темы: видна одна иконка — солнце в светлой теме, луна в тёмной --- */
.sidebar__user > div { min-width: 0; flex: 1; }
.sidebar__user b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-btn {
  position: relative; flex: none; margin-left: 16px;
  display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border: 1px solid var(--line-dark); border-radius: 50%; background: rgba(255,255,255,.06);
  cursor: pointer; transition: background-color .2s, border-color .2s, transform .2s var(--ease);
}
.theme-btn:hover { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.26); }
.theme-btn:active { transform: scale(.92); }
.theme-btn .icon {
  grid-area: 1 / 1; width: 19px; height: 19px;
  transition: opacity .3s var(--ease), transform .4s var(--ease);
}
.theme-btn__sun { color: var(--accent-400); }
.theme-btn__moon { color: #dbe7f4; opacity: 0; transform: rotate(-90deg) scale(.5); }
:root[data-theme="dark"] .theme-btn__sun { opacity: 0; transform: rotate(90deg) scale(.5); }
:root[data-theme="dark"] .theme-btn__moon { opacity: 1; transform: none; }
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease), fill .25s var(--ease) !important;
}

/* --- Тёмная тема ----------------------------------------------------------
   Те же фирменные цвета: нави-фон, абрикосовые кнопки, стальной синий.
   Меняются только поверхности, линии и цвет текста. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0b1521;
  --surface: #132132;
  --sand-50: #0f1b29;
  --sand-100: #182a3e;
  --sand-200: #203349;
  --line: #24374b;
  --line-warm: #2a3c51;
  --ink: #eef2f6;
  --text: #c3cdd8;
  --muted: #8d9caf;
  --blue-50: #13283f;
  --blue-100: #1a3552;
  --blue-300: #41698f;
  --blue-500: #5f98d0;
  --blue-600: #80b3e4;
  --navy-700: #cfe0f2;
  --accent-100: #3a2419;
  --accent-200: #6b3a24;
  --accent-700: #f2a37f;
  --warn-bg: #362b13;
  --warn-ink: #efcd88;
  --danger-bg: #3b1e18;
  --danger-ink: #f3a693;
  --ok-bg: #15322a;
  --ok-ink: #91d4b4;
  --violet-bg: #2b2240;
  --violet-ink: #cbb6ee;
  --danger: #ee7f66;
  --success: #57b88c;
  --topbar-bg: rgba(11, 21, 33, .86);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .3), 0 14px 32px -12px rgba(0, 0, 0, .65);
  --shadow-lg: 0 30px 60px -24px rgba(0, 0, 0, .75);
}
:root[data-theme="dark"] .sidebar { border-right: 1px solid var(--line-dark); }
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .accent-text,
:root[data-theme="dark"] .widget__value--accent { color: var(--accent-400); }
:root[data-theme="dark"] .eyebrow::before, :root[data-theme="dark"] .eyebrow::after { color: var(--accent-500); }
:root[data-theme="dark"] .btn--navy { background: var(--navy-800); }
:root[data-theme="dark"] .btn--navy:hover { background: #24406a; }
:root[data-theme="dark"] .btn--outline:hover { border-color: var(--blue-300); }
:root[data-theme="dark"] .avatar { background: color-mix(in srgb, var(--c) 32%, var(--surface)); color: color-mix(in srgb, var(--c) 40%, #fff); }
:root[data-theme="dark"] .sidebar .avatar { background: rgba(255,255,255,.12); color: #fff; }
:root[data-theme="dark"] .money-tile--profit { background: var(--grad-navy); border-color: var(--line); }
:root[data-theme="dark"] .toast { background: var(--navy-800); border: 1px solid var(--line-dark); }
:root[data-theme="dark"] .toast--error { background: #6e2a1a; }
:root[data-theme="dark"] .pipeline button.is-done { background: color-mix(in srgb, var(--stage) 30%, var(--surface)); }
:root[data-theme="dark"] .card__when, :root[data-theme="dark"] .task-row__meta .is-today { color: var(--accent-400); }
:root[data-theme="dark"] .hero, :root[data-theme="dark"] .auth__visual { box-shadow: inset 0 0 0 1px var(--line-dark); }
:root[data-theme="dark"] dialog.modal::backdrop { background: rgba(0, 0, 0, .6); }
:root[data-theme="dark"] .scrim { background: rgba(0, 0, 0, .55); }

/* --- Отметка сделок в списке и панель действий ---------------------------- */
.row-check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin-right: 6px; }
.row-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent-600); cursor: pointer; }
th .row-check { vertical-align: middle; }
.table tbody tr.is-picked, .table tbody tr.is-picked td { background: var(--blue-50); }
.bulk-bar {
  position: fixed; z-index: 45; bottom: 22px; left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) / 2); transform: translateX(-50%);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
  width: max-content; max-width: calc(100vw - var(--sidebar-w) - 32px);
  padding: 10px 12px 10px 20px;
  background: var(--surface); border: 1px solid var(--blue-300); border-radius: var(--r-pill); box-shadow: var(--shadow-lg);
  animation: bulk-in .2s var(--ease);
}
.bulk-bar b { color: var(--ink); font-size: .875rem; margin-right: 4px; }
@keyframes bulk-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@media (max-width: 1024px) {
  .bulk-bar { left: 50%; max-width: calc(100vw - 24px); bottom: 14px; }
}
@media (max-width: 760px) {
  .bulk-bar { border-radius: var(--r-md); padding: 10px 12px; }
}

/* --- Роль под именем в меню ----------------------------------------------- */
.sidebar__meta { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--on-dark-muted); white-space: nowrap; }
.sidebar__meta form { display: contents; }
.sidebar__meta span::after { content: "·"; margin-left: 6px; }
.sidebar__meta button { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; }
.sidebar__meta button:hover { color: #fff; }

/* --- Документы сделки ----------------------------------------------------- */
.docs { display: grid; gap: 14px; }
.docs__group { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; transition: border-color .15s, background-color .15s; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.docs__group.is-drop { border-color: var(--accent-400); border-style: dashed; background: var(--accent-100); }
.docs__group.is-loading { opacity: .6; pointer-events: none; }
.docs__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.docs__head h3 { font-size: .9375rem; }
.docs__add { cursor: pointer; position: relative; }
.docs__add:focus-within { outline: 2px solid var(--blue-500); outline-offset: 2px; }
.docs__empty { margin-top: 8px; font-size: .8125rem; color: var(--muted); }
.doc { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.docs__head + .doc { margin-top: 10px; }
.doc__icon { flex: none; display: grid; place-items: center; width: 40px; height: 44px; border-radius: 8px; background: var(--blue-50); color: var(--blue-600); font-size: .625rem; font-weight: 700; letter-spacing: .03em; }
.doc__icon--pdf { background: var(--danger-bg); color: var(--danger-ink); }
.doc__icon--img { background: var(--ok-bg); color: var(--ok-ink); }
.doc__main { min-width: 0; flex: 1; display: grid; gap: 2px; }
.doc__name { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.doc__name:hover { color: var(--blue-600); }
.doc__meta { font-size: .75rem; color: var(--muted); }
.doc__actions { display: flex; gap: 14px; align-items: center; flex: none; }
.doc__actions form { display: contents; }
.doc__actions .icon { width: 16px; height: 16px; }
@media (max-width: 760px) {
  .doc { flex-wrap: wrap; }
  .doc__actions { width: 100%; padding-left: 52px; }
}

/* --- Воронка: полупрозрачные стрелки по краям (как в Битрикс24) ------------ */
.board-wrap { position: relative; }
.board-nav {
  position: absolute; top: 0; bottom: 14px; z-index: 6; width: 64px; padding: 0; border: 0; cursor: pointer;
  display: flex; justify-content: center; color: var(--ink); opacity: 0; transition: opacity .2s var(--ease);
}
.board-nav--prev { left: -2px; background: linear-gradient(90deg, color-mix(in srgb, var(--canvas) 92%, transparent) 30%, transparent); }
.board-nav--next { right: -2px; background: linear-gradient(270deg, color-mix(in srgb, var(--canvas) 92%, transparent) 30%, transparent); }
.board-wrap:hover .board-nav, .board-nav:focus-visible, .board-wrap.is-dragging .board-nav { opacity: 1; }
.board-nav__arrow {
  position: sticky; top: calc(50vh - 22px); margin-top: 90px; display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 50%; background: color-mix(in srgb, var(--surface) 78%, transparent); border: 1px solid var(--line);
  box-shadow: var(--shadow-md); backdrop-filter: blur(4px); transition: transform .2s var(--ease), background-color .2s;
}
.board-nav:hover .board-nav__arrow { transform: scale(1.08); background: var(--surface); }
.board-nav__arrow .icon { width: 22px; height: 22px; }
@media (hover: none) {
  .board-nav { opacity: 1; width: 44px; background: none; }
  .board-nav__arrow { width: 38px; height: 38px; }
}

/* --- Широкие экраны: воронка и задачи на всю ширину, этапы растягиваются ---- */
.content { max-width: 1920px; }
.content.content--wide { max-width: none; }
.board { grid-auto-columns: minmax(248px, 1fr); }
@media (min-width: 2200px) {
  .content { padding-left: 40px; padding-right: 40px; }
}

/* --- Телефоны и планшеты: высота по видимой части экрана, отступы под панели браузера и «чёлку» */
.app { min-height: 100vh; min-height: 100dvh; }
.sidebar { height: 100vh; height: 100dvh; padding-bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px)); }
.toasts { bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px)); }
.bulk-bar { bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px)); }
dialog.modal { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: auto; }
.content { padding-bottom: max(clamp(18px, 2.4vw, 32px), calc(env(safe-area-inset-bottom) + 16px)); }
@media (max-width: 1024px) {
  .sidebar { inset: 0 auto auto 0; padding-left: max(14px, env(safe-area-inset-left)); }
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}
/* Задачи: на планшетах и раскладушках — сетка 2×2, на телефонах — колонки друг под другом */
@media (max-width: 1100px) {
  .board.board--tasks { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-columns: auto; overflow: visible; }
  .board--tasks .lane { min-height: 0; }
}
@media (max-width: 600px) {
  .board.board--tasks { grid-template-columns: minmax(0, 1fr); }
  .board--tasks .lane { min-height: 0; }
}

/* --- Уведомления «Новая заявка» и «Есть изменения» ------------------------- */
.toast--live { align-items: center; }
.toast--live a { display: grid; gap: 2px; color: #fff; text-decoration: none; }
.toast--live a b { color: var(--accent-400); font-size: .8125rem; }
.toast--live a:hover span { text-decoration: underline; }
.toast--live button[data-close-toast] { font-size: 18px; line-height: 1; padding: 0 2px; }
.toast--hint { gap: 12px; }
.toast--hint .btn { flex: none; }
.toast--lead { border-left: 3px solid var(--accent-400); }
