/* ========== CRM Logistics — base styles ========== */

:root {
  /* dark theme by default — Linear-leaning monochrome */
  --bg:            #0a0a0d;
  --bg-elev:       #111116;
  --surface:       #16161c;
  --surface-2:     #1c1c24;
  --surface-hover: #20202a;
  --border:        #22222b;
  --border-strong: #2e2e38;
  --border-soft:   #1a1a22;

  --text:          #ececf1;
  --text-2:        #a0a0ad;
  --text-3:        #6b6b7a;
  --text-4:        #44444f;

  --accent:        oklch(0.74 0.09 152);
  --accent-soft:   oklch(0.74 0.09 152 / .22);
  --accent-line:   oklch(0.74 0.09 152 / .45);
  --accent-strong: oklch(0.46 0.13 152);
  --accent-ink:    #ffffff;

  --success:       oklch(0.72 0.13 145);
  --success-soft:  oklch(0.72 0.13 145 / .14);
  --warning:       oklch(0.78 0.13 75);
  --warning-soft:  oklch(0.78 0.13 75 / .14);
  --danger:        oklch(0.66 0.18 25);
  --danger-soft:   oklch(0.66 0.18 25 / .14);
  --violet:        oklch(0.68 0.16 295);
  --violet-soft:   oklch(0.68 0.16 295 / .14);
  --cyan:          oklch(0.74 0.11 210);
  --cyan-soft:     oklch(0.74 0.11 210 / .14);

  --radius:        6px;
  --radius-lg:     10px;
  --radius-sm:     4px;

  --shadow-1:      0 1px 0 rgba(255,255,255,.02) inset, 0 1px 2px rgba(0,0,0,.4);
  --shadow-pop:    0 0 0 1px var(--border-strong), 0 20px 50px -10px rgba(0,0,0,.6), 0 8px 20px -6px rgba(0,0,0,.4);

  --sidebar-w:     228px;
  --row-h:         32px;

  --font:          'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:     'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

[data-theme="light"] {
  --bg:            #f8fbf9;
  --bg-elev:       #ffffff;
  --surface:       #ffffff;
  --surface-2:     #f1f6f3;
  --surface-hover: #eaf2ec;
  --border:        #e3ece6;
  --border-strong: #c9d8ce;
  --border-soft:   #eef3ef;
  --text:          #18241d;
  --text-2:        #4d5b53;
  --text-3:        #7e8c84;
  --text-4:        #b0bdb5;
  --shadow-1:      0 1px 0 rgba(0,0,0,.02), 0 1px 2px rgba(20,40,30,.04);
  --shadow-pop:    0 0 0 1px var(--border), 0 20px 50px -10px rgba(20,40,30,.16), 0 8px 20px -6px rgba(20,40,30,.08);
}

[data-density="compact"] { --row-h: 28px; }
[data-density="comfy"]   { --row-h: 38px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}
#root { height: 100%; }

button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num  { font-variant-numeric: tabular-nums; }

/* ========== App layout ========== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ========== Sidebar ========== */

.sb {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sb-hd {
  padding: 12px 12px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sb-logo {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: linear-gradient(140deg, var(--accent), oklch(0.5 0.18 270));
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 12px;
  letter-spacing: -0.02em;
}
.sb-org { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; flex: 1; }
.sb-org small { display: block; font-weight: 400; color: var(--text-3); font-size: 11px; }
.sb-org-arrow { color: var(--text-3); }

.sb-search {
  margin: 4px 8px 4px;
  display: flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 12px;
  cursor: text;
}
.sb-search:hover { background: var(--surface-hover); }
.sb-search kbd {
  margin-left: auto;
  font-family: inherit;
  font-size: 10px;
  color: var(--text-4);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0 4px;
  border-radius: 3px;
  line-height: 14px;
}

.sb-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 4px 12px; }
.sb-group { padding: 8px 8px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-4); font-weight: 600; }
.sb-item {
  display: flex; align-items: center; gap: 8px;
  height: 26px;
  padding: 0 8px;
  margin: 1px 4px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: default;
  user-select: none;
  position: relative;
}
.sb-item:hover { background: var(--surface-hover); color: var(--text); }
.sb-item.is-active { background: var(--surface); color: var(--text); }
.sb-item.is-active::before {
  content: ""; position: absolute; left: -4px; top: 6px; bottom: 6px;
  width: 2px; border-radius: 2px; background: var(--accent);
}
.sb-item svg { color: var(--text-3); flex-shrink: 0; }
.sb-item.is-active svg { color: var(--text); }
.sb-item-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.sb-item-dot {
  margin-left: auto;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

.sb-ft {
  padding: 8px 8px 12px;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 8px;
}
.sb-ft .avatar { width: 22px; height: 22px; font-size: 10px; }
.sb-ft-name { font-size: 12px; flex: 1; }
.sb-ft-name small { display: block; color: var(--text-3); font-size: 10.5px; }

/* ========== Main area ========== */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: 44px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  background: var(--bg);
  flex-shrink: 0;
}
.crumb { color: var(--text-3); font-size: 12.5px; }
.crumb b { color: var(--text); font-weight: 500; }
.crumb-sep { color: var(--text-4); margin: 0 6px; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.view { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.view-hd {
  padding: 16px 20px 12px;
  display: flex; align-items: flex-end; gap: 12px;
  flex-shrink: 0;
}
.view-hd h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.view-hd .pageSub { color: var(--text-3); font-size: 12.5px; margin-left: auto; }

.view-toolbar {
  padding: 0 20px 8px;
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.view-body { flex: 1; min-height: 0; overflow: auto; }

/* ========== Buttons ========== */
.btn {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: default;
  transition: background 80ms ease, border-color 80ms ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn.is-primary {
  background: var(--accent-strong);
  border-color: transparent;
  color: var(--accent-ink);
}
.btn.is-primary:hover { background: oklch(0.52 0.13 152); }
.btn.is-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn.is-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.is-sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.is-icon { width: 28px; padding: 0; justify-content: center; }
.btn.is-icon.is-sm { width: 24px; }
.btn svg { color: var(--text-3); }
.btn.is-primary svg { color: rgba(255,255,255,.85); }

/* ========== Badges ========== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px;
  height: 19px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.badge.is-new     { color: var(--text-2); }                                     .badge.is-new .dot     { background: var(--text-3); }
.badge.is-calc    { color: oklch(0.74 0.11 210); background: var(--cyan-soft); border-color: transparent; } .badge.is-calc .dot { background: var(--cyan); }
.badge.is-agreed  { color: var(--violet); background: var(--violet-soft); border-color: transparent; }     .badge.is-agreed .dot { background: var(--violet); }
.badge.is-work    { color: var(--accent-strong); background: var(--accent-soft); border-color: transparent; } .badge.is-work .dot { background: var(--accent-strong); }
.badge.is-docs    { color: var(--warning); background: var(--warning-soft); border-color: transparent; } .badge.is-docs .dot { background: var(--warning); }
.badge.is-closed  { color: var(--success); background: var(--success-soft); border-color: transparent; } .badge.is-closed .dot { background: var(--success); }
.badge.is-cancel  { color: var(--danger); background: var(--danger-soft); border-color: transparent; opacity: 0.85; } .badge.is-cancel .dot { background: var(--danger); }
.badge.is-paid    { color: var(--success); background: var(--success-soft); border-color: transparent; } .badge.is-paid .dot { background: var(--success); }
.badge.is-unpaid  { color: var(--warning); background: var(--warning-soft); border-color: transparent; } .badge.is-unpaid .dot { background: var(--warning); }
.badge.is-overdue { color: var(--danger);  background: var(--danger-soft); border-color: transparent; } .badge.is-overdue .dot { background: var(--danger); }
.badge.is-tag     { background: transparent; border: 1px solid var(--border); color: var(--text-2); }

/* ========== Avatar ========== */
.avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 9.5px; font-weight: 600;
  color: white;
  flex-shrink: 0;
  letter-spacing: 0;
}
.avatar.is-sm { width: 18px; height: 18px; font-size: 9px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

/* ========== Table ========== */
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  table-layout: fixed;
}
.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg);
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  padding: 0 10px;
  height: 28px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.tbl tbody td {
  padding: 0 10px;
  height: var(--row-h);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tbl tbody tr { cursor: default; }
.tbl tbody tr:hover { background: var(--surface); }
.tbl tbody tr.is-active { background: var(--surface-2); }
.tbl tbody tr.is-active td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td .secondary { color: var(--text-3); }

.tbl-checkbox { width: 28px; }
.tbl-checkbox input { appearance: none; -webkit-appearance: none; width: 13px; height: 13px; border: 1px solid var(--border-strong); border-radius: 3px; background: transparent; cursor: default; }
.tbl-checkbox input:checked { background: var(--accent); border-color: transparent; }

.cell-route { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cell-route .arrow { color: var(--text-4); flex-shrink: 0; }
.cell-route span { overflow: hidden; text-overflow: ellipsis; }

.cell-id { color: var(--text-3); font-family: var(--font-mono); font-size: 11.5px; }

/* ========== Cards / panels ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.card-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-hd h3 { margin: 0; font-size: 12px; font-weight: 500; color: var(--text-3); letter-spacing: 0.01em; }
.kpi-val { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-val .unit { color: var(--text-3); font-size: 14px; font-weight: 500; margin-left: 2px; }
.kpi-delta { font-size: 11.5px; display: inline-flex; align-items: center; gap: 3px; }
.kpi-delta.up   { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--text-3); }
.kpi-sub { font-size: 11.5px; color: var(--text-3); }

/* ========== Kanban ========== */
.kb {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 280px;
  gap: 10px;
  height: 100%;
  padding: 4px 20px 20px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.kb-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  min-height: 0;
}
.kb-col-hd {
  padding: 10px 12px 8px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.kb-col-hd h4 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: -0.005em; }
.kb-col-hd .count { color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.kb-col-hd .grow { flex: 1; }
.kb-col-body {
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto;
  flex: 1; min-height: 0;
}
.kb-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 10px;
  display: flex; flex-direction: column; gap: 6px;
  cursor: default;
  font-size: 12px;
}
.kb-card:hover { border-color: var(--border-strong); }
.kb-card .kb-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.kb-card .kb-route { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-card .kb-id { color: var(--text-3); font-size: 11px; font-family: var(--font-mono); }
.kb-card .kb-meta { color: var(--text-3); font-size: 11px; display: flex; align-items: center; gap: 6px; }
.kb-card .kb-amt { margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; }

/* ========== Drawer ========== */
.drawer-bd {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.drawer-bd.is-open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 740px; max-width: calc(100vw - 80px);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  /* Тень только когда открыт — иначе blur просвечивает на правом крае */
  z-index: 61;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 220ms cubic-bezier(.22,.61,.36,1);
  visibility: hidden;
  pointer-events: none;
}
.drawer.is-open {
  transform: translateX(0);
  box-shadow: -20px 0 60px rgba(0,0,0,.4);
  visibility: visible;
  pointer-events: auto;
}
.drawer-hd {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.drawer-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.drawer-title h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.drawer-id { color: var(--text-3); font-family: var(--font-mono); font-size: 12px; }
.drawer-tabs {
  display: flex; gap: 2px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-tab {
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--text-3);
  cursor: default;
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
}
.drawer-tab:hover { color: var(--text-2); }
.drawer-tab.is-active { color: var(--text); }
.drawer-tab.is-active::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0;
}
.drawer-tab .count {
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 10.5px;
  padding: 0 4px;
  border-radius: 3px;
  min-width: 16px;
  text-align: center;
}
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 24px; }

.drawer-section { margin-bottom: 22px; }
.drawer-section h4 {
  margin: 0 0 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-4);
  font-weight: 600;
}

/* Definition list inside drawer */
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; font-size: 12.5px; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; color: var(--text); }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 9px; top: 4px; bottom: 4px;
  width: 1px; background: var(--border);
}
.tl-item { display: grid; grid-template-columns: 20px 1fr auto; gap: 8px; padding: 6px 0; align-items: start; }
.tl-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-4);
  margin: 6px;
  position: relative;
  border: 2px solid var(--bg-elev);
  box-shadow: 0 0 0 1px var(--text-4);
}
.tl-dot.accent { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tl-content { font-size: 12.5px; }
.tl-content .who { color: var(--text); font-weight: 500; }
.tl-content .what { color: var(--text-2); }
.tl-content .extra { color: var(--text-3); font-size: 11.5px; margin-top: 1px; }
.tl-time { color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; padding-top: 7px; }

/* Comment box */
.comment-box {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.comment-box textarea {
  width: 100%; border: 0; background: transparent; resize: none;
  outline: none; min-height: 44px; font-size: 12.5px;
}
.comment-box-ft { display: flex; justify-content: space-between; align-items: center; padding-top: 6px; border-top: 1px solid var(--border-soft); }

/* Finance breakdown in drawer */
.fin-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 12.5px; border-bottom: 1px dashed var(--border-soft); }
.fin-line:last-child { border-bottom: 0; }
.fin-line .label { color: var(--text-2); }
.fin-line .val { font-family: var(--font-mono); }
.fin-line.is-total { border-top: 1px solid var(--border); border-bottom: 0; padding-top: 10px; margin-top: 4px; font-weight: 600; }
.fin-line.is-total .val { color: var(--success); font-size: 14px; }

/* Documents grid */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.doc-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
  cursor: default;
}
.doc-tile:hover { border-color: var(--border-strong); }
.doc-tile .icon-box {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-2);
}
.doc-tile .name { font-size: 12px; font-weight: 500; }
.doc-tile .meta { font-size: 11px; color: var(--text-3); display: flex; gap: 6px; }

/* ========== Filter bar ========== */
.filter-bar { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.filter-input {
  height: 28px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--text-2);
}
.filter-input.is-active { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); }
.filter-input svg { color: var(--text-3); }

.search-input {
  height: 28px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 220px;
}
.search-input input {
  flex: 1; background: transparent; border: 0; outline: 0;
  font-size: 12.5px;
}
.search-input input::placeholder { color: var(--text-3); }

.view-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 1px;
}
.view-switch button {
  appearance: none; border: 0; background: transparent;
  color: var(--text-3);
  height: 22px; padding: 0 8px;
  font-size: 12px;
  border-radius: 4px;
  display: inline-flex; align-items: center; gap: 4px;
  cursor: default;
}
.view-switch button:hover { color: var(--text); }
.view-switch button.is-active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

/* ========== Dashboard mini chart ========== */
.spark { width: 100%; height: 36px; display: block; }
.area-chart { width: 100%; height: 220px; }

/* ========== Split view (list left + detail right) ========== */
.split { display: grid; grid-template-columns: 1fr 480px; height: 100%; min-height: 0; }
.split-list { border-right: 1px solid var(--border); min-height: 0; overflow: auto; }
.split-detail { overflow: auto; min-height: 0; background: var(--bg-elev); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ========== Sidebar theme toggle ========== */
.sb-theme-btn:hover {
  background: var(--surface-hover) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

/* ========== Topbar user menu ========== */
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  text-align: left;
  transition: background 0.12s ease;
}
.menu-item:hover { background: var(--surface-hover); }
.menu-item .icon { color: var(--text-3); }

/* ========== Lead list (компактный список лидов) ========== */
.lead-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.lead-row {
  display: grid;
  grid-template-columns: 6px 1fr auto auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.12s ease;
  font-size: 12.5px;
}
.lead-row:last-child { border-bottom: none; }
.lead-row:hover { background: var(--surface-hover); }
.lead-row-priority {
  width: 6px; height: 32px;
  border-radius: 3px;
  flex-shrink: 0;
}
.lead-row-main { min-width: 0; }
.lead-row-title {
  display: flex; align-items: baseline; gap: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px;
}
.lead-row-id {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
}
.lead-row-company {
  font-weight: 600;
  color: var(--text);
}
.lead-row-contact {
  color: var(--text-3);
  font-weight: 400;
  font-size: 12px;
}
.lead-row-meta {
  display: flex;
  gap: 10px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-3);
  flex-wrap: wrap;
}
.lead-row-money {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}
.lead-row-mgr {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.lead-row-days {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  white-space: nowrap;
  min-width: 32px;
  text-align: right;
}

/* ========== Tasks / lists ========== */
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.task-row:hover { background: var(--surface-hover); }
.task-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.task-check { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--text-4); }
.task-check.is-done { background: var(--text-3); border-color: var(--text-3); }
.task-row.is-done .task-title { color: var(--text-3); text-decoration: line-through; }
.task-status-pill {
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Task list container */
.task-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.task-list .task-row:last-child { border-bottom: none; }

/* Task create panel (inline new-task form) */
.task-create-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.task-create-panel input,
.task-create-panel select {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--text);
}
.task-create-panel input[type="text"] { flex: 1; min-width: 0; }

/* Tabs inside task drawer */
.task-drawer-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  padding: 0 16px;
}
.task-drawer-tabs button {
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.task-drawer-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.task-drawer-tabs button:hover { color: var(--text); }

/* Subtask row inside drawer */
.subtask-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
}
.subtask-row:hover { background: var(--surface-hover); }

/* Checklist item inside drawer */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
}
.checklist-item:hover { background: var(--surface); }
.checklist-item.is-done .checklist-text { color: var(--text-3); text-decoration: line-through; }

/* Comment block */
.task-comment {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.task-comment:last-child { border-bottom: none; }
.task-comment .comment-body {
  flex: 1;
  min-width: 0;
}
.task-comment .comment-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 2px;
}

/* Empty state */
.empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-3); font-size: 13px;
}

/* Map placeholder */
.map-box {
  height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(45deg, var(--surface) 0 8px, var(--surface-2) 8px 16px);
  position: relative;
  overflow: hidden;
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--font-mono);
  display: flex; align-items: flex-end; padding: 8px 10px;
}
.map-route { position: absolute; left: 10%; right: 10%; top: 45%; height: 2px; background: var(--accent); border-radius: 1px; }
.map-route::before, .map-route::after {
  content: ""; position: absolute; top: -3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.map-route::before { left: -4px; }
.map-route::after  { right: -4px; }

/* Section dividers in views */
.section-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; padding: 0 20px; }
.col-grid { display: grid; gap: 12px; }
.row-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 0 20px; }
.row-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0 20px; }
.row-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; padding: 0 20px 20px; }
.stack > .row-grid-4, .stack > .row-grid-3, .stack > .row-grid-2, .stack > .section-row { padding: 0; }

/* Chart bars */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding: 8px 4px 0; }
.bar-chart .bar { flex: 1; background: var(--accent-soft); border-radius: 2px 2px 0 0; min-width: 6px; position: relative; }
.bar-chart .bar .fill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); border-radius: 2px 2px 0 0; }
.bar-labels { display: flex; gap: 4px; padding: 4px 4px 0; font-size: 10px; color: var(--text-3); }
.bar-labels span { flex: 1; text-align: center; }

/* Pulse / live indicator */
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); display: inline-block; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--success-soft); }
  50%      { box-shadow: 0 0 0 5px var(--success-soft); }
}

/* Currency cell with secondary line */
.cell-money { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.cell-money .secondary { font-size: 10.5px; color: var(--text-3); }

/* Generic flex helpers */
.row { display: flex; align-items: center; gap: 8px; }
.row-sb { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grow { flex: 1; }
.sep { width: 1px; height: 16px; background: var(--border); display: inline-block; }

/* Stat list (sidebar in dashboards) */
.stat-list { display: flex; flex-direction: column; gap: 0; }
.stat-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 12.5px;
}
.stat-row:last-child { border-bottom: 0; }
.stat-row .name { color: var(--text); }
.stat-row .sub  { color: var(--text-3); font-size: 11px; }
.stat-row .val  { font-family: var(--font-mono); }
.stat-row .pct  { color: var(--text-3); font-size: 11.5px; min-width: 50px; text-align: right; }

/* Subtle highlight box (Important info card) */
.note {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text);
  display: flex; gap: 10px; align-items: flex-start;
}
.note svg { color: var(--accent-strong); flex-shrink: 0; margin-top: 1px; }

/* Soft warning */
.note.is-warn { background: var(--warning-soft); border-color: oklch(0.78 0.13 75 / .35); }
.note.is-warn svg { color: var(--warning); }

/* ============================================
   Workspace switcher in Topbar (Лента / Чаты / CRM)
============================================ */
.ws-switch { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; min-width: 0; }
.ws-sep    { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }
.ws-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  background: transparent; border: 1px solid transparent;
  border-radius: 8px; color: var(--text-2);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  position: relative;
}
.ws-btn:hover { background: var(--surface-hover); color: var(--text); }
.ws-btn svg { color: currentColor; }
.ws-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--text);
}
.ws-btn.is-active svg { color: var(--accent-strong); }
.ws-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: 10.5px; font-weight: 600;
  border-radius: 9px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.ws-badge.is-info   { background: var(--accent-soft);  color: var(--accent-strong); }
.ws-badge.is-warn   { background: var(--warning-soft); color: var(--warning); }
.ws-badge.is-danger { background: var(--danger-soft);  color: var(--danger); }

/* ============================================
   CRM Kanban — wider columns, richer card
============================================ */
.crm-kb { display: grid; grid-auto-flow: column; grid-auto-columns: 300px; gap: 10px; padding: 4px 20px 20px; height: 100%; overflow-x: auto; scrollbar-width: thin; }
.crm-kb-col {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; min-height: 0;
}
.crm-kb-col-hd {
  padding: 10px 12px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 6px;
}
.crm-kb-col-hd .dot { width: 8px; height: 8px; border-radius: 50%; }
.crm-kb-col-hd h4 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: -0.005em; flex: 1; }
.crm-kb-col-hd .count { color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.crm-kb-col-hd .sum   { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; font-family: var(--font-mono); }
.crm-kb-col-body {
  padding: 8px; display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; flex: 1; min-height: 0;
}
.crm-kb-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 11px; display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; font-size: 12px;
  position: relative;
}
.crm-kb-card:hover { border-color: var(--border-strong); }
.crm-kb-card.is-overdue { box-shadow: inset 3px 0 0 var(--danger); }
.crm-kb-card.is-hot     { box-shadow: inset 3px 0 0 #EF4444; }
.crm-kb-card.is-warm    { box-shadow: inset 3px 0 0 #F59E0B; }
.crm-kb-card.is-cold    { box-shadow: inset 3px 0 0 #6B7280; }
.crm-kb-card .kb-id { color: var(--text-3); font-size: 10.5px; font-family: var(--font-mono); }
.crm-kb-card .kb-title { font-weight: 500; color: var(--text); line-height: 1.4; }
.crm-kb-card .kb-sub { color: var(--text-3); font-size: 11px; }
.crm-kb-card .kb-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.crm-kb-card .kb-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-2);
}
.crm-kb-card .kb-meta-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); }
.crm-kb-card .kb-meta-row .grow { flex: 1; }
.crm-kb-card .kb-amount { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.crm-kb-card .kb-bar { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.crm-kb-card .kb-bar > div { height: 100%; background: var(--accent); }

/* ============================================
   Feed — corporate wall
============================================ */
.feed-wrap { display: grid; grid-template-columns: 1fr 280px; gap: 20px; padding: 16px 20px; max-width: 1280px; }
.feed-col  { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.feed-side { display: flex; flex-direction: column; gap: 10px; }
.feed-side .card { padding: 12px; }
.feed-side .card-hd h3 { font-size: 12px; }

.feed-filters {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.feed-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; cursor: pointer; border: 1px solid transparent;
}
.feed-chip.is-active { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }
.feed-chip:hover { background: var(--surface-hover); }

.feed-composer {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 12px; display: flex; gap: 10px; align-items: flex-start;
}
.feed-composer input {
  flex: 1; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; font: inherit; color: var(--text); height: 36px;
}
.feed-composer input::placeholder { color: var(--text-3); }
.feed-composer .feed-types { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; width: 100%; }

.feed-post {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  position: relative;
}
.feed-post.is-important { border-color: var(--accent-line); background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 50%); }
.feed-post.is-pinned    { box-shadow: 0 0 0 1px var(--accent-line); }
.feed-post.is-birthday  { border-color: oklch(0.78 0.13 295 / .45); background: linear-gradient(180deg, oklch(0.68 0.16 295 / .12) 0%, var(--surface) 50%); }
.feed-post-hd { display: flex; align-items: center; gap: 10px; }
.feed-post-hd .who { font-weight: 500; color: var(--text); }
.feed-post-hd .meta { color: var(--text-3); font-size: 11.5px; }
.feed-post-hd .pin-badge {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--accent-strong);
}
.feed-post-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); margin: 0; }
.feed-post-body  { font-size: 13.5px; color: var(--text); line-height: 1.55; }
.feed-post-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px;
  font-size: 10.5px; font-weight: 500;
  background: var(--surface-2); color: var(--text-3);
}
.feed-post-tag.is-news       { background: var(--cyan-soft);    color: oklch(0.6 0.11 210); }
.feed-post-tag.is-announce   { background: var(--accent-soft);  color: var(--accent-strong); }
.feed-post-tag.is-important  { background: var(--danger-soft);  color: var(--danger); }
.feed-post-tag.is-birthday   { background: var(--violet-soft);  color: var(--violet); }
.feed-post-tag.is-poll       { background: var(--warning-soft); color: var(--warning); }
.feed-post-tag.is-achievement{ background: var(--success-soft); color: var(--success); }

.feed-post-attach {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 12px;
}
.feed-post-attach svg { color: var(--text-3); }
.feed-post-links { display: flex; flex-wrap: wrap; gap: 6px; }
.feed-post-link {
  font-size: 11.5px; color: var(--accent-strong); background: var(--accent-soft);
  border: 1px solid var(--accent-line); padding: 2px 7px; border-radius: 4px;
  display: inline-flex; align-items: center; gap: 4px;
}

.feed-reactions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.feed-reaction {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; cursor: pointer;
}
.feed-reaction.is-mine { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.feed-reaction:hover { background: var(--surface-hover); }
.feed-reaction .count { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }
.feed-reaction-add {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 12px;
  border: 1px dashed var(--border-strong); color: var(--text-3);
  font-size: 12px; background: transparent;
}

.feed-foot { display: flex; align-items: center; gap: 12px; padding-top: 8px; border-top: 1px solid var(--border-soft); }
.feed-foot-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 0; padding: 4px 6px; border-radius: 4px;
  color: var(--text-3); font-size: 12px; cursor: pointer;
}
.feed-foot-btn:hover { background: var(--surface-hover); color: var(--text); }
.feed-foot-btn .num { font-family: var(--font-mono); color: var(--text-2); }

.feed-comments { display: flex; flex-direction: column; gap: 10px; }
.feed-comment { display: flex; gap: 10px; align-items: flex-start; }
.feed-comment-body {
  flex: 1; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; font-size: 12.5px;
}
.feed-comment-meta { display: flex; gap: 6px; align-items: baseline; margin-bottom: 2px; }
.feed-comment-meta .who { font-weight: 500; font-size: 12px; color: var(--text); }
.feed-comment-meta .when { color: var(--text-3); font-size: 11px; }
.feed-comment.is-reply { margin-left: 32px; }

.feed-read-receipts {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--radius); font-size: 12px; color: var(--accent-strong);
}

/* Feed birthday card */
.bd-card { display: flex; gap: 14px; align-items: center; }
.bd-cake { font-size: 36px; line-height: 1; }
.bd-card .name { font-size: 15px; font-weight: 600; color: var(--text); }
.bd-card .meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.bd-gifts { display: flex; gap: 4px; align-items: center; margin-top: 6px; }
.bd-gift {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 7px; border-radius: 12px;
  background: oklch(0.68 0.16 295 / .12); border: 1px solid oklch(0.68 0.16 295 / .35);
  font-size: 12px; color: var(--text);
}
.bd-gift .emoji { font-size: 14px; }
.bd-actions { display: flex; gap: 8px; }
.bd-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius); cursor: pointer;
  font-size: 12.5px; font-weight: 500;
  background: var(--violet-soft); color: var(--violet); border: 1px solid oklch(0.68 0.16 295 / .35);
}
.bd-btn:hover { background: oklch(0.68 0.16 295 / .2); }

/* Poll */
.poll-opt { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.poll-opt + .poll-opt { border-top: 1px solid var(--border-soft); }
.poll-opt .pct {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--surface-2); position: relative; overflow: hidden;
}
.poll-opt .pct > div { position: absolute; inset: 0; background: var(--accent-soft); border-radius: 3px; }
.poll-opt .label { font-size: 12.5px; color: var(--text); min-width: 140px; }
.poll-opt .val   { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); min-width: 36px; text-align: right; }

/* ============================================
   Chat — 3-column workspace
============================================ */
.chat-wrap {
  display: grid;
  grid-template-columns: 280px 1fr 260px;
  gap: 0; height: 100%; min-height: 0;
}
.chat-list {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border-soft);
  background: var(--bg-elev);
  min-height: 0;
}
.chat-list-hd {
  padding: 12px 14px;
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.chat-list-hd h3 { margin: 0; font-size: 14px; font-weight: 600; flex: 1; }
.chat-list-search {
  padding: 8px 12px; border-bottom: 1px solid var(--border-soft);
}
.chat-list-search input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px; font: inherit; font-size: 12px; color: var(--text);
}
.chat-list-section { padding: 8px 8px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-4); font-weight: 600; }
.chat-list-items { flex: 1; overflow-y: auto; padding: 0 4px 8px; min-height: 0; }
.chat-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius); cursor: pointer;
  margin: 1px 0;
}
.chat-list-item:hover { background: var(--surface-hover); }
.chat-list-item.is-active { background: var(--accent-soft); }
.chat-list-item .avatar { width: 32px; height: 32px; font-size: 11px; flex-shrink: 0; position: relative; }
.chat-list-item .avatar.online::after {
  content: ''; position: absolute; right: -2px; bottom: -2px;
  width: 9px; height: 9px; background: var(--success);
  border: 2px solid var(--bg-elev); border-radius: 50%;
}
.chat-list-item .mid { flex: 1; min-width: 0; }
.chat-list-item .name { font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 6px; }
.chat-list-item .name b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-item .preview { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.chat-list-item .right  { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.chat-list-item .time   { font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); }
.chat-list-item .unread {
  background: var(--accent); color: var(--accent-ink);
  font-size: 10.5px; font-family: var(--font-mono); font-weight: 600;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.chat-stream {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg);
}
.chat-stream-hd {
  padding: 11px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elev);
}
.chat-stream-hd .name { font-size: 14px; font-weight: 600; color: var(--text); }
.chat-stream-hd .sub  { font-size: 11.5px; color: var(--text-3); }
.chat-stream-hd .grow { flex: 1; }

.chat-stream-body {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.chat-msg-day {
  text-align: center; font-size: 11px; color: var(--text-3);
  margin: 12px 0 8px;
}
.chat-msg {
  display: flex; gap: 10px; padding: 4px 0;
  position: relative;
}
.chat-msg-content { flex: 1; min-width: 0; }
.chat-msg-hd { display: flex; align-items: baseline; gap: 6px; }
.chat-msg-hd .who { font-weight: 500; font-size: 12.5px; color: var(--text); }
.chat-msg-hd .when { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }
.chat-msg-body {
  font-size: 13px; line-height: 1.5;
  color: var(--text); word-break: break-word;
}
.chat-msg.is-mine .chat-msg-body { color: var(--text); }
.chat-msg.is-system {
  text-align: center; opacity: 0.78;
}
.chat-msg.is-system .chat-msg-body {
  display: inline-block;
  font-size: 11.5px; color: var(--text-3);
  background: var(--surface-2); padding: 4px 10px; border-radius: 12px;
}
.chat-msg-file {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-top: 4px;
}
.chat-msg-file .name { font-size: 12.5px; color: var(--text); }
.chat-msg-file .size { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }
.chat-msg-reactions { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.chat-msg-reactions .feed-reaction { font-size: 11.5px; padding: 1px 6px; }

.chat-typing {
  font-size: 11.5px; color: var(--text-3); font-style: italic;
  padding: 4px 16px; height: 22px;
}
.chat-typing .dots span { animation: ct-blink 1.4s infinite; }
.chat-typing .dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ct-blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

.chat-composer {
  padding: 10px 16px; border-top: 1px solid var(--border-soft);
  background: var(--bg-elev);
  display: flex; gap: 8px; align-items: flex-end;
}
.chat-composer textarea {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; font: inherit; font-size: 13px; color: var(--text);
  resize: none; min-height: 36px; max-height: 120px;
}
.chat-composer .ico-btns { display: flex; gap: 2px; }

.chat-right {
  border-left: 1px solid var(--border-soft);
  background: var(--bg-elev);
  display: flex; flex-direction: column;
  min-height: 0;
}
.chat-right-tab {
  padding: 11px 14px; border-bottom: 1px solid var(--border-soft);
  display: flex; gap: 14px;
}
.chat-right-tab span { font-size: 12px; color: var(--text-3); cursor: pointer; padding-bottom: 2px; }
.chat-right-tab span.is-active { color: var(--text); border-bottom: 2px solid var(--accent); }
.chat-right-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.chat-right-body h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.chat-member-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 12.5px;
}
.chat-member-row .role { font-size: 10.5px; color: var(--text-3); margin-left: auto; }
.chat-member-row .online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-4); }
.chat-member-row .online-dot.is-online { background: var(--success); }

/* ============================================
   Gantt chart (basic)
============================================ */
.gantt-wrap { display: grid; grid-template-columns: 280px 1fr; height: 100%; min-height: 0; }
.gantt-tasks { background: var(--surface); border-right: 1px solid var(--border-soft); overflow-y: auto; }
.gantt-task-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  min-height: 36px;
}
.gantt-task-row .pad-depth { width: 0; }
.gantt-task-row .pad-1 { width: 16px; }
.gantt-task-row .pad-2 { width: 32px; }
.gantt-task-row .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-chart {
  position: relative;
  overflow: auto;
  background-image: linear-gradient(to right, var(--border-soft) 0, var(--border-soft) 1px, transparent 1px, transparent 60px);
  background-size: 60px 100%;
}
.gantt-header {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg-elev); border-bottom: 1px solid var(--border-soft);
  display: flex; height: 36px; align-items: center;
}
.gantt-header .day {
  width: 60px; text-align: center; font-size: 10.5px; color: var(--text-3);
  font-family: var(--font-mono);
}
.gantt-bar {
  position: absolute;
  height: 22px; border-radius: 4px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; padding: 0 8px;
  display: inline-flex; align-items: center;
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
  white-space: nowrap; overflow: hidden;
}
.gantt-bar.is-done   { background: var(--success); }
.gantt-bar.is-parent { background: oklch(0.46 0.13 270); }
.gantt-bar.is-blocked{ background: var(--danger); }
.gantt-bar .pct { position: absolute; left: 0; top: 0; bottom: 0; background: oklch(0.46 0.13 152); border-radius: 4px; }
.gantt-bar span { position: relative; z-index: 1; }

/* ============================================
   CRM card / lead drawer
============================================ */
.crm-card-hd {
  padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 6px;
}
.crm-card-hd .id-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }
.crm-card-hd h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.crm-card-hd .sub { font-size: 12.5px; color: var(--text-2); }
.crm-card-hd .meta-row { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-3); }
.crm-card-hd .meta-row b { color: var(--text); font-weight: 500; }

/* Communication dashboard widget */
.comms-widget { display: flex; flex-direction: column; gap: 6px; }
.comms-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  cursor: pointer; font-size: 12.5px;
}
.comms-row:hover { background: var(--surface-hover); }
.comms-row .ico { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; background: var(--surface-2); }
.comms-row .label { flex: 1; }
.comms-row .count { font-family: var(--font-mono); color: var(--text-2); font-weight: 500; }


/* ============================================
   Feed composer v2 — широкий, многострочный
============================================ */
.feed-composer-v2 {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s;
}
.feed-composer-v2:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.fc-row-top { display: flex; align-items: center; gap: 10px; }
.fc-meta { flex: 1; min-width: 0; }
.fc-meta .fc-name { font-size: 13px; font-weight: 600; color: var(--text); }
.fc-meta .fc-role { font-size: 11px; color: var(--text-3); }

.fc-area {
  width: 100%;
  min-height: 80px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit; font-size: 14px; line-height: 1.5;
  color: var(--text);
  resize: vertical;
  transition: border-color .15s, background .15s;
}
.fc-area:focus {
  outline: none;
  border-color: var(--accent-line);
  background: var(--surface);
}
.fc-area::placeholder { color: var(--text-3); }

.fc-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 4px;
}
.fc-chip-group {
  display: flex; gap: 4px; flex-wrap: wrap; flex: 1;
}
.fc-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; height: 28px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 14px; color: var(--text-2);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all .12s;
}
.fc-chip:hover { background: var(--surface-hover); color: var(--text); }
.fc-chip svg { color: var(--text-3); }
.fc-chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--text);
}
.fc-chip.is-active svg { color: var(--accent-strong); }
.fc-chip.is-danger {
  background: var(--danger-soft);
  border-color: oklch(0.66 0.18 25 / .35);
  color: var(--danger);
}
.fc-chip.is-danger svg { color: var(--danger); }

.fc-actions { display: flex; align-items: center; gap: 10px; }
.fc-hint { font-size: 10.5px; color: var(--text-4); font-family: var(--font-mono); }

/* ============================================
   Topbar global search
============================================ */
.tb-search {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  margin: 0 12px;
  display: flex;
  align-items: center;
}
.tb-search-input {
  width: 100%; height: 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 56px 0 32px;
  font: inherit; font-size: 12.5px;
  color: var(--text);
  transition: border-color .15s, background .15s;
}
.tb-search-input:focus {
  outline: none;
  background: var(--bg-elev);
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.tb-search-input::placeholder { color: var(--text-3); }
.tb-search > svg:first-of-type {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
  z-index: 1;
}
.tb-search-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; color: var(--text-3);
  background: var(--bg-elev); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px;
  font-family: var(--font-mono);
  pointer-events: none;
  z-index: 1;
}
.tb-search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  max-height: 60vh; overflow-y: auto;
  z-index: 70;
}
.tb-search-group { padding: 8px 0; }
.tb-search-group-head {
  padding: 4px 14px; font-size: 10px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}
.tb-search-item {
  padding: 8px 14px; display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 12.5px;
}
.tb-search-item:hover { background: var(--surface-hover); }
.tb-search-item .id { color: var(--text-3); font-family: var(--font-mono); font-size: 11px; }
.tb-search-item .meta { color: var(--text-3); font-size: 11px; }

.fc-block {
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.fc-block-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 8px;
}

/* ============================================
   Сворачивающийся сайдбар
============================================ */
body[data-sidebar="collapsed"] { --sidebar-w: 56px; }
.sb.is-collapsed .sb-item { justify-content: center; padding: 0 6px; }
.sb.is-collapsed .sb-item-label,
.sb.is-collapsed .sb-item-count,
.sb.is-collapsed .sb-group { display: none; }
.sb.is-collapsed .sb-item-dot {
  position: absolute; top: 5px; right: 5px; margin-left: 0;
}
.sb.is-collapsed .sb-ft { justify-content: center; }
.sb.is-collapsed .sb-hd { justify-content: center; padding: 12px 6px 8px; }

/* ============================================
   Stage progress bar — pill chain
============================================ */
.stage-bar {
  display: flex; flex-direction: column; gap: 6px;
  padding: 4px 0 8px;
}
.stage-bar-row {
  display: flex; gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 4px;
}
.stage-step {
  flex: 1 0 auto; min-width: 80px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  font-size: 11.5px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all .12s;
  position: relative;
}
.stage-step:first-child {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}
.stage-step:last-child {
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}
.stage-step + .stage-step {
  margin-left: -1px;
}
.stage-step:hover {
  border-color: var(--stage-color, var(--accent));
  z-index: 1;
}
.stage-step.is-current {
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.stage-step .stage-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 10px; font-weight: 600;
  background: rgba(255,255,255,.18);
}
.stage-step.is-current .stage-num {
  background: rgba(255,255,255,.28);
}
.stage-step:not(.is-current):not(.is-passed) .stage-num {
  background: var(--surface-2);
  color: var(--text-3);
}
.stage-step .stage-label {
  overflow: hidden; text-overflow: ellipsis;
}

.stage-bar-end {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 4px;
}
.stage-end-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; height: 26px;
  border: 1px solid; border-radius: 13px;
  font-size: 11.5px; font-weight: 500;
  cursor: pointer;
  transition: all .12s;
}
.stage-end-btn:hover { opacity: 0.8; }

/* ============================================
   Drawer expanded — full screen
============================================ */
.drawer.is-expanded {
  width: 100vw !important;
  max-width: none !important;
}
